NuGet package Serilog.Sinks.File gives an error when publishing.
I am trying to publish a self-contained WPF .NET Core 3.0 app. The app builds, runs fine publishes fine until Serilog.Sinks.File is added. Once Serilog.Sinks.File is added to the project, the app builds/runs and even logs correctly. However, when trying to publish this error is given;
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.
===================
Remove Serilog.Sinks.File and the app publishes.
Even removing the Serilog initialize command and the same error occurs.
AggregateException
to see if it gives any clue? – C. Augusto ProieteappSettings.json
orapp.config
? If you are, it's possible the build process is failing to detect the dependency to the File sink... It's worth a quick test... Just put thisConsole.WriteLine(typeof(Serilog.FileLoggerConfigurationExtensions));
somewhere in the startup of your app, to create a static dependency to the File Sink assembly, and see if that helps. – C. Augusto Proiete