UPD 2024: standalone nuget
commands replaced with dotnet nuget
CLI. The information provided is relevant for VS2022 and .NET 8.
Cache locations
Solution-local packages folders are no longer used by .NET Core and Visual Studio. The command to list user-specific folders is:
dotnet nuget locals all --list
And its typical output (I’ve replaced absolute paths with variables and prettified it):
global-packages: %USERPROFILE%\.nuget\packages
http-cache: %$LOCAL_APPDATA%\NuGet\v3-cache
temp: %$LOCAL_APPDATA%\Temp\NuGetScratch
plugins-cache: %$LOCAL_APPDATA%\NuGet\plugins-cache
Notice that the machine-wide folder isn’t listed there. However, it is defined at Visual Studio settings: Options -> NuGet Package Manager -> Package Sources. By default it is:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
In Package Sources, you can add/remove as many cache locations as you want.
Configuration files
NuGet.config
files are located here:
- User-specific:
%APPDATA%\NuGet\
- Machine-wide:
%ProgramFiles(x86)%\NuGet\Config\
Any NuGet.config
settings can be overriden at many levels (project, solution, user, machine). Read more about NuGet.config
hierarchical priority ordering here: How settings are applied.
For example, globalPackagesFolder
parameter changes a package cache location:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<clear />
<add key="globalPackagesFolder" value="c:\packages" />
</config>
</configuration>