NuGet 包源优先级 [英] NuGet packageSources priority

查看:51
本文介绍了NuGet 包源优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您的 NuGet.config 中有多个 packageSources:

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

运行 nuget install 等时是否使用了 XML 中的顺序?如果我在两个版本中都有 1.0.0-SNAPSHOT 版本的 packageA,那么 feature1 分支上的开发频道版本会赢吗?

解决方案

您的提要在 nuget.config 中的顺序决定了它们在从 Visual Studio 的 NuGet 的各种视图的下拉菜单中显示的顺序.在所有情况下,您都可以选择从哪个源进行安装.请参阅下面的屏幕截图.

Visual Studio 不会跟踪您的包的来源,因此包 ID 实际上位于全局命名空间中,您必须知道它属于哪个提要.Visual Studio 将向您显示来自所选提要的任何包以及匹配的 ID,因此您可能会用另一个提要中的另一个提要覆盖从一个提要安装的包.

对于我在公司管理的 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?

解决方案

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.

这篇关于NuGet 包源优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆