9

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?

2 Answers 2

8

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.

3
  • Thanks very much for your answer, things are a bit clear now. I found some info on project.json here: github.com/NuGet/Home/wiki/…. I am still on on Visual Studio 2015, does that mean I need to use project.json util I can upgrade to 2017? Also is there away to configure dependencies using the package manager console I do I have edit project.json by hand?
    – Shane
    Commented Sep 6, 2017 at 6:03
  • Yes 2015 only has classic packages.config or project.json. I think the package manger console has support for project.json, but the intent is to be able to edit the file (or the simplified csproj file in 2017) manually as well (e.g. when not using VS) Commented Sep 6, 2017 at 6:31
  • this does not play well with source control integration. VS2017 and VS2019 always complain that this user profile folder is not mapped in the workspace. mapping it is not an option in our scenario) Commented Mar 11, 2021 at 14:51
-2

See this question, I believe everything will be clear after that

Setting up a common nuget packages folder for all solutions when some projects are included in multiple solutions

4
  • This is about repositoryPath, not the new global package cache Commented Sep 5, 2017 at 10:36
  • Thanks but have read this question which helped me figure out how to specify a central local for project to reference packages from but it doesn't explain why I have packages in my user directory which don't seem to be referenced anywhere.
    – Shane
    Commented Sep 5, 2017 at 11:38
  • This makes it a bit clearer learn.microsoft.com/en-us/nuget/consume-packages/… - it seems there is just one but several caches.
    – Shane
    Commented Sep 5, 2017 at 12:29
  • It's the globalPackagesFolder which is used for new-style csproj projects (and has been used for project.json in VS 2015 / UWP projects) Commented Sep 5, 2017 at 13:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.