Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does NuGet store packages in C:\Users\<UserName>\.nuget\packages?

Tags:

nuget

I understand that it is now possible to configure a global package directory for all projects but I noticed that NuGet also puts files in my home directory. Is it possible to configure a single repo which will be used for all projects?

like image 202
Shane Avatar asked Sep 05 '17 09:09

Shane


1 Answers

NuGet introduced a new way of package management in for project.json (now deprecated) and PackageReference-based projects (default .NET Core, .NET Standard).

Instead of creating a solution-local packages folder to which all packages are downloaded and extracted (alt: repositoryPath location in NuGet.Config override), all packages are downloaded to a global location (controlled by globalPackagesFolder in NuGet.Config) which is defaulted to %userprofile%\.nuget\packages (~/.nuget/packages on linux/Mac).

The idea is that you don't have to download packages multiple times and the csproj files no longer reference all individual files but just the package. .NET Core projects also do not need to copy the NuGet packages' assets because the generated .runtimeconfig.json file specifies the location of the global cache to look up the packages at runtime, so builds can be a little bit faster.

like image 68
Martin Ullrich Avatar answered Nov 11 '22 09:11

Martin Ullrich