alt text

When I’m reviewing new projects, or being really strict in checking builds I like fully delete anything cached on my local dev machine so it will emulate a fresh build server.

Clearing the Caches

There are 3 ways to clear NuGet caches that I know about

VS2019, Tools, Options, NuGet Package Manager, General, Clear all caches

Or from the command line, and these both seem to do the same thing. NuGet CLI Download

dotnet nuget locals all --clear

nuget locals all -clear

Which gives output:

Clearing NuGet HTTP cache: C:\Users\dave\AppData\Local\NuGet\v3-cache
Clearing NuGet global packages folder: C:\Users\dave\.nuget\packages\
Clearing NuGet Temp cache: C:\Users\dave\AppData\Local\Temp\NuGetScratch
Clearing NuGet plugins cache: C:\Users\dave\AppData\Local\NuGet\plugins-cache
Local resources cleared.

Clearing packages folder

Even doing a Clean Solution in Visual Studio won’t get rid of the packages folder in the solution.

So remember to delete packages in your solution (then watch inside the directory as it rebuilds)

As a side note - the packages folder should not be checked into source control (it is ignored in the default .NET .gitignore file)

Resetting the repo

This will clean out everything not in the repository eg bin/obj/packages folders resetting back to a clean state. Be careful

 git clean -xfd
  • d is directories
  • x is remove untracked files not in gitignore
  • f is force


The above was working from a .NET Framework solution using VS2019.

There does seem to be differences in the .NET Core solutions. See here