错误NU1605检测到程序包降级 [英] Error NU1605 Detected package downgrade
问题描述
我在 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还原时,我还会收到以下错误,但我不确定是否与之相关:
When performing dotnet restore from the CLI, I also get the following error, which I am not sure is related:
C:\Program Files\dotnet\sdk\2.1.200\NuGet.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:\MyProject\MyProject.sln]
C:\Program Files\dotnet\sdk\2.1.200\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\MyProject\MyProject.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.
推荐答案
错误NU1605检测到程序包降级
Error NU1605 Detected package downgrade
对于错误 NU1605 :
您可以使用< NoWarn> NU1605< / NoWarn>
清除项目中的 WarningsAsErrors
。
You can use <NoWarn>NU1605</NoWarn>
to clear the WarningsAsErrors
in your project.
那是因为 netcoreapp2.0
项目具有< WarningsAsErrors> NU1605< / WarningsAsErrors>
默认情况下。从属性->构建->将警告作为错误进行检查:
That because netcoreapp2.0
projects have <WarningsAsErrors>NU1605</WarningsAsErrors>
by default. Check it from Properties->Build->Treat warning as errors:
添加如下内容:
<PackageReference Include="Colorful.Console" Version="1.2.6">
<NoWarn>NU1605</NoWarn>
</PackageReference>
在此处查看博客文章: MSBuild集成NuGet警告和错误和意外的软件包版本警告。
Check the blog post here: MSBuild integration of NuGet warnings and errors and Unexpected package version warnings.
对于错误 NU1603 :
发生警告是因为Feed中不存在 System.Runtime.Handles
(> = 4.1.0 )。通常,这是软件包创作错误,因为软件包依赖于不存在的东西。
The warning occurs because System.Runtime.Handles
(>= 4.1.0) does not exist in the feed. Typically this is a package authoring error because the package depends on something that doesn't exist.
您还可以使用< NoWarn> NU1603< / NoWarn>
解决此问题:
You can also use <NoWarn>NU1603</NoWarn>
to resolve this issue:
<PropertyGroup>
<NoWarn>NU1603</NoWarn>
</PropertyGroup>
注意:您会注意到您的项目还有另一个警告,请注意PackageReference上的黄色三角形标志 DotSpinners
参考。那是因为软件包 DotSpinners
是一个.NET Framework项目,与您的.NET Core项目不兼容。
Note:You would notice that your project has another warning, notice the yellow triangle insignia on the PackageReference DotSpinners
on Reference. That because the package DotSpinners
is a .NET Framework project, not compatible with your .NET Core project.
希望这会有所帮助。
这篇关于错误NU1605检测到程序包降级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!