首页 > 解决方案 > 如果我引用 Log4Net nuget 包,.net core 3.1 将不会发布到 linux

问题描述

我有一个简单的工作应用程序(使用工作人员服务模板),它只是一个帮助我移动 .net 核心项目以在 linux 上运行的测试。我的问题是,当我引用 log4Net 的 nuget 包时,我在尝试发布时遇到错误。

目标位置:本地 HD 上的文件配置:发布目标框架:netcoreapp3.1 目标运行时:linux-x64

"Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. "

检查临时目录中的日志显示

"3/9/2020 11:09:39 AM
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.<IsBuildCompletedSuccessfully>b__2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<DefaultCorePublishStep>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__213.MoveNext()
---> (Inner Exception #0) System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---

System.Exception: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 

===================


<Project Sdk="Microsoft.NET.Sdk.Worker">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UserSecretsId>dotnet-UnbuntuWorker-7195FC82-40A3-4F0A-A32C-29EA1B03EA6E</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="log4net" Version="2.0.8" />
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" />
  </ItemGroup>

  <ItemGroup>
    <Content Update="log4net.config">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <Folder Include="LogConfig\" />
  </ItemGroup>
</Project>

谢谢你的帮助

标签: .net-corelog4net

解决方案


以防其他人遇到此问题。我通过添加一堆 Nuget 包解决了这个问题。我通过针对 linux 的 VS 开发人员命令提示符运行构建来找出哪些包

dotnet build -r linux-x64 

这给了我一堆关于 System.xxx.xxx 是错误版本的错误,所以我不得不在 nuget 上找到它们以获得最新版本。

奇怪的是,有时我会添加一个版本,但仍然会收到错误,然后旧版本会出现在依赖项中。通常删除它并重新添加它会解决它。

一旦所有问题都解决了,它就会最终发布。


推荐阅读