serilog-aspnetcore icon indicating copy to clipboard operation
serilog-aspnetcore copied to clipboard

Self contained single executable publishing fails.

Open rati-openkey opened this issue 2 years ago • 17 comments

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

rati-openkey avatar Jan 29 '22 18:01 rati-openkey

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

sungam3r avatar Jan 30 '22 00:01 sungam3r

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>

rati-openkey avatar Jan 30 '22 08:01 rati-openkey

What is your TFM in csproj?

sungam3r avatar Jan 30 '22 16:01 sungam3r

<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

rati-openkey avatar Jan 30 '22 16:01 rati-openkey

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.

sungam3r avatar Jan 30 '22 20:01 sungam3r

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.

rati-openkey avatar Jan 30 '22 20:01 rati-openkey

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

sungam3r avatar Jan 30 '22 20:01 sungam3r

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 avatar Jan 30 '22 20:01 sungam3r

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

rati-openkey avatar Jan 30 '22 20:01 rati-openkey

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

skomis-mm avatar Feb 04 '22 12:02 skomis-mm

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

rati-openkey avatar Feb 04 '22 16:02 rati-openkey

Aiming to fix this with #287

nblumhardt avatar Feb 06 '22 22:02 nblumhardt

@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" />

FeeSaver avatar Feb 08 '22 22:02 FeeSaver

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!

nblumhardt avatar Feb 08 '22 22:02 nblumhardt

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.

FeeSaver avatar Feb 08 '22 22:02 FeeSaver

Excellent, thanks @FeeSaver 👍

nblumhardt avatar Feb 08 '22 23:02 nblumhardt

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

rati-openkey avatar Feb 09 '22 19:02 rati-openkey