Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet packageSources priority

Tags:

nuget

If you have multiple packageSources in your NuGet.config:

<packageSources>
  <clear />
  <add key="dev" value="http://server2/branches/feature1/nuget" />
  <add key="release" value="http://server1/nuget" />
</packageSources>

Is the order in the XML used when running nuget install, etc? If I have packageA at version 1.0.0-SNAPSHOT in both, will the dev channel version on feature1 branch win?

like image 274
Skeeterbug Avatar asked Apr 07 '16 08:04

Skeeterbug


People also ask

Can I delete .NuGet folder?

Yes, the . nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed.

How do I change the source of a NuGet package?

To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.

What is the default NuGet package source?

The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux). A relative path can be used in project-specific nuget.


1 Answers

The order of your feeds in nuget.config determines the order that they show up in the drop down menus from the various views into NuGet from Visual Studio. In all cases, you have the choice of which feed you install from. See the screenshots below.

Visual Studio doesn't keep track of where your package came from, so the package ID is really in a global namespace that you have to know which feed it's a part of. Visual Studio will show you any package from the selected feed with a matching ID, so it's possible that you'd overwrite a package you installed from one feed with another from a different feed.

For a NuGet feed that I manage at my company, I prefix our internal packages with <CompanyName>. so as to reduce the risk for a naming conflict now and in the future.

enter image description here

enter image description here

like image 180
Frank Bryce Avatar answered Oct 07 '22 19:10

Frank Bryce