2

I have a solution with many projects that use many packages. Generally, packages have installed to the "packages" subfolder under the solution. But now I've noticed that a recently installed package did not install there. Instead, it installed to \users\myid\packages. Many other packages are installed there. Some are duplicates of the ones in the solutions folder, and some are additional.

Some packages may have been installed with the visual studio solution manager, some with the visual studio command line for nuget, but this difference doesn't seem to account for the difference in the install location.

Why did my latest package not install to the solution folder? How can I make it do so?

I'm using Visual Studio 2022, with a mix of .net framework and .net core/5+ projects.

Elroy Flynn
  • 3,032
  • 1
  • 24
  • 33
  • That depends on the type of project: SDK style projects always install to the global folder, projects still using a `packages.config` file install to the projects subfolder. – PMF Jan 01 '23 at 19:52
  • Why exactly do you care? The answer might depend on that. – PMF Jan 01 '23 at 19:52
  • @pmf When you say "install to the projects subfolder" do you mean the solution\packages subfolder? That's what I want and I'm not getting. I didn't realize that a sdk project doesn't use the solution\packages folder. I want this because my existing build system looks for packages in solution\packages. My issue is somewhat related to https://stackoverflow.com/questions/43837638/how-do-i-get-net-core-projects-to-copy-nuget-references-to-the-build-output/52824190#52824190 – Elroy Flynn Jan 01 '23 at 20:54
  • Sorry, yes. That's what I meant. You can change the name of the solution\packages folder with an entry in the Nuget.Config file, but I don't think you can change the global folder or disable it. I think the only way forward is to update your build system to support using the global folders. Most existing build systems (e.g. Cake or Nuke) already provide support for getting the path to a package by name. – PMF Jan 02 '23 at 07:06

1 Answers1

0

Projects using the PackageReference format always use packages directly from global-packages. When using the packages.config, packages are installed to the global-packages folder, then copied into the project's packages folder(solution\packages subfolder).

You can refer to doc:Managing the global packages, cache, and temp folders

If you use packages.config to install packages,it will install to solution\packages subfolder.

If you use visual studio command line for nuget or other,it will install to global-packages(default).

You can use nuget locals global-packages -list to get the path of global-packages.

If you want packages installed to solution folder,you can use nuget config to override the path to install.

For example:

nuget config -set globalPackagesFolder=<your solution subfolder>
snipsnipsnip
  • 2,268
  • 2
  • 33
  • 34
Dou Xu-MSFT
  • 880
  • 1
  • 1
  • 4