Home: .NET Core 2.0.0 Preview 2 - downgrade warnings have become errors when running package restore

Created on 13 Jul 2017  路  5Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used: dotnet.exe
NuGet version: 2.12.0.0
dotnet.exe --version (if appropriate): 2.0.0-preview2-006497
VS version: N/A
OS version: macOS Sierra 10.12.5

This was not an issue with dotnet 1.0.4 for certain and probably all other 1.x.y.

This issue was opened following from the discussion in dotnet/core#711.

Detailed repro steps so we can see the same problem

  1. Create a new ASP.NET Core project.

  2. Force a package to downgrade. In my case, I include dependencies <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="1.0.0" /> and <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />. The Mvc package requires JsonPatch v1.1.2 and I'm forcing v1.0.0 to be installed instead.

  3. Try to run dotnet restore.

Expected behaviour

The dotnet restore should succeed, but with downgrade warnings.

Actual behaviour

The dotnet restore fails with downgrade errors.

Verbose Logs

/Users/<me>/RiderProjects/<product>/src/<company>.<product>Web.ServiceAdapters.WebSockets/<company>.<product>Web.ServiceAdapters.WebSockets.csproj : error NU1605: Detected package downgrade: Microsoft.AspNetCore.JsonPatch from 1.1.2 to 1.0.0. Reference the package directly from the project to select a different version.  [/Users/<me>/RiderProjects/<product>/<product>web-core.sln]
/Users/<me>/RiderProjects/<product>/src/<company>.<product>Web.ServiceAdapters.WebSockets/<company>.<product>Web.ServiceAdapters.WebSockets.csproj : error NU1605:  <company>.<product>Web.ServiceAdapters.WebSockets (>= 1.0.0) -> Microsoft.AspNetCore.Mvc (>= 1.1.3) -> Microsoft.AspNetCore.Mvc.Formatters.Json (>= 1.1.3) -> Microsoft.AspNetCore.JsonPatch (>= 1.1.2)  [/Users/<me>/RiderProjects/<product>/<product>web-core.sln]
/Users/<me>/RiderProjects/<product>/src/<company>.<product>Web.ServiceAdapters.WebSockets/<company>.<product>Web.ServiceAdapters.WebSockets.csproj : error NU1605:  <company>.<product>Web.ServiceAdapters.WebSockets (>= 1.0.0) -> Microsoft.AspNetCore.JsonPatch (>= 1.0.0) [/Users/<me>/RiderProjects/<product>/<product>web-core.sln]

Most helpful comment

@atrauzzi You can disable these warnings using the following:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <NoWarn>$(NoWarn);NU1605</NoWarn>
  </PropertyGroup>
</Project>

All 5 comments

This issue is not present with Preview 1, so this issue is caused by some change introduced between .NET Core 2.0.0-preview1-005685 and 2.0.0-preview2-006497.

Downgrade warnings are now errors by default in preview2. You can change this in your project using the NoWarn or WarningsAsErrors properties.

@emgarten - Is this WarningsAsErrors property documented anywhere? What's the syntax in XML to clear it?

@atrauzzi You can disable these warnings using the following:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <NoWarn>$(NoWarn);NU1605</NoWarn>
  </PropertyGroup>
</Project>

@atrauzzi take a look at https://blog.nuget.org/20170815/Whats-nu-in-NuGet-with-VS2017-15-3.html#msbuild-integration-of-nuget-warnings-and-errors

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jainaashish picture jainaashish  路  3Comments

msaraf1 picture msaraf1  路  3Comments

livarcocc picture livarcocc  路  3Comments

clairernovotny picture clairernovotny  路  3Comments

philippe-lavoie picture philippe-lavoie  路  3Comments