"Detected package downgrade" 警告是什么意思?

What does the "Detected package downgrade" warning mean?

当我 运行 dotnet restore(或 运行 在 Visual Studio 中恢复包)时,我看到这样的警告:

  • /usr/local/share/dotnet/sdk/1.0.4/NuGet.targets(97,5): warning : Detected package downgrade: Microsoft.EntityFrameworkCore.Design from 1.1.1 to 1.0.3 [/Users/markamery/somesolution/SomeSolution.sln]
  • /usr/local/share/dotnet/sdk/1.0.4/NuGet.targets(97,5): warning : SomeProject (>= 1.0.0) -> Microsoft.EntityFrameworkCore.Tools (>= 1.1.0) -> Microsoft.EntityFrameworkCore.Design (>= 1.1.1) [/Users/markamery/somesolution/SomeSolution.sln]
  • /usr/local/share/dotnet/sdk/1.0.4/NuGet.targets(97,5): warning : SomeProject (>= 1.0.0) -> Microsoft.EntityFrameworkCore.Design (>= 1.0.3) [/Users/markamery/somesolution/SomeSolution.sln]

我正在努力解析上面警告的含义。有很多事情我不清楚:

在这种情况下,您的依赖关系图引用了 Microsoft.EntityFrameworkCore.Design 的两个版本。这由包含 ->:

的行指示

在第一行之后,它显示您的项目引用了 Microsoft.EntityFrameworkCore.Tools 版本 1.1.0,它被解析为一个包,该包又引用了版本 1.1.1Microsoft.EntityFrameworkCore.Design .

然后显示你的包在1.0.3处直接引用了Microsoft.EntityFrameworkCore.Design

NuGet documentation for dependency resolution 规定了适用于这种情况的规则:

Nearest wins

When the package graph for an application contains different versions of the same package, the package that's closest to the application in the graph is used and others are ignored. This allows an application to override any particular package version in the dependency graph.

此规则适用于此,因为您的应用直接引用了与另一个依赖项不同的包版本。由于此版本较低,NuGet 会发出警告来提醒您,因为其他依赖项可能需要较低版本中不存在的某些功能。该文档还包括关于此的警告:

The Nearest Wins rule can result in a downgrade of the package version, thus potentially breaking other dependencies in the graph. Hence this rule is applied with a warning to alert the user.