【问题标题】:.net core 3.1 won't publish to linux if I reference Log4Net nuget package如果我引用 Log4Net nuget 包,.net core 3.1 将不会发布到 linux
【发布时间】:2020-03-09 15:31:35
【问题描述】:

我有一个简单的工作者应用程序(使用工作者服务模板),它只是帮助我将 .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>

感谢您的帮助

【问题讨论】:

  • 您能否在您的csproj 文件中显示相关部分? (log4net等版本)
  • 当然..将其添加到原始问题中。谢谢
  • 更新这显然发生在我针对除“便携式”之外的任何运行时

标签: .net-core log4net


【解决方案1】:

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

dotnet build -r linux-x64 

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    相关资源
    最近更新 更多