我的netcoreapp2.0控制台应用程序遇到以下NU1605依赖项错误:
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:
<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>
而且它们似乎确实可以恢复正常:
该项目还引用了Microsoft.NETCore.App 2.0 SDK。
从CLI执行dotnet还原时,我还会收到以下错误,我不确定是否与以下错误有关:
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”的信息。
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警告:
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控制台应用程序存在类似问题。
该项目正在成功建立。但是,发布失败并出现几个NU1605错误。
该问题起源于log4net版本2.0.8。在.netstandard2.0项目中引用了它,它具有以下依赖关系:
它们导致引用log4net的项目中的软件包降级。在发布期间,这些警告被视为错误...
为了解决该问题,我通过Nuget添加了这些库的正确版本。
终于,出版成功了。
PS当我第一次使用最新版本的库添加软件包时,在依赖项列表上会显示一个黄色警告标志,好像这些软件包不适合该项目。卸载项目并重新加载后,警告标志消失了!(我正在使用Visual Studio 2019)
希望能帮助到你!
我刚遇到这个确切的问题。我正在发布一个针对.Net Core和.Net Standard的项目。我认为仅当我将.Net Standard添加为目标框架时,此问题才显现出来。添加这三个软件包可以解决该问题。
我在使用log4net时遇到了完全相同的问题。您如何更改特定的DLL依赖关系?我的.NetCore版本是3.1.0。
您可以在nuget中搜索dll并安装最新版本。
是的,.NET Core 3.1控制台应用程序中的log4net出现了完全相同的问题。我必须将这些软件包以及主要的可执行项目添加到我的类库中。
专门针对log4net,解决方案中添加的Microsoft.NETCore.Targets库也对其进行了修复。参见stackoverflow.com/questions/47712035/…