9
votes

I have an asp.net Core project and I'm trying to add a logger to it. I choose SeriLog which I used in other projects.

But when I'm trying to add the "Serilog.AspNetCore" package version 2.0.0 I'm getting"

Package restore failed. Rolling back package changes for 'BackEnd'.

My csproj contain the following settings:

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <DockerComposeProjectPath>..\..\docker-compose.dcproj</DockerComposeProjectPath>
   <AssemblyName>BackEnd</AssemblyName>
  <RootNamespace>BackEnd</RootNamespace>
</PropertyGroup>

Allready tried to clear all nuget cache, rebuilding, restart VS

Running on Win10, Visual Studio 2017 15.3.0

Is there a log that can give me more details why I'm getting this error? Any suggestions how to fix it?

*Update - the detailed build log (Thanks @Leo-MSFT for that):

...

Checking compatibility for System.Security.Cryptography.Csp 4.3.0 with .NETCoreApp,Version=v2.0.

Checking compatibility for runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.Apple 4.3.0 with .NETCoreApp,Version=v2.0.

All packages and projects are compatible with .NETCoreApp,Version=v2.0.

Detected package downgrade: Microsoft.Extensions.DependencyInjection from 2.0.0 to 1.1.1. Reference the package directly from the project to select a different version.

BackEnd (>= 1.0.0) -> Serilog.AspNetCore (>= 2.0.0) -> Microsoft.Extensions.DependencyInjection (>= 2.0.0)

BackEnd (>= 1.0.0) -> Microsoft.Extensions.DependencyInjection (>= 1.1.1)

Package restore failed. Rolling back package changes for 'BackEnd'.

Time Elapsed: 00:00:01.4928161

========== Finished ==========

Yep it seems that it's related to "Microsoft.Extensions.DependencyInjection"

1
try manually add <PackageReference Include="Serilog.AspNetCore" Version="2.0.0"/> into your .csproj and then do dotnet restoreSet
What is the detailed installation log on the output window? You can change the MSBuild output verbosity to Detailed or Diagnostic, Tools->Options->Build and Run->MSBuild project build output verbosity.Leo Liu-MSFT
I tried it also, but I'm getting: "Restoring NuGet packages... NuGet package restore failed."Aviram Fireberger
@Leo-MSFT thanks for the input, I added the build log.. seems that it's related to "Microsoft.Extensions.DependencyInjection" mismatch versionAviram Fireberger

1 Answers

4
votes

Solved by updating all my existence Nuget packages to the latest version available. Including those 5 packages:

<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />

The problem was the version of "Microsoft.Extensions.DependencyInjection" but I update all of them.