serilog-sinks-file icon indicating copy to clipboard operation
serilog-sinks-file copied to clipboard

System.Runtime 5.0.0.0 dependency after updating to last version

Open ruipaulomonteiro opened this issue 4 years ago • 4 comments
trafficstars

Hi,

I have a .net 4.8 project (Windows Service) that depends on a .net standard 2.0 project with classes for log management through serilog.

It was working fine with version 4.1.0 but after updating to version 5.0.0, I started to get the following error when the log initialization is triggered: "Could not load file or assembly System.Runtime, Version=5.0.0.0"

Apparently the dependency reference is correct, it seems to look for .net 5 runtime when running.

image

Any help would be appreciated. Thanks in advance.

ruipaulomonteiro avatar Jul 01 '21 22:07 ruipaulomonteiro

Thanks for the heads-up, that's rather strange!

The 5.0 netstandard2.0 version doesn't look to have any strange dependencies:

image

Just some ideas that might help narrow this down-

  • Is the .NET Standard project in the same solution, or are you consuming it as a library?
  • Is your project a new-style or old-style CSPROJ?
  • Have you tried completely cleaning and rebuilding?
  • Do you have .NET 5 installed at all? (Not sure how this would/should impact it .. but .. >???)
  • Do you know which MSBuild binary you're building with?
  • Does it work if you build using dotnet build instead of VS?

nblumhardt avatar Jul 02 '21 05:07 nblumhardt

Hi,

Thanks for the hints. Checked all and seems to be ok. When activating build verbose output, found this message which seems to be the cause. But didn't find out why the 5.0.0.0 version is required.

8> MSB3243: No way to resolve conflict between "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" arbitrarily. (TaskId:25) 8> References which depend on "System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. 8> C:\prjNet\CSU\ADD-ON\Master Data\Implementação\Output\Platform\Serilog.Sinks.File.dll 8> Project file item includes which caused reference "C:\prjNet\CSU\ADD-ON\Master Data\Implementação\Output\Platform*Serilog.Sinks.File.dll".*

The .net assembly (.net standard) where this package is used, is also shared with .net 5 projects, besides the .net 4.8 project is. But can't find out what is the problem, since it was working fine with previous version.

Still looking...

ruipaulomonteiro avatar Jul 04 '21 10:07 ruipaulomonteiro

Looking at #232, any chance adding the below to your CSPROJ fixes it?

<PackageReference Include="Microsoft.NETCore.Targets" Version="5.0.0" PrivateAssets="all" />

nblumhardt avatar Jul 05 '21 23:07 nblumhardt

Same issue here. Cannot update to 5.0.0.

juanmalm avatar May 20 '22 14:05 juanmalm

Hi, I'm spring cleaning the issues lsit. I feel this issue is just confusing, so ideally we'd shift it to either a) closed or b) a clear problem definition (ideally with a documented workaround)

I suspect there likely is a workaround given the lack of traffic on this issue atm

@juanmalm have you found a solution? @ruipaulomonteiro did you try Nicks's suggestion?

bartelink avatar Oct 19 '23 09:10 bartelink

@juanmalm have you found a solution?

Nope

juanmalm avatar Oct 19 '23 10:10 juanmalm

Could not explain why but I rebuilt all from scratch and started working. Thanks!

ruipaulomonteiro avatar Oct 19 '23 10:10 ruipaulomonteiro

Thanks @ruipaulomonteiro for circling back (and closing - hopefully the 11 remaining issues now correctly represent the actionable enhancements and/or investigations that this repo is the right place for...)

@juanmalm if you're still blocked, I'd suggest trying Nick's suggestion, and then creating a stack overflow question tagged serilog documenting:

  • what you tried (with relevant snippets of csproj files, build outputs etc)
  • the exact issue/message on which you are blocked and posting a link to it here.

bartelink avatar Oct 19 '23 10:10 bartelink