Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Serilog' already has a dependency defined for 'Microsoft.CSharp'

I am trying to install serilog and I'm getting error

PM> Install-Package Serilog
Install-Package : 'Serilog' already has a
dependency defined for 'Microsoft.CSharp'. At line:1 char:1
+ Install-Package Serilog
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Microsoft.CSharp is already referenced in my project

like image 418
LP13 Avatar asked Aug 01 '16 18:08

LP13


2 Answers

To add to this. I had a similar issue but the problem was due to our build server being based on TFS 2012 and using an old version of MSBuild (which we can't update in the near term). Everything built and ran fine locally, but when the build server tried to run we got the same error.

The workaround I found was to go into the packages folder of the solution, find the package having the issue (in my case Serilog.2.3.0 and the associated Sink packages I had installed). Open the "lib" folder and you should see some folders associated to the various .Net frameworks. Delete the netstandard folders which correspond to the .Net Core versions.

The downside to this is you have to check in the folders you modify like this so MSBuild doesn't try to restore them.

like image 160
Harrison Avatar answered Oct 17 '22 09:10

Harrison


As @Tieson T. said, Update "Nuget Package Manager for Visual Studio" from Visual Studio Window > Tools > Extensions and Updates > Click Updates tab. Select Nuget plugin and update. Then restart the visual studio after installation complete. I tried (Windows 8.1 64bit & Visual Studio 2013 Ultimate) and it works.

like image 29
Lost_In_Library Avatar answered Oct 17 '22 09:10

Lost_In_Library