Scenario :
You have ASP.Net core application. You created build pipeline in Azure DevOps. The tasks in build pipeline look like this screen. Also you are using Microsoft provided agent – “vs2017-win2016”
Pipeline starts showing below errors-
####################################################################################################
C:\Program Files\dotnet\sdk\2.2.110\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.1. [d:\a\1\s\SampleWebApiAspNetCore\SampleWebApiAspNetCore.csproj]
NuGet Version: 4.4.1.4656
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe “C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\zz0nsncr.l5g.nugetinputs.targets” /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets=”C:\Users\VssAdministrator\AppData\Local\Temp\NuGetScratch\ljzojdde.s5h.nugetrestore.targets” /p:RestoreTaskAssemblyFile=”C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe” /p:RestoreSolutionDirectory=”d:\a\1\s” /p:RestoreConfigFile=”d:\a\1\Nuget\tempNuGet_147.config” /p:SolutionDir=”d:\a\1\s”
NuGet.CommandLine.ExitCodeException: Exception of type ‘NuGet.CommandLine.ExitCodeException’ was thrown.
at NuGet.CommandLine.MsBuildUtility.<GetProjectReferencesAsync>d__6.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.<GetDependencyGraphSpecAsync>d__48.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.RestoreCommand.<DetermineInputsFromMSBuildAsync>d__43.MoveNext()
####################################################################################################
####################################################################################################
Error parsing solution file at d:\a\1\s\SampleWebApiAspNetCore.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly ‘Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The system cannot find the file specified. d:\a\1\s\SampleWebApiAspNetCore.sln
NuGet Version: 4.4.1.4656
######################################################################################################
Solution:
Make 2 changes to your pipeline.
1.Change the build agent to “windows-2019”
2.Change the NuGet package version
Save and queue the pipeline. It will build the code fine.