簡體   English   中英

修復 C# dotnetcore3.1 log4net 2.0.8:檢測到包降級錯誤

[英]Fixing C# dotnetcore3.1 log4net 2.0.8: Detected package downgrade error

我正在嘗試讓 log4net 在 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 的“魔法”來解決它。

根據此消息, Reference the package directly from the project to select a different version. ,我已經嘗試向我的 csproj 添加包引用,但是“System”、“System.Diagnostics”或“System.Diagnostics.Debug”都不起作用。

你是如何解決這個問題的?

請具體點。 我仍然是 C# 的新手,我發現的許多解決方案可能沒有用,因為他們只是說添加<SomeXmlTag />而我不知道把它放在哪里或在哪個父項下放置標簽。


每個 Gray Cat,我嘗試過: 將 bindingRedirect 添加到 .Net 標准庫

最初它似乎根本沒有改變輸出。 在玩弄冗長之后,我發現了這個:

   "/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]

奇妙的是,它應該包含詳細信息,但我在我正在查看的輸出頁面中找不到它們。

我們在嘗試構建一些 .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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM