Skip to content

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

Closed

Description

@kofifus

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 ?

Activity

  1. nblumhardt commented on Jun 7, 2019

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

  2. alexrp commented on Jan 22, 2020

    @alexrp

    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.

  3. nblumhardt commented on Jan 24, 2020

    @nblumhardt
    Member

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

  4. changed the title [-]cannot add Serilog.Sinks.File[/-] [+]Cannot add Serilog.Sinks.File to .NET Core 3.x[/+] on Jan 24, 2020
  5. philpowers commented on Feb 18, 2020

    @philpowers

    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.

  6. Mgamerz commented on Jul 19, 2020

    @Mgamerz

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions