Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

After upgrading a test project from .NET Core 2.0 to 2.1 I started getting the following error on build:

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:

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.*" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.*" />

to your test project depending on a package you use in your API project.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.