Howto disable nuget machine-wide cache?

2019-06-25 17:47发布

问题:

As you know NuGet uses %LOCALAPPDATA%\NuGet\Cache location for caching. It first checks if requested packages is here then download if needed.

How can I properly disable this cache mechanism from Nuget and "Visual Studio 2013", and make sure they always download from sources?

Can I build Nuget Package Manager Extension from source, then install it to Visual Studio? Or Are there any registry configuration that disable it?

Thanks

回答1:

You cannot disable NuGet from using a cache. The only thing you can do without changing the source code is to change the location of the cache directory using a NuGetCachePath environment variable.

So you are left with clearing the local cache manually or automatically before installing a NuGet package or modifying the source code for NuGet's Visual Studio extension.

The source code for NuGet 2.8.5 and older is available on CodePlex.

The source code for NuGet 3.0 is available on GitHub

There are some instructions available on how to setup the NuGet development environment to be able to build and run NuGet within Visual Studio.



回答2:

Currently it's possible to do so in case you'd running Install NuGet packages task through CLI which is common practice.

You can order NuGet to not use it's cache at all by using -NoCache input parameter. Then it will behave as you described. See CLI reference of NuGet.exe