0

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.

Pritam
  • 1,288
  • 5
  • 23
  • 40

1 Answers1

1

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.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • 1
    Thanks for the answer and one thing I would like to add is always use latest nuget version while restoring it. – Pritam Apr 21 '20 at 14:02