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

标签 c# wpf serilog .net-core-3.0

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

我正在尝试发布一个独立的 WPF .NET Core 3.0 应用程序。在添加 Serilog.Sinks.File 之前,应用程序构建、运行良好并发布良好。一旦将 Serilog.Sinks.File 添加到项目中,应用程序就会正确构建/运行甚至记录。但是,在尝试发布时给出此错误;

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 然后应用程序才能发布。

关于c# - 发布 WPF .Net Core 3 应用程序和 Serilog.Sinks.File,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57775965/

相关文章:

c# - Xamarin.Form 的 LayoutOptions,尤其是 Fill 和 Expand 之间有什么区别?

c# - 想在WP7的外部浏览器中打开链接

c# - 如何使用 MVVM 更新 Datagrid?

c# - 如何使用某些脚本为 wpf 4.5 应用程序创建安装包

serilog - 是否可以将 Serilog 配置为截断(即清空)每个新进程的日志文件?

c# - 为什么 double 精度在 C 和 C# 之间不同?

c# - 为什么 IIS 8.0 Express 在 Visual Studio 2012 中重命名后使用旧项目名称

wpf - WPF 中选定的文本颜色

logging - 如何将 Serilog 与 Amazon OpenSearch 结合使用?

c# - 单元测试自定义 Serilog 接收器