繁体   English   中英

NuGet解决了错误的包依赖版本

[英]NuGet resolves the wrong version of package dependency

所以我有一个NServiceBus.Host包依赖于NServiceBus> = 4.5.0。

在nuget上有一个4.5.1版本的NServiceBus。 当我安装包NServiceBus.Host我得到:

PM> install-package nservicebus.host
Attempting to resolve dependency 'NServiceBus (≥ 4.5.0)'.
Attempting to resolve dependency 'NServiceBus.Interfaces (≥ 4.5.0)'.
Installing 'NServiceBus.Interfaces 4.5.0'.
You are downloading NServiceBus.Interfaces from NServiceBus Ltd, the license agreement to which is available at http://particular.net/LicenseAgreement. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'NServiceBus.Interfaces 4.5.0'.
Installing 'NServiceBus 4.5.0'.

如您所见,我得到4.5.0版本的依赖项。

nuget doco中它说:

如果未安装依赖项,NuGet将执行以下步骤:

NuGet枚举了版本规范中的Feed中的每个Subkismet版本。 然后NuGet缩小设置为具有最低主要/次要版本的包。 在其余的软件包中,NuGet选择版本号最高的软件包。

“NuGet选择版本号最高的那个。” 似乎在这里违反了,因为有一个永不版本。

这是NuGet中的错误吗?

您引用的依赖项解析的NuGet文档自2010年12月以来尚未更新。真正的NuGet文档可在此处获取: https//docs.nuget.org

此外,NuGet将 - 默认情况下 - 解析允许范围内的最低major.minor版本,如包依赖项中所定义。 所以4.5.0是一个正确的默认依赖解析。

自NuGet v2.8.1以来的新功能:您可以使用NuGet包管理器控制台使用备用依赖项解析算法:

Install-Package NServiceBus.Host -DependencyVersion HighestPatch

还有更多选项,请查看以下文档: https//docs.nuget.org/docs/reference/package-manager-console-powershell-reference#Install-Package

正如Xavier所说,这似乎是默认行为。 但是,文档说您可以通过编辑nuget配置来更改默认行为:

指定要从有效依赖关系包列表中选择的依赖关系包的版本。 最低价值是最低的。 您可以通过在nuget.config文件中指定新的默认值来覆盖此默认值:

<configuration>
    <config>
        <add key="DependencyVersion" value="HighestPatch" />
    </config>
</configuration>

我按照文档中的描述编辑了我的配置文件:

%AppData%\Nuget\NuGet.Config

然后它在Powershell中工作,但不在常规命令提示符中。

文档还说:

奇怪的是,文档说2.7.2的默认值是HighestPatch ...

请注意,对于NuGet 2.7.2或更早版本,默认值为HighestPatch,并且无法更改。

2.8的发行说明提到了行为的变化,以及安装包现在具有一致的依赖性解析结果的原因。

https://docs.nuget.org/docs/release-notes/nuget-2.8

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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