错误 NU1605 检测到包降级 [英] Error NU1605 Detected package downgrade

查看:27
本文介绍了错误 NU1605 检测到包降级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 netcoreapp2.0 控制台应用程序中遇到以下 NU1605 依赖项错误:

I am experiencing the following NU1605 dependency errors in my netcoreapp2.0 console application:

NU1605  Detected package downgrade: System.Diagnostics.Debug from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
 MyProject -> Colorful.Console 1.2.6 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Diagnostics.Debug (>= 4.3.0) 
 MyProject -> System.Diagnostics.Debug (>= 4.0.11)

NU1605  Detected package downgrade: System.Runtime.Extensions from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
 MyProject -> Colorful.Console 1.2.6 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Runtime.Extensions (>= 4.3.0) 
 MyProject -> Colorful.Console 1.2.6 -> System.Runtime.Extensions (>= 4.1.0)    MyProject

NU1605  Detected package downgrade: System.Runtime.Handles from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version. 
 MyProject -> Colorful.Console 1.2.6 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Runtime.Handles (>= 4.3.0) 
 MyProject -> Colorful.Console 1.2.6 -> System.IO.FileSystem 4.0.1 -> System.Runtime.Handles (>= 4.0.1)

NU1605  Detected package downgrade: System.Runtime.InteropServices from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version. 
 MyProject -> Colorful.Console 1.2.6 -> System.Console 4.0.0 -> runtime.win.System.Console 4.3.0 -> System.Runtime.InteropServices (>= 4.3.0) 
 MyProject -> Colorful.Console 1.2.6 -> System.Runtime.InteropServices (>= 4.1.0)

我尝试在 csproj 中引用这些包版本,但这并不能解决问题.参见 csproj:

I have tried referencing these package versions in csproj, but this doesn't fix the problem. See csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Colorful.Console" Version="1.2.6" />
    <PackageReference Include="CommandLineParser" Version="2.2.1" />
    <PackageReference Include="DotSpinners" Version="1.2.0" />
    <PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
    <PackageReference Include="System.Runtime.Extensions" Version="4.1.0" />
    <PackageReference Include="System.Runtime.Handles" Version="4.0.1" />
    <PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
  </ItemGroup>
</Project>

而且它们似乎恢复得很好:

And they do seem to restore fine:

该项目还引用了 Microsoft.NETCore.App 2.0 SDK.

The project is also referencing the Microsoft.NETCore.App 2.0 SDK.

从 CLI 执行 dotnet restore 时,我也收到以下错误,我不确定是否相关:

When performing dotnet restore from the CLI, I also get the following error, which I am not sure is related:

C:Program Filesdotnetsdk2.1.200NuGet.targets(114,5): error : Failed to retrieve information about 'System.Runtime.Serialization.Formatters' from remote source 'https://mycompany.pkgs.visualstudio.com/_packaging/myid/nuget/v3/flat2/system.runtime.serialization.formatters/index.json'. [C:MyProjectMyProject.sln]
C:Program Filesdotnetsdk2.1.200NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:MyProjectMyProject.sln]

我不知道为什么它试图从我们的私人公司包存储库中检索有关System.Runtime.Serialization.Formatters"的信息.

I have no idea why it's trying to retrieve information about 'System.Runtime.Serialization.Formatters' from our private company package repository.

NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="mycompany" value="https://mycompany.pkgs.visualstudio.com/_packaging/Stable/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredentials>
     <mycompany>
       <add key="Username" value="vsts" />
       <add key="ClearTextPassword" value="xxx" />
     </mycompany>
   </packageSourceCredentials>
  <disabledPackageSources>
    <add key="Microsoft and .NET" value="true" />
  </disabledPackageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <bindingRedirects>
    <add key="skip" value="False" />
  </bindingRedirects>
  <packageManagement>
    <add key="format" value="0" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>

如果这意味着什么,我还有以下 NU1603 警告:

I also have the following NU1603 warning if this means anything:

NU1603  MyProject depends on System.Runtime.Handles (>= 4.1.0) but System.Runtime.Handles 4.1.0 was not found. An approximate best match of System.Runtime.Handles 4.3.0 was resolved.

推荐答案

我在 .netcoreapp2.2 控制台应用程序中遇到了类似的问题.

I had a similar issue with a .netcoreapp2.2 console application.

该项目已成功构建.但是,发布失败,出现了几个 NU1605 错误.

The project was building successfully. However, publishing was failing with several NU1605 errors.

问题源于 log4net 2.0.8 版.它在具有以下依赖项的 .netstandard2.0 项目中被引用:

The problem was originated from log4net version 2.0.8. It was referenced in a .netstandard2.0 project with the following dependencies:

他们导致引用 log4net 的项目中的包降级.在发布期间,这些警告被视为错误...

They were causing package downgrades in the projects referencing log4net. And during publish these warnings are treated as errors...

为了解决这个问题,我通过 Nuget 添加了这些库的正确版本.

To solve the problem I added correct versions of these libraries via Nuget.

终于发布成功了.

P.S. 当我第一次添加带有最新版本库的包时,依赖项列表上会显示一个黄色警告标志,好像这些包不适合该项目.卸载项目并重新加载后,警告标志消失了!(我使用的是 Visual Studio 2019)

P.S. When I first added packages with the newest version of libraries, a yellow warning sign was displayed on the dependencies list as if the packages were not suitable for that project. After unloading the project and loading back the warning sign gone! (I'm using Visual Studio 2019)

希望能帮到你!

这篇关于错误 NU1605 检测到包降级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆