Skip to content

Cannot add Serilog.Sinks.File to .NET Core 3.x #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kofifus opened this issue Jun 6, 2019 · 5 comments · Fixed by #130
Closed

Cannot add Serilog.Sinks.File to .NET Core 3.x #104

kofifus opened this issue Jun 6, 2019 · 5 comments · Fixed by #130

Comments

@kofifus
Copy link

kofifus commented Jun 6, 2019

Using latest .NET Core v3.0.0-preview5

My proj has:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="3.0.0-preview5-19227-01" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview5-19227-01" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0-preview5.19227.1" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
    <PackageReference Include="Serilog" Version="2.9.0-dev-01091" />
    <PackageReference Include="Serilog.Extensions.Hosting" Version="2.0.1-dev-00009" />
  </ItemGroup>

I then try to install package Serilog.Sinks.File

I get:

Severity	Code	Description	Project	File	Line	Suppression State
Error	NU1605	Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version. 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.IO.FileSystem.Primitives (>= 4.3.0) 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.IO.FileSystem 4.0.1 -> System.IO.FileSystem.Primitives (>= 4.0.1)	DashboardServer	C:\src\epax\Dashboard\DashboardServer\DashboardServer.csproj	1	
Error	NU1605	Detected package downgrade: System.Text.Encoding.Extensions from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version. 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Text.Encoding.Extensions (>= 4.3.0) 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.Text.Encoding.Extensions (>= 4.0.11)	DashboardServer	C:\src\epax\Dashboard\DashboardServer\DashboardServer.csproj	1	
Error	NU1605	Detected package downgrade: System.Runtime.Handles from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version. 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.IO.FileSystem 4.0.1 -> runtime.win.System.IO.FileSystem 4.3.0 -> System.Runtime.Handles (>= 4.3.0) 
 DashboardServer -> Serilog.Sinks.File 4.1.0-dev-00838 -> System.IO.FileSystem 4.0.1 -> System.Runtime.Handles (>= 4.0.1)	DashboardServer	C:\src\epax\Dashboard\DashboardServer\DashboardServer.csproj	1	
Error	CS1061	'LoggerSinkConfiguration' does not contain a definition for 'File' and no accessible extension method 'File' accepting a first argument of type 'LoggerSinkConfiguration' could be found (are you missing a using directive or an assembly reference?)	DashboardServer	C:\src\epax\Dashboard\DashboardServer\Program.cs	55	Active
Error	CS1061	'DbContextOptionsBuilder' does not contain a definition for 'UseSqlite' and no accessible extension method 'UseSqlite' accepting a first argument of type 'DbContextOptionsBuilder' could be found (are you missing a using directive or an assembly reference?)	DashboardServer	C:\src\epax\Dashboard\DashboardServer\Startup.cs	37	Active
Warning	MVC1005	Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing. To continue using 'UseMvc', please set 'MvcOptions.EnableEndpointRounting = false' inside 'ConfigureServices'.	DashboardServer	C:\src\epax\Dashboard\DashboardServer\Startup.cs	106	Active
Error		Package restore failed. Rolling back package changes for 'DashboardServer'.				

How do I solve this ?

@nblumhardt nblumhardt transferred this issue from serilog/serilog-aspnetcore Jun 7, 2019
@nblumhardt
Copy link
Member

Hi! You can add:

    <PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />

to your CSPROJ.

I think we may need to update the dependency versions in this package to avoid this annoyance once 3.0 is out.

https://github.com/serilog/serilog-sinks-file/blob/dev/src/Serilog.Sinks.File/Serilog.Sinks.File.csproj#L58

@alexrp
Copy link

alexrp commented Jan 22, 2020

I just ran into this in a netcoreapp3.1 project. I had to add the following:

    <PackageReference Include="System.IO.FileSystem.Primitives">
      <Version>4.3.0</Version>
    </PackageReference>
    <PackageReference Include="System.Text.Encoding.Extensions">
      <Version>4.3.0</Version>
    </PackageReference>

Can anything be done to not require these? Serilog.Sinks.File is the only package in this fairly large project for which I've had to do this.

@nblumhardt nblumhardt reopened this Jan 24, 2020
@nblumhardt
Copy link
Member

Thanks for the nudge, @alexrp - reopening so that someone might be able to PR an update for this 👍

@nblumhardt nblumhardt changed the title cannot add Serilog.Sinks.File Cannot add Serilog.Sinks.File to .NET Core 3.x Jan 24, 2020
@philpowers
Copy link

philpowers commented Feb 18, 2020

The PackageReference workaround didn't work for me for some reason. In my case, I'm trying to bundle a .NET Core 3.1 WPF application into a Desktop Bridge project.

For now I've had to simply remove the reference to Serilog.Sinks.File, which of course is not ideal. I see there is a fix pending, so I'm hoping that I'll be able to re-add it soon.

@Mgamerz
Copy link

Mgamerz commented Jul 19, 2020

Any chance the production version of this will be fixed anytime soon? I can build for windows platforms on .net core 3.1 but when I build for linux-x64 I get the downgrade messages as posted above.

PS C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole> dotnet restore -r linux-x64
  Determining projects to restore...
  Restored C:\Users\Mgamerz\source\repos\AlotAddOnGUI\gui.cs\Terminal.Gui\Terminal.Gui.csproj (in 299 ms).
  Restored C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerCore\ALOTInstallerCore.csproj (in 298 ms).
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.IO from 4.3.0 to 4.1.0. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.IO (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> System.IO (>= 4.1.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.IO.FileSystem.Primitives from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.IO.FileSystem.Primitives (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> System.IO.FileSystem.Primitives (>= 4.0.1)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.Runtime.Handles from 4.3.0 to 4.0.1. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.Runtime.Handles (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> System.Runtime.Handles (>= 4.0.1)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.Text.Encoding from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.Text.Encoding (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> System.Text.Encoding (>= 4.0.11)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.Text.Encoding.Extensions from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.Text.Encoding.Extensions (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.Text.Encoding.Extensions (>= 4.0.11)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605: Detected package downgrade: System.Threading.Tasks from 4.3.0 to 4.0.11. Reference the package directly from the project to select a different version.
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> runtime.unix.System.IO.FileSystem 4.3.0 -> System.Threading.Tasks (>= 4.3.0)
C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj : error NU1605:  ALOTInstallerConsole -> Serilog.Sinks.File 4.1.0 -> System.IO.FileSystem 4.0.1 -> System.Threading.Tasks (>= 4.0.11)
  Failed to restore C:\Users\Mgamerz\source\repos\AlotAddOnGUI\ALOTInstallerConsole\ALOTInstallerConsole.csproj (in 439 ms).

I also tried using the prerelease nuget package, but it didn't fix it either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants