简体   繁体   中英

When added to solution NuGet packages restore/install to multiple locations

I'm using Visual Studio 2017, building a .Net framework (not core) v4.6.1 ASP.Net MVC project and when I added packages to my single project inside my solution the packages are seemingly restoring/installing to multiple different locations. I am installing packages from multiple feeds, some are internal to my company and others are public.

Some packages are located at my solution root and others seemingly are landing at %userprofile%.nuget\\packages\\

One package even installed and its hintpath was in a completely different location from the two of them. The package was installed there but I don't know why it didn't install to what I consider the solution's local package folder.

I'm not sure if these are the right questions to ask yet, but these are what I'm trying to answer for now:

  1. For VS2017, .Net framework, ASP.Net MVC what is the default package install location?
  2. How do I specify which feed a package comes from for CI/CD purposes?
  3. Does NuGet look for packages already installed on my computer?
  4. If yes, where does NuGet look for packages and where can I find its list of locations it looks for.

Thanks!

1.For VS2017, .Net framework, ASP.Net MVC what is the default package install location?

It depends on which package management method you using. If you are use package.config , the default package install location is solution root, if you are use PackageReference , the default package install location is %userprofile%.nuget\\packages\\ . That is the reason why you added packages to single project inside the solution the packages are seemingly restoring/installing to multiple different locations. You can unload and edit your project, check the project file .csproj , you will find following:

  <ItemGroup>
    <PackageReference Include="xxxxx">
      <Version>x.x.x</Version>
    </PackageReference>
  </ItemGroup>

To resolve this issue, you can accept the advice of Lex. If you want to unify, make the choice and change the files. You can uninstall those packages which using PackageReference (or package.config), then change the nuget settings(Tools->Options->NuGet Package Manager->General-> Default package management format ->Packages.config), then reinstall those packages, make sure they use a uniform form.

2.How do I specify which feed a package comes from for CI/CD purposes?

You can not do such things and you do not need to do things. As we know, when we install nuget packages from multiple feeds, all the packages are downloaded to the local host, Visual Studio will use those packages on the local, Nuget does not care which feed it comes from.

3.Does NuGet look for packages already installed on my computer? 4.If yes, where does NuGet look for packages and where can I find its list of locations it looks for.

Yes, you can use the command line nuget locals all -list to find its list of locations.

See Managing the global packages, cache, and temp folders for some more details.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM