修复C#dotnetcore3.1 log4net 2.0.8:检测到的程序包降级错误

问题描述 投票:1回答:1

我正在尝试使dot4net在dotnetcore3.1项目下工作。我不断收到这样的错误的垃圾邮件:

error 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.  [/app/MyProject.csproj]

csproj归结为:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <OutputType>exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="log4net" Version="2.0.8" />
  </ItemGroup>
</Project>

环境:

  • dotnetcore3.1
  • docker构建映像:mcr.microsoft.com/dotnet/core/sdk:3.1
  • docker运行时映像:mcr.microsoft.com/dotnet/core/runtime:3.1-bionic

不可接受的“修复”:

  • “只需添加<WarningsAsErrors></WarningsAsErrors>
  • 涉及打开Visual Studio的所有内容

[针对此问题有好几篇文章,但是它们似乎抑制了错误并继续前进,或者他们使用Visual Studio“ magic”解决了该问题。

基于此消息,Reference the package directly from the project to select a different version.,我尝试将程序包引用添加到我的csproj中,但是“ System”,“ System.Diagnostics”或“ System.Diagnostics.Debug”都不起作用。

您实际上如何解决此问题?

请具体说明。我仍然对C#还是陌生的,我发现的许多解决方案可能都行不通,因为它们只是说加<SomeXmlTag />而我不知道将它放在哪里或放在哪个父标签下。


[每只灰猫,我尝试过:Adding a bindingRedirect to a .Net Standard library

最初似乎根本没有改变输出。在玩了冗长之后,我发现了这一点:

   "/app/MyProject.csproj" (Publish target) (1) ->
   (ResolveAssemblyReferences target) -> 
/usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Configuration.ConfigurationManager" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
     /usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.AccessControl" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
     /usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.Permissions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]
     /usr/share/dotnet/sdk/3.1.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "System.Security.Principal.Windows" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed. [/app/MyProject.csproj]

很好,它应该包括详细信息,但我无法在正在查看的输出页面中找到它们。

c# linux .net-core nuget log4net
1个回答
0
投票

我们在尝试构建某些.NET Core 3.1服务时遇到了类似的问题。降级消息是相同的,尽管对于不同的库(尽管它们全部来自System。*名称空间)

我设法通过将以下行添加到.csproj文件来解决此问题

<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" PrivateAssets="all" />

该解决方案由Microsoft提出,并在此处记录:https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605(示例2)

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.