发布 WPF .Net Core 3 应用程序和 Serilog.Sinks.File

Publishing WPF .Net Core 3 app and Serilog.Sinks.File

NuGet 包 Serilog.Sinks.File 发布时出错。

我正在尝试发布独立的 WPF .NET Core 3.0 应用程序。该应用程序构建,运行良好,发布良好,直到添加 Serilog.Sinks.File。一旦 Serilog.Sinks.File 添加到项目中,应用程序 builds/runs 甚至可以正确记录。但是,在尝试发布时出现此错误;

System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed. --- 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.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.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.d__205.MoveNext() ---> (Inner Exception #0) System.Exception: Publishing failed.<---

System.Exception: Publishing failed.

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

删除 Serilog.Sinks.File 应用程序发布。

即使删除 Serilog 初始化命令,也会出现同样的错误。

我发现解决方案证明 Serilog.Sinks.File 不是正确的 Nuget 包。您需要使用 Serilog.AspNetCore 然后应用程序才能发布。