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

后端 未结 8 655
遇见更好的自我
遇见更好的自我 2021-01-01 09:12

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 NuGe

相关标签:
8条回答
  • 2021-01-01 09:38

    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" />
    
    0 讨论(0)
  • 2021-01-01 09:45

    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.

    0 讨论(0)
  • 2021-01-01 09:46

    For future readers.

    So early in the morning, my code was building.

    Then I started getting this error:

    Error   NU1605  Detected package downgrade: Microsoft.Extensions.Logging from 3.1.1 to 2.1.1. Reference the package directly from the project to select a different version.
    

    and I got it on 2 assemblies,csprojs.

    MyCompany.MyProject.SomeLibraryONE 
    MyCompany.MyProject.SomeLibraryTWO
    

    So of course, I started tracking down "Microsoft.Extensions.Logging".

    But then I remembered "It was working this morning", and I back tracked my changes.

    I found a new package (nuget import) add in

    MyCompany.MyProject.SomeLibraryTHREE
    

    (and ONE and TWO had a reference to THREE)

    Here was the "new" line:

    <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.1" />
    

    So I looked and looked, but this was the ONLY place "Microsoft.Extensions.Http" package was being imported.

    Do what?

    From memory, I just kinda remembered that I had alot of "3.1.0" package imports, but no 3.1.1.

    examples of OTHER package imports (for example):

    <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0" />
    

    Long story:short..............I changed that new package import (the new import was the prime-suspect in my code breakage)...and changed it to to match the "3.1.0 world".

    So I now had this.

    <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
    

    And now everything works.

    So the (actual) error could be a red-herring to what is actually happening.

    Hopefully you're using source control, and can "reverse" step it.

    Just to finish this out...here is the the weird part:

    \.nuget\packages\microsoft.extensions.http\3.1.1\lib\netcoreapp3.1\Microsoft.Extensions.Http.dll
    

    I opened up this file.

    and it references

    // Microsoft.Extensions.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
        // Assembly reference loading information:
        // Info: Success - Loading from: C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1.0\Microsoft.Extensions.Logging.dll
    

    Not, it is "3.1.0\Microsoft.Extensions.Logging.dll". So what is it breaking stuff????? (Who knows?)

    so while it doesn't make sense to me...........what I showed above did address the issue.

    Go figure.

    Hope that helps someone.

    0 讨论(0)
  • 2021-01-01 09:47

    My version of this issue (I think) was caused by a combination of actual .NET Core versions installed on a Jenkins build server alongside a Unit Test project having ambigious references.

    I understand that, in an ideal world, dotnet expects no version stated in the csproj for AspNetCore - providing maximum flexibility during build:

    <PackageReference Include="Microsoft.AspNetCore.App" />
    

    However, on the build server when it compiled the main project (first), it chose to use 2.1.6 as the AspNetCore version. It then tries to compile the test project, and that project had a minimum version of "2.1.1", so build process tries to downgrade and then aborts the build as a fail.

    I removed the "2.1.1" minimum version from the test project, but then the test project would not build locally because it could not resolve the dependencies unambigiously. After a number of NuGet package upgrades / downgrades no joy, so chose to force a "2.1.6" minimum version so align with build server.

    This still could not resolve locally all the dependencies correctly, and finally ended up with forcing the minimum version for NetCore as well:

    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.6" />
    <PackageReference Include="Microsoft.NetCore.App" Version="2.1.6" />
    

    Everything now built locally and on the Jenkins build server!

    0 讨论(0)
  • 2021-01-01 09:48

    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

    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    

    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

    0 讨论(0)
  • 2021-01-01 09:48

    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

    0 讨论(0)
提交回复
热议问题