本文介绍了如何更正 dotnet restore 警告 NU1604,不包含包含下限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .NET Core 项目(针对 .netcoreapp2.0.)上执行 dotnet restore 时,我收到以下警告:

While performing a dotnet restore on a .NET Core project (targeting .netcoreapp2.0.), I get the following warning:

警告 NU1604:项目依赖 System.Net.NameResolution 不包含包含下限.在依赖版本中包含下限以确保一致的还原结果.

这是项目文件中的相关行:

Here is the relevant line from the project file:

<PackageReference Include="System.Net.NameResolution" Verison="4.3.0" />

(如果您想知道,我已包含该参考以避免警告 NU1605:检测到软件包降级.)

(If you are wondering, I have included that reference to avoid a warning NU1605: Detected package downgrade.)

如何在依赖版本中包含下限以确保一致的还原结果"?

How does one "include a lower bound in the dependency version to ensure consistent restore results"?

推荐答案

为了指示包引用的最低版本,您必须将引用的 Version 属性设置为包含以下内容的范围一个包含的下界.正如@Carter 指出的那样,微软提供了一个关于该属性格式的很好的文档.

In order to indicate a minimum version for your package references you have to set the Version property of your reference to a range that contains an inclusive lower bound. As @Carter pointed out, Microsoft provides a nice documentation about the format of that property.

如果你没有为你的引用指定一个包含下限,每次恢复都会尝试找到一个可以使用的较低版本的包.有关该警告的更多信息可以在 关于 nuget 错误和警告参考页

If you don't specify an inclusive lower bound for your references, each restore will try to find a lower version of the package that can be used. More information about that warning can be found on the nuget errors and warnings reference page

您的参考文献的唯一问题似乎是您输入了错误(Verison 而不是 Version).所以这条线应该是

The only problem with your reference seems to be that you have a typo (Verison instead of Version). So the line should be

<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />

通过这一行,您表明项目需要 4.3.0 或更高版本的 System.Net.NameResolution 包,因此 System.Net.NameResolution 的包含下限em>4.3.0.

With this line, you indicate that the project requires the version 4.3.0 or above of the package System.Net.NameResolution, hence the inclusive lower bound on 4.3.0.

这篇关于如何更正 dotnet restore 警告 NU1604,不包含包含下限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 23:31