Clearing NuGet Caches

5/12/2025
2 minute read

NuGet can cache a lot of packages and other stuffs over time. Here a small rundown on how to clear the biggest chunk.

You can see used caches and cachelocations via:

dotnet nuget locals all --list

I am on a MacBook and this prints the following:

http-cache: /Users/stevengiesel/.local/share/NuGet/http-cache
global-packages: /Users/stevengiesel/.nuget/packages/
temp: /var/folders/5t/gkzk4_kd5x501k1y70q__s240000gn/T/NuGetScratch
plugins-cache: /Users/stevengiesel/.local/share/NuGet/plugin-cache

I did have a check and was amazed on how much data accumalted over time. http-cache was a bit over 10GB and my global-packages was roughly 50GB. Now if you have enough space and/or you don't care, just leave it as it is. It is just cached stuff which really doesn't harm you (except occupied space).

NuGet Package Cache

The global package folder is where dotnet restore puts in all the packages across your user. So it doesn't matter which repository you are in, it always downloads every package (of course including peer dependencies for each version the package is needed) into that folder. The benefit is, unless like nodejs and npm, that you have a super quick restore for packages that are already downloaded and are not local to your repository.

To remove the cache (which will retrigger downloads), you can either clear the content of the folder or just call:

dotnet nuget locals global-packages --clear

Http Cache

The same applies to the Http Cache. Basically, that keeps metadata to some extent of your packages (for example in which versions it exists on NuGet) but also seems to have some binary data (I saw some files way beyond 10 MB file size in my cache). I am not sure what the binary content here is (in contrast to the nupkg file itself that is cached inside the global-packages folder).

In any case, if you want to delete this stuff:

dotnet nuget locals http-cache --clear

Temp

My temp folder (NuGetScratches) was roughly 100 MB - if you want to delete that:

dotnet nuget locals temp --clear

Deleting all

If you understand all the implications, you can also wipe out all the caches at once via:

dotnet nuget locals all --clear

This will force to redownload stuff from the internet once you will build an application. But at least it also removes all the clutter!

An error has occurred. This application may no longer respond until reloaded. Reload x