1

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.

4
  • 1
    The current .NET SDK does not support targeting .NET Core 3.1 message tells you, that you should update the SDK on your build agent Commented Apr 21, 2020 at 8:02
  • @PavelAnikhouski Agree! Any link mentioning the steps for same? Commented Apr 21, 2020 at 8:10
  • I'm on windows-2022 image. For some unexplainable reason, unit test project won't build or at least no produce a DLL to run later. Commented Jan 7, 2024 at 10:03
  • I found this solution to work for me: stackoverflow.com/a/59971457/1548275 Commented Jan 7, 2024 at 11:52

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer and one thing I would like to add is always use latest nuget version while restoring it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.