Detected package downgrade: Microsoft.NETCore.App from 2.1.3 to 2.1.0

48,620

Solution 1

I had a similar issue to you. Could not publish my project when I specified a runtime identifier.

The solution I got to work was to add in the following line to the *.csproj

<PropertyGroup>     
    <TargetFramework> xxx </TargetFramework>     
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>  <<<----- Add this line  
</PropertyGroup>

After that line was added the project would publish correctly.

The below link references a downgrade issue between 2.1.1 and 2.1.0 but the solution worked the same.

https://github.com/dotnet/cli/issues/9624

Solution 2

I had a missing version in the csproj file.

Adding the version fixed the issue.

enter image description here

Solution 3

After updating .net core SDK on my windows machine from .net core 2.1.0 to .net core 2.2.0 I had the same issue. I was unable to build the project and getting build error with Detected package downgrade: Microsoft.AspNetCore.Razor.Design from 2.2.0 to 2.1.0.

I have resolved this issue by updating a nuget package for Microsoft.AspNetCore.Razor.Design

Solution 4

I just experienced this same issue after adding a reference to MySQL.Data.

The only solution was to explicitly define the version of the affected references in the .csproj file:

<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" />
<PackageReference Include="System.Globalization" Version="4.3.0" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />

Solution 5

I had this issue as well. What ultimately fixed it for me was uninstalling the .NET SDK 2.1.3 from the "Programs" control panel. Or I basically had to uninstall any later versions of the related SDK libraries that my project was trying to use.

Share:
48,620
ant
Author by

ant

Updated on July 09, 2022

Comments

  • ant
    ant almost 2 years

    I try to update my .net solution from .NET Core 1.1 to .NET Core 2.1. I have several .NET Core and .NET standard projects inside, which reference each other and another NuGet packages. After update 'dotnet resore' and 'dotnet build' commands work fine, but when i try to build my solution from visual studio, i get this error:

    Error NU1605 Detected package downgrade: Microsoft.NETCore.App from 2.1.3 to 2.1.0. Reference the package directly from the project to select a different version.

    And i see that indeed some of my projects have SDK reference to Microsoft.NETCore.App v2.1.0 and some of them v.2.1.3. Setting RuntimeFrameworkVersion and adding this package to dependencies explicitly doesn't work.

    How i can deal with this?

    UPD: dotnet --info:

    .NET Core SDK (reflecting any global.json):  Version:   2.1.401  Commit:    91b1c13032
    
    Runtime Environment:  OS Name:     Windows  OS Version:  10.0.17134  OS Platform: Windows  RID:         win10-x64  Base Path:   C:\Program Files\dotnet\sdk\2.1.401\
    
    Host (useful for support):   Version: 2.1.3   Commit:  124038c13e
    
    .NET Core SDKs installed:
      1.1.10 [C:\Program Files\dotnet\sdk]
      2.0.0 [C:\Program Files\dotnet\sdk]
      2.1.4 [C:\Program Files\dotnet\sdk]
      2.1.100 [C:\Program Files\dotnet\sdk]
      2.1.202 [C:\Program Files\dotnet\sdk]
      2.1.400 [C:\Program Files\dotnet\sdk]
      2.1.401 [C:\Program Files\dotnet\sdk]
    
    .NET Core runtimes installed:   Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]   Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]   Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]   Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]   Microsoft.NETCore.App
    1.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App 1.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App
    2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App
    2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]   Microsoft.NETCore.App
    2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    
    To install additional .NET Core runtimes or SDKs:   https://aka.ms/dotnet-download
    

    UPD: Somehow issue disappears if i remove this line from .csproj file:

    <RuntimeIdentifier>win7-x64</RuntimeIdentifier>

    Can it be related?

  • Pat
    Pat about 5 years
    This fixed it for me. Strange that Microsoft.AspNetCore.App was already upgraded to 2.2 but [...].Razor.Design was left to 2.1
  • Adam Wise
    Adam Wise almost 5 years
    For some reason, I only needed to apply this to a test project. Other nearly identical projects did not require this.
  • Rutix
    Rutix almost 5 years
    This will change the behavior. This way you won't have roll forward anymore, the recommended way by Microsoft is to have a versionless Microsoft.AspNetCore.App and to have the SDK at top be <Project Sdk="Microsoft.NET.Sdk.Web">
  • Steve Smith
    Steve Smith over 4 years
    Where do you add it in the file?
  • oflahero
    oflahero about 4 years
    @SteveSmith: <PropertyGroup> <TargetFramework> xxx </TargetFramework> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> </PropertyGroup>
  • William
    William over 2 years
    You need to update your answer based on the third comment
  • Fairuz Sulaiman
    Fairuz Sulaiman over 2 years
    After upgrade my SDK with latest. It works.
  • Evgeny Gorb
    Evgeny Gorb almost 2 years
    IMHO the most correct answer since Microsoft recommends it as a solution: docs.microsoft.com/en-us/nuget/reference/errors-and-warnings‌​/…