[英]Error NU1107 Version conflict detected for Microsoft.CodeAnalysis.Common
After upgrading a test project from .NET Core 2.0 to 2.1 I started getting the following error on build: 将测试项目从.NET Core 2.0升级到2.1之后,我开始在构建过程中遇到以下错误:
Error Package restore failed. Rolling back package changes for 'Api.Tests'.
Error NU1107 Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 2.8.2 directly to project Api.Tests to resolve this issue.
Api.Tests -> Api -> Microsoft.CodeAnalysis.Common (>= 2.8.2)
Api.Tests -> Microsoft.AspNetCore.Mvc 2.0.3 -> Microsoft.AspNetCore.Mvc.Localization 2.0.3 -> Microsoft.AspNetCore.Mvc.Razor 2.0.3 -> Microsoft.CodeAnalysis.CSharp 2.3.1 -> Microsoft.CodeAnalysis.Common (= 2.3.1). Api.Tests
Error NU1107 Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 2.8.2 directly to project Api.Tests to resolve this issue.
Api.Tests -> Api -> Microsoft.CodeAnalysis.Common (>= 2.8.2)
Api.Tests -> Microsoft.AspNetCore.Mvc 2.2.0-preview3-35497 -> Microsoft.AspNetCore.Mvc.Localization 2.2.0-preview3-35497 -> Microsoft.AspNetCore.Mvc.Razor 2.2.0-preview3-35497 -> Microsoft.CodeAnalysis.CSharp 2.8.0 -> Microsoft.CodeAnalysis.Common (= 2.8.0). Api.Tests
I tried installing Microsoft.CodeAnalysis.Common 2.8.2 directly in the project but it gave the following error: 我尝试直接在项目中安装Microsoft.CodeAnalysis.Common 2.8.2,但出现以下错误:
Restoring packages for Api.Tests.csproj...
NU1608: Detected package version outside of dependency constraint: Microsoft.CodeAnalysis.CSharp 2.3.1 requires Microsoft.CodeAnalysis.Common (= 2.3.1) but version Microsoft.CodeAnalysis.Common 2.8.2 was resolved.
NU1608: Detected package version outside of dependency constraint: Microsoft.CodeAnalysis.Workspaces.Common 2.3.1 requires Microsoft.CodeAnalysis.Common (= 2.3.1) but version Microsoft.CodeAnalysis.Common 2.8.2 was resolved.
Install-Package : NU1605: Detected package downgrade: Microsoft.AspNetCore.Mvc from 2.2.0-preview3-35497 to 2.0.3. Reference the package directly from the project to select a different version.
Api.Tests -> Services -> CommStack.Conference.Web.Api.Client 1.0.0-CI-20181128-112729 -> CommStack.Web.Api.Client.Common 1.0.0-CI-20181128-112729 -> Microsoft.AspNetCore.Mvc (>= 2.2.0-preview3-35497)
Api.Tests -> Microsoft.AspNetCore.Mvc (>= 2.0.3)
At line:1 char:1
+ Install-Package Microsoft.CodeAnalysis.Common -Version 2.8.2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for 'Api.Tests'.
At line:1 char:1
+ Install-Package Microsoft.CodeAnalysis.Common -Version 2.8.2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Any suggestions on how to fix this? 对于如何解决这个问题,有任何的建议吗?
To solve this issue you have to explicitly install either 要解决此问题,您必须显式安装
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
or 要么
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.*" />
to your test project depending on a package you use in your API project. 测试项目,具体取决于您在API项目中使用的软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.