Skip to content

[Bug]: Package downgrade and error messages #10126

Open

Description

@marcin-krystianc

Hi, we've discovered recently that NuGet has native support for central package versioning CPVM. It is definitely a good step forward to simplify version management for large solutions, but it seems that there are some significant changes in how the restore errors are being reported.

Test solution

Let's assume that we have simple application with two library projects (SimpleAppWithLibs-Centralised.zip), e.g.:

App -> Lib1 -> Newtonsoft.Json (>= 9.0.1)
    -> Lib2 -> Newtonsoft.Json.Bson (>= 1.0.2) -> Newtonsoft.Json (>= 12.0.1)

Problem

When we try to run dotnet restore for such solution then we get following error messages:

error NU1109: Detected package downgrade: Newtonsoft.Json from 12.0.1 to centrally defined 9.0.1. Update the centrally managed package version to a higher version.  [...\Solution.sln]
error NU1109:  App -> Newtonsoft.Json.Bson 1.0.2 -> Newtonsoft.Json (>= 12.0.1)  [...\Solution.sln]
error NU1109:  App -> Newtonsoft.Json (>= 9.0.1) [...\Solution.sln]
error NU1109: Detected package downgrade: Newtonsoft.Json from 12.0.1 to centrally defined 9.0.1. Update the centrally managed package version to a higher version.  [...\Solution.sln]
error NU1109:  Lib2 -> Newtonsoft.Json.Bson 1.0.2 -> Newtonsoft.Json (>= 12.0.1)  [...\Solution.sln]
error NU1109:  Lib2 -> Newtonsoft.Json (>= 9.0.1) [...\Solution.sln]
  Failed to restore ...\Lib2\Lib2.csproj (in 300 ms).
  Restored ...\Lib1\Lib1.csproj (in 299 ms).
  Failed to restore ...\App\App.csproj (in 300 ms).

I appreciate the fact that by design restore operation works differently for CPVM enabled solutions compared to the non-CPVM case. My concern is that error reporting also works very differently, so for example error messages from above are repeated for each failed project. For large solutions containing hundreds of projects this can become very noisy.

Another issue is that one of the error messages suggests that App project has references to the Newtonsoft.Json and to the Newtonsoft.Json.Bson where actually it doesn't have any of these references. It is not clear from the error message that these are transitive references from Lib1 and Lib2.

Can you please confirm whether this is desired error reporting behaviour for CPVM enabled solutions?

Version

  • dotnet.exe --version : 5.0.100-rc.2.20479.15

Activity

  1. self-assigned this
    on Oct 15, 2020
  2. rconard commented on Oct 15, 2020

    @rconard

    @marcin-krystianc, thank you for sharing your feedback on CPVM's restore and pack.

    Your issue is closely related to #10115. Could you take a look at that issue?

    We would appreciate your giving feedback on that issue. If you are okay, I will merge these issues.

  3. marcin-krystianc commented on Oct 16, 2020

    @marcin-krystianc
    Author

    @rconard I see how these two issues are related but I think it is better to keep them separate.
    My concern in this issue is only about how the version downgrade errors are being reported when the "transitive pinning" behaviour is enabled (regardless of whether it is the default or opt-in behaviour).

    As I said in the previous comment, there are two problems with these error messages:

    • It is going to be a lot of repetition in error messages (especially for large solutions), but maybe that is unavoidable.
    • There is no distinction between direct references and transitive reference in the error message. Therefore I think that the error message can be confusing.

    Maybe the transitive reference type can be marked with different type of arrow e.g. : ~> ? So the example from previous comment would look like this:

    error NU1109: Detected package downgrade: Newtonsoft.Json from 12.0.1 to centrally defined 9.0.1. Update the centrally managed package version to a higher version.  [...\Solution.sln]
    error NU1109:  App ~> Newtonsoft.Json.Bson 1.0.2 -> Newtonsoft.Json (>= 12.0.1)  [...\Solution.sln]
    error NU1109:  App ~> Newtonsoft.Json (>= 9.0.1) [...\Solution.sln]
    error NU1109: Detected package downgrade: Newtonsoft.Json from 12.0.1 to centrally defined 9.0.1. Update the centrally managed package version to a higher version.  [...\Solution.sln]
    error NU1109:  Lib2 -> Newtonsoft.Json.Bson 1.0.2 -> Newtonsoft.Json (>= 12.0.1)  [...\Solution.sln]
    error NU1109:  Lib2 ~> Newtonsoft.Json (>= 9.0.1) [...\Solution.sln]
      Failed to restore ...\Lib2\Lib2.csproj (in 300 ms).
      Restored ...\Lib1\Lib1.csproj (in 299 ms).
      Failed to restore ...\App\App.csproj (in 300 ms).
    
  4. changed the title [-][CPVM] Package downgrade and error messages[/-] [+][Bug]: Package downgrade and error messages[/+] on Apr 15, 2022
  5. self-assigned this
    on May 2, 2022
  6. removed their assignment
    on Jan 7, 2025
  7. added
    Priority:3Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog.
    and removed
    Priority:2Issues for the current backlog.
    on Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions