serilog-aspnetcore
serilog-aspnetcore copied to clipboard
Updating Serilog.AspNetCore package to 4.0, application cannot load Serilog.Sinks.Debug
Description When updating the Serilog.AspNetCore Nuget package in a .Net 5.0 Windows Service from 3.4.0 to 4.0.0 and publishing the service in Release mode, the service fails to start because it cannot load Serilog.Sinks.Debug. The service is published with PublishSingleFile=True.
- Explicitly adding the Serilog.Sinks.Debug 2.0.0 Nuget package to the project and publishing the application did not resolve this issue.
- Reverting the Serilog.AspNetCore package to 3.4.0 resolved the issue as a temporary workaround, but we like to keep our Nuget packages up to date.
Relevant package, tooling and runtime versions
- Serilog.AspNetCore 3.4.0, 4.0.0
- Serilog.Sinks.Debug 2.0.0
- Windows Server
- Visual Studio 2019 16.8.6, 16.9.1
- dotnet 5.0.103
Thanks for the heads-up, sounds like this will need some investigation.
IIRC there's some conditional compilation around System.Diagnostics.Debug
that might be either broken in the 2.0.0 version of Serilog.Sinks.Debug, or, the trimming mechanism in single file publishing may be involved.
I'm flat out for a few days, so if anyone following along has a chance to dig in and investigate that would be very welcome :-)
Does Serilog.AspNetCore 3.4.0 together with Serilog.Sinks.Debug 2.0.0 (as opposed to version 1.0.1 of the debug sink that the aspnetcore package uses by default) work?
(I gave it a quick go on an ASP.Net Core project at work and fell over https://github.com/serilog/serilog-settings-configuration/issues/239, which isn't ideal itself!)