Pritam
Pritam

Reputation: 1400

.net core unit test project failing to build in Azure Devops pipeline

In my solution I have project targetting .netstandard 2.0, as we cannot have test case project targeting the same platform, I am using .netcore 3.1 unit test project, even after I updated the build pipeline to use .net 3.1, I am facing below issue at restore nuget step in build pipeline.

##[error]The nuget command failed with exit code(1) and error(C:\Program Files (x86)\Microsoft Visual Studio\2017\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(112,5): error : The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [D:\a\1\s\src\SampleProject\test\UnitTest\UnitTest.csproj])
##[error]Packages failed to restore

Note : https://www.hanselman.com/blog/AzureDevOpsContinuousBuildDeployTestWithASPNETCore22PreviewInOneHour.aspx is the link I followed to troubleshoot this issue but still facing the same error.

Upvotes: 1

Views: 1582

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30353

I can see from the error that you were running the pipeline on agent vs2017-win2016. In agent vs2017-win2016 the older version msbuild in vs2017 is invoked while executing nuget restore command.

I have encountered a simmilar issue, and it seems that the older version msbuild cannot find the installed .NET Core 3.1 correctly.

Please have a try using agent windows-2019 (windows-latest) to run your pipeline. And use task Use .NET Core to install .NET Core 3.1.

Upvotes: 1

Related Questions