Detected package downgrade warning (dotnet core, vs 2017)

后端 未结 19 1373
梦如初夏
梦如初夏 2021-02-01 11:53

I have just updated all my nuget packages for my solution (dotnet core 1.1 project).

I am now getting the following warnings and I don\'t really know what they mean.

相关标签:
19条回答
  • 2021-02-01 12:12

    Try using NuGet

    I was getting:

    error NU1605: Detected package downgrade: System.Net.NameResolution from 4.3.0 to 4.0.0. Reference the packagedirectly from the project to select a different version.

    So I referenced the package directory by running (in the project folder):

    dotnet add package System.Net.NameResolution
    

    See NuGet Errors - NU1605

    Issue:

    A dependency package specified a version constraint on a higher version of a package than restore ultimately resolved. That is, because of the "nearest wins" rule when resolving packages, a nearer package in the graph may have overridden a distant package.

    Solution:

    Add a direct reference to the project for the higher version of the package that you want to use.

    0 讨论(0)
  • 2021-02-01 12:15

    This generally happens because the item you are attempting to install requires a more recent version of a sub-dependency than you have already included in your project.

    The solution is to update or delete the existing dependency that is in your project prior to installing the package.

    Example:

    Detected package downgrade: Newtonsoft.Json from 9.0.0 to 8.0.0.

    This means you have Newtonsoft.Json 8.0.0 already listed as a dependency in your project, but the package you are trying to install requires at least version 9.0.0 as a dependency.

    This is because Visual studio won't automatically upgrade this dependency as you've specified an explicit version for your project. You can either upgrade the dependency in your project to the minimum required version or remove it from your project, and let the package you're installing handle it.

    To resolve this, in our example above, this would mean finding 'Newtonsoft.Json 8.0.0' and upgrading it to version '9.0.0' or simply removing it from your project prior to installing your package.

    0 讨论(0)
  • 2021-02-01 12:15

    The issue for me was that I had packages installed locally that were of higher versions than my projects referenced. If you go to Tools > NuGet Package Manager > Package Manager Settings > General > Clear All NuGet Cache(s) then rebuild your solution it'll install the packages referenced and the errors will go.

    0 讨论(0)
  • 2021-02-01 12:16

    I could solve the problem by downloading earlier version of the package causing the problem, that seems to be caused by depending on a .NET Standard version that's not installed, this also should be solved by updating Visual Studio.

    0 讨论(0)
  • 2021-02-01 12:16

    I had a similar issue, where my project had package reference like this:

    Package references:

    Package A
    Package B
        Package A
    

    So because project B reference package A, I just deleted package A from the main packages list and was left with Package B referencing Package A. I rebuilt the solution and the problem was gone.

    0 讨论(0)
  • 2021-02-01 12:19

    In my case, this error was not related to .NET Core but to .NET Standard.

    I had two libraries A, and B. Library A depended on some nuget package X, and library B depended on A. Once I upgraded X to a new version, somehow it started depending on a new version of NETStandard.Library nuget package (from 2.0.2 to 2.0.3), which broke the build of B with the error Detected package downgrade: NETStandard.Library from 2.0.3 to 2.0.2. Reference the package directly from the project to select a different version.

    Once I added the NETStandard.Library nuget package as a dependency to B (obviously targetting the latest version 2.0.3), the error went away, even if a new warning appeared:

    /usr/local/share/dotnet/sdk/2.1.403/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.targets(5,5): Warning NETSDK1023: A PackageReference for 'NETStandard.Library' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs (NETSDK1023) (GWallet.Frontend.XF)

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