Core: Fail to build a .Net Core 2.2 project with Azure DevOps with on-premises agent

Created on 20 Dec 2018  路  4Comments  路  Source: dotnet/core

We are using the Azure DevOps to host and build our code. We are starting to build new services on .Net Core and since 2.2 is out, decided to go that route. But after installing .Net Core SDK 2.2.101 on the build agent (on premises), creating a vanilla asp.net core empty project (New Project -> pushed to git, absolutely no changes), it looks like it wants to compile it against the 2.1, even though the TargetFramework is netcoreapp2.2.

For building we are using the Visual Studio Build task. Using dotnet build is not an option as we'll need multiple targets for some of the common components we are sharing between .net framework and .net core projects we have.

2018-12-19T15:41:51.1962553Z ##[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.aspnetcore.app\2.1.0\build\netcoreapp2.1\Microsoft.AspNetCore.App.targets(14,5): Error : This version of Microsoft.AspNetCore.App is only compatible with the netcoreapp2.1 target framework. Please target netcoreapp2.1 or choose a version of Microsoft.AspNetCore.App compatible with netcoreapp2.2.

The .net core installed on the agent (output from dotnet --list-sdks):

2018-12-19T15:29:54.1887058Z 2.1.201 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1887424Z 2.1.202 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1887788Z 2.1.400 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1887954Z 2.1.402 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1888059Z 2.1.403 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1888137Z 2.1.500 [C:\Program Files\dotnet\sdk]
2018-12-19T15:29:54.1888211Z 2.2.101 [C:\Program Files\dotnet\sdk]

Same behavior can be observed on the Hosted VS2017 agent, but you need to install the .Net Core SDK 2.2.101 first using the .NET Core SDK Installer task.

Setting the version for Microsoft.AspNetCore.App explicitly in the csproj file resolves the exception, but does not solve the problem, as stranger errors pop up down the line.

Could not reproduce the problem on a developer machine. Might be related to the version of the Visual Studio installed.

Most helpful comment

UPDATE: for the benefit of anyone having the same issues

found the problem, it was due to the NuGet restore task using the 4.3 version (because I cloned the build definition from another project, doh..). Updated to latest and it worked OK.

All 4 comments

p.s. added here as seems like a .Net Core issue, rather than a Azure DevOps but I might be wrong...

It seems that something in your Azure DevOps setting (or in the platform itself) decided to use wrong MS.AspNetCore.App package. If it compiles locally, I would dig into the differences of used SDKs and other tools. Contacting Azure DevOps support may be one of the ways to narrow it down.
This may be also helpful: https://www.hanselman.com/blog/AzureDevOpsContinuousBuildDeployTestWithASPNETCore22PreviewInOneHour.aspx

If you find evidence this is a problem in .NET Core itself (SDK or runtime), please let us know and we can reopen.
Closing as this is likely problem in Azure DevOps.

UPDATE: for the benefit of anyone having the same issues

found the problem, it was due to the NuGet restore task using the 4.3 version (because I cloned the build definition from another project, doh..). Updated to latest and it worked OK.

we are using NuGet restore 4.8.1 still the same.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rand-Random picture Rand-Random  路  4Comments

AxxlForce picture AxxlForce  路  3Comments

wq807319473 picture wq807319473  路  3Comments

mmacneil picture mmacneil  路  3Comments

rykr picture rykr  路  3Comments