serilog / serilog-aspnetcore

Serilog integration for ASP.NET Core
Apache License 2.0
1.3k stars 205 forks source link

Self contained single executable publishing fails. #285

Open rati-openkey opened 2 years ago

rati-openkey commented 2 years ago

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 image

sungam3r commented 2 years ago

изображение Please click that arrow and show appeared message.

rati-openkey commented 2 years ago

image 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>
sungam3r commented 2 years ago

What is your TFM in csproj?

rati-openkey commented 2 years ago
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
sungam3r commented 2 years ago

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.

rati-openkey commented 2 years ago

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.

sungam3r commented 2 years ago

Then just do what compiler says - add newer dependencies explicitly.

sungam3r commented 2 years ago

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.

rati-openkey commented 2 years ago

@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.

skomis-mm commented 2 years ago

Looks similar to this issue. @rati-openkey try to install latest Serilog.Settings.Configuration version and see if it helps

rati-openkey commented 2 years ago

@skomis-mm thank you I will give it a try for sure and will report back.

nblumhardt commented 2 years ago

Aiming to fix this with #287

FeeSaver commented 2 years ago

@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" />
nblumhardt commented 2 years ago

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!

FeeSaver commented 2 years ago

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.

nblumhardt commented 2 years ago

Excellent, thanks @FeeSaver 👍

rati-openkey commented 2 years ago

Not able to run a full regression for sure but the publishing seems to be working.