2
votes

I have an asp.net web api project that targets .net Core 3.1. It builds on DevOps Server 2019 just fine.

I added a project to run XUnit tests. This project also targets .net Core 3.1. The solution (containing both projects) builds on my desktop just fine, but when I try and build it on the server I get errors like the following:

[error]CSC(0,0):

Error CS1705: Assembly 'myteam API' with identity 'myteam API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.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

2

2 Answers

4
votes

I had a similar issue and it ended up due to a nuget package (e.g. NSWag.AspNetCore) referencing an older version of Microsoft.ASpNetCore.Mvc.Core (1.0.3).

The latter is not a Nuget package and you can't simply add it to your project to resolve the mismatch.

More specifically, in my scenario, the issue was not with the Asp.Net Core csproj itself, but rather another project (in our case, unit test project) that had a reference to the Asp.Net Core project. As such, update the latter csproj to use:

<Project Sdk="Microsoft.NET.Sdk.Web">

instead of

<Project Sdk="Microsoft.NET.Sdk">

In doing so, the project will have access to the correct Asp.Net.Core dependencies, as per its TargetFramework.

0
votes

I solved this problem by using the DotNetCoreCLI@2 task in my build pipeline instead of the VSBuild@1 task.