Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correct dotnet restore warning NU1604, does not contain an inclusive lower bound?

Tags:

.net-core

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

warning NU1604: Project dependency System.Net.NameResolution does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.

Here is the relevant line from the project file:

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

(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"?

like image 658
Wallace Kelly Avatar asked Sep 16 '17 13:09

Wallace Kelly


4 Answers

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.

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

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" />

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.

like image 112
Monticola Explorator Avatar answered Nov 03 '22 23:11

Monticola Explorator


I think the key there is to not include the last digit on your version. Then it will set the lowerbound as 4.3.0 by default.

<PackageReference Include="System.Net.NameResolution" Version="4.3" />
like image 9
Carter Avatar answered Nov 03 '22 22:11

Carter


Right click "Packages" -> Manage NuGet Packages -> Update

Update all broken packages, if that is not available remove them and add them again.

like image 5
Heinzlmaen Avatar answered Nov 03 '22 23:11

Heinzlmaen


Managing the package version is quite important. you must mention the version or have a floated version specified.

<PackageReference Include="System.Net.NameResolution" Version="4.3" /> or <PackageReference Include="System.Net.NameResolution" Version="4.*" />

like image 1
rish90 Avatar answered Nov 03 '22 22:11

rish90