Just before the start of my weekend, I got a message from one of our administrators, the disk space on one of our build servers was filling up. Whoops!
A took a look at the server and noticed that a lot of the disk space was eaten up by the .nuget folder:
What is this .nuget folder?
The .nuget folder is the default global packages folder. It is the location where NuGet installs any downloaded package. In the first NuGet versions packages were installed as part of the solution tree where the packages were used.
But since a long time, this got replaced by the global packages folder avoiding having package copies found everywhere on your local file system.
The default location is:
- Windows:
%userprofile%\.nuget\packages
- Mac/Linux:
~/.nuget/packages
How to change the global packages location?
The easiest way to change this location is by setting the NUGET_PACKAGES environment variable to a different path:
$Env:NUGET_PACKAGES = "d:\.nuget\packages"
More information
How to manage the global packages, cache, temp folders in NuGet | Microsoft Learn