NuGet packages not added to local cache

We are having problems with most of our builds being a bit too slow. After investigating a bit, we see that NuGet packages are never added to the local cache (C:\Windows\System32\config\systemprofile\.nuget\packages), so we have to pull them down again for every build, which takes some time. We see that the builds themselves look in the cache:

[13:25:27][install] Feeds used:
[13:25:27][install] C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache
[13:25:27][install] C:\Windows\system32\config\systemprofile\.nuget\packages\
[13:25:27][install] https://nuget.org/api/v2/
 

Is there any way for us to enable usage of the local nuget cache to speed things up a bit?

 

With regards,

Nikolai Maric

 

9 comments
Comment actions Permalink
Official comment

Hi, Nikolay

In case you are talking about Install NuGet packages runner - there is an advanced option on runner settings page 'Disable looking up packages from local machine cache'
Please check that it is turned off.

Comment actions Permalink

I forgot to mention that in my original post, but the option is turned off for these builds. The problem seems to be that packages are never getting added to the local build server cache in the first place - at least, I can't see anything showing up in the C:\Windows\System32\config\systemprofile\.nuget\packages during or after the build has run.

 

With regards,

Nikolai Maric

 

0
Comment actions Permalink

What do you mean by local build server? Are you talking about build agent?

Please check that NuGet.exe version you use actually cache packages when called directly from Command Line runner.

0
Comment actions Permalink

Sorry if I was unclear, I was talking about the build agent.

I logged into one of the build agents, and ran a package install from the command line. The package was added to C:\Users\myusername\.nuget\packages. The build agent runs as local system, and C:\Windows\system32\config\systemprofile\.nuget\packages does not contain packages downloaded during builds.

 

With regards,

Nikolai Maric

0
Comment actions Permalink

I now tried to run nuget from the command line as the local system user, installing the same package as above. This time, the package was not added to either C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache or C:\Windows\system32\config\systemprofile\.nuget\packages.

 

With regards,

Nikolai Maric

0
Comment actions Permalink

Hi,

we have the same problem, we spend 3 minutes (+ bandwidth) on every build to download all the packages again and again, can you pls answer us how to avoid this ?

I've seen that the nuget cache is set via 'NUGET_PACKAGES' environment variable to 'C:\BuildAgent\temp\buildTmp\.nuget\packages' and it's cleaned up on every build star, is it possible to change this behavior ?

0
Comment actions Permalink

Hi,

when running NuGet under the Local System account MSBuild can fail:
https://github.com/NuGet/Home/issues/4277

To fix it, we automatically override the NUGET_PACKAGES env var to the build temp directory. To reuse cache you could start the build agent under a normal user account or set the NUGET_PACKAGES variable for the local system account on the machine.

0
Comment actions Permalink

Thanks,

i decided to run teamcity under local account.

0
Comment actions Permalink

I guess you have to force a different environment variable. 

See https://github.com/NuGet/Home/issues/3324#issuecomment-679177442

0

Please sign in to leave a comment.