简体   繁体   English

'Serilog'已经为'Microsoft.CSharp'定义了一个依赖项

[英]'Serilog' already has a dependency defined for 'Microsoft.CSharp'

I am trying to install serilog and I'm getting error 我试图安装serilog,我收到错误

PM> Install-Package Serilog PM> Install-Package Serilog
Install-Package : 'Serilog' already has a 安装包:'Serilog'已经有了
dependency defined for 'Microsoft.CSharp'. 为“Microsoft.CSharp”定义的依赖项。 At line:1 char:1 在行:1个字符:1
+ Install-Package Serilog + Install-Package Serilog
+ ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException + CategoryInfo:NotSpecified:(:) [Install-Package],InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand + FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Microsoft.CSharp is already referenced in my project Microsoft.CSharp已在我的项目中引用

As @ Tieson T. said, Update "Nuget Package Manager for Visual Studio" from Visual Studio Window > Tools > Extensions and Updates > Click Updates tab. 正如@ Tieson T.所说,从Visual Studio窗口>工具>扩展和更新>单击更新选项卡更新“Visual Studio的Nuget包管理器”。 Select Nuget plugin and update. 选择Nuget插件并更新。 Then restart the visual studio after installation complete. 然后在安装完成后重新启动visual studio。 I tried (Windows 8.1 64bit & Visual Studio 2013 Ultimate) and it works. 我试过(Windows 8.1 64bit和Visual Studio 2013 Ultimate)并且它可以工作。

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). 我有一个类似的问题,但问题是由于我们的构建服务器基于TFS 2012并使用旧版本的MSBuild(我们无法在近期更新)。 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). 我找到的解决方法是进入解决方案的packages文件夹,找到有问题的包(在我的情况下是Serilog.2.3.0和我安装的相关Sink包)。 Open the "lib" folder and you should see some folders associated to the various .Net frameworks. 打开“lib”文件夹,您应该看到一些与各种.Net框架相关联的文件夹。 Delete the netstandard folders which correspond to the .Net Core versions. 删除与.Net Core版本对应的netstandard文件夹。

The downside to this is you have to check in the folders you modify like this so MSBuild doesn't try to restore them. 这样做的缺点是你必须检查你修改的文件夹,这样MSBuild不会尝试恢复它们。

Please do the 2 steps below, it works for me or teamcity/jenkins 请执行以下两个步骤,它适用于我或teamcity / jenkins

  1. If you still using the Nuget CommandLine 2.8, please try to upgrade to 3.5. 如果您仍在使用Nuget CommandLine 2.8,请尝试升级到3.5。
  2. If you using the private Nuget Server, Please update the Serilog.2.3.0.nupkg with the steps below: 如果您使用私人Nuget服务器,请使用以下步骤更新Serilog.2.3.0.nupkg:

    2.1 Update Nuget Spec File: Remove ... ... 2.1更新Nuget Spec文件:删除......

    2.2 Remove the folder lib/netstandard1.0 and lib/netstandard1.0 2.2删除文件夹lib / netstandard1.0和lib / netstandard1.0

    2.3 Then redeploy the Serilog.2.3.0.nupkg to your private Nuget Server 2.3然后将Serilog.2.3.0.nupkg重新部署到您的私有Nuget服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM