serilog-aspnetcore
serilog-aspnetcore copied to clipboard
Self contained single executable publishing fails.
Description Whenever I try to publish a single executable from from Visual studio exception is being thrown.
Reproduction create any empty asp.net core minimal API project ant reference this package, try to publish as self contained, a single executable
Expected behavior Publishing succeeds.
Relevant package, tooling and runtime versions Visual Studio 2022 (v17.0.5) Net 6.0 LTS
Additional context
Please click that arrow and show appeared message.
Please use the following setup
<ItemGroup>
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>
What is your TFM in csproj?
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Looking at your error output I think that this is caused by runtime.win.System.IO.FileSystem. 4.3.0
that is located deeper in the dependencies tree and has newer version of dependencies located upper. Try build with runtime identifier pointing to linux. Weird error.
sorry but that's not an option for me for now I will have to step away from this package and find an alternative way. if someone fixes this in the future would be nice if not u can close this but this is a real issue and only happens with the information given in this issue.
Then just do what compiler says - add newer dependencies explicitly.
Or even simpler - suppress NU1605 warning/error https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605
It seems that you force TreatWarningsAsErrors
for your project. NU1605 is warning. You may find WarningsNotAsErrors
option rather usefull.
@sungam3r, actually that is what I am going to give a try and to a full regression testing I will treat NU1605 as warning not error and see how it goes.
Looks similar to this issue.
@rati-openkey try to install latest Serilog.Settings.Configuration
version and see if it helps
@skomis-mm thank you I will give it a try for sure and will report back.
Aiming to fix this with #287
@rati-openkey You can add this to your .proj file and then publish should work. This has been issue for very long time.
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Collections" Version="4.3.0" />
Version 5.0.0-dev-00259 of Serilog.AspNetCore should also fix this.
If anyone has a chance to test it and confirm - we can push this out as a stable release.
Thanks!
Oh I didnt have the pre-release packages checked in, so I didnt see it. I have updated the package and now it publish without errors.
Excellent, thanks @FeeSaver 👍
Not able to run a full regression for sure but the publishing seems to be working.