2
votes

I have ASP.NET Api app with Microsoft.AspNetCore.App version 2.1.1 and xUnit Test with Microsoft.NETCore.App version 2.1.0

I have added xUnit Test application which has reference from Api project. Because of version difference (2.1.1 and 2.1.0) solution gives error while building.

Error:

Error CS1705
Assembly 'Customer.API' with identity 'Customer.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Mvc.Core' with identity 'Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Question is: how can I upgrade Microsoft.AspNetCore.App in my test project.

PS: from Nuget Manager it is not possible to change version or update (in test project)

2

2 Answers

4
votes

Right click on Solution. Go NuGet Packages for Solution Click Microsoft.AspNetCore.App then at right panel click checkbox for xUnit Test Project then change version to 2.1.1 and install.

Build again.

Solved in my case

1
votes

The accepted answer will address the issue. Just to add more background on what is really causing this issue:

This issue is because of the Implicit Versioning that was introduced for Microsoft.AspNetCore.App metapackage. With implicit versioning the sdk decides the version & it resolved it as 2.1.1

However, it was resolving to version 2.1 for the nunit test project. Specifying the version number for the nunit project like and performing dotnet restore helped resolve this issue.

There is a ticket for this issue in github and this behavior around implicit versioning could change in future - https://github.com/aspnet/AspNetCore.Docs/issues/6430 & https://github.com/dotnet/core/blob/master/release-notes/1.0/sdk/1.0-rc3-implicit-package-refs.md