jololandayan
jololandayan

Reputation: 55

TeamCity restores nuget package - running too long in restoring the packages

I'm trying to use the nuget install plugin for TeamCity but after running, it takes too long in restoring and installing all the packages in my solution.

Can someone help in nuget restore packages in TeamCity?

enter image description here

Upvotes: 1

Views: 1202

Answers (1)

Alexandr
Alexandr

Reputation: 193

I was researching and solving the same problem. My solution took up to 20 minute(in bad times) to resolve all NuGet packages. Here is what I had found:

  1. TeamCity doesn't use the nuget cache because they reassign the env variable for the directory where they keep resolved packages. The details about this you can find on here https://teamcity-support.jetbrains.com/hc/en-us/community/posts/115000160524/comments/360000087900 And here is the reason why they do it https://github.com/NuGet/Home/issues/4277
  2. I'm not sure why but the version NuGet that provided by TeamCity v3.5, v4.6 proceed with restore operation slower than other versions.

What I did:

  1. In my case I've added the override of the env.NUGET_PACKAGES to the home Agent directory (%teamcity.agent.home.dir%/nuget-cache) in my TeamCity project. That made restore stable not more than 10 minutes. Be careful because the work and temp directory might be cleared by TeamCity Agent and your cache will not be stable.
  2. I've added the latest stable version of the NuGet.exe file (v5.8.1 in my case) https://www.nuget.org/downloads. Then I'd chosen the Custom option for NuGet Install step in TeamCity (NuGet.exe select box) and set the path to my NuGet.exe file in the solution.

After both of these steps, NuGet restore takes up to 1.5 minutes for my solution and this is ok for me.

Upvotes: 3

Related Questions