0

My team recently migrated to .NET 6.0 and after adding one of our projects back to the solution it was found that while it is building and running locally in Visual Studio just fine, in our Azure DevOps pipeline it fails with the following: C:\hostedtoolcache\windows\dotnet\sdk\6.0.405\Microsoft.Common.CurrentVersion.targets(4099,5): Error MSB4062: The "Microsoft.Build.Tasks.RequiresFramework35SP1Assembly" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I have been trying to update relevant packages and been researching online for a solution as to why this is happening but have no luck. Does anyone have an idea of what would be causing this and how to fix it?

2 Answers2

0

I ran into this exact same error, but with slightly different circumstances. My error was:

Microsoft.Common.CurrentVersion.targets(4149, 5): [MSB4062] The "Microsoft.Build.Tasks.RequiresFramework35SP1Assembly" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

My code compiled and ran fine in Visual Studio 2022 but when I tried to run it in JetBrains Rider, it failed with this error. I'm not sure in Azure what exactly needs to be done, but in Rider I went into File | Settings | Toolset and Build | Toolset. Under that section is an MSBuild version. Mine was set to "Auto detect (17)" with a path to %ProgramFiles%\dotnet\sdk\7.0.203\MSBuild.dll. I changed it to point to a folder under Rider's install path \tools\MSBuild\Current\Bin\amd64\MSBuild.exe. After saving the new settings, my app compiled and ran.

Screenshot of JetBrain Rider's Setting

JetBrains Rider 2023.2 EAP 1 Build #RD-232.5150.114

I found that solution here: https://youtrack.jetbrains.com/issue/RIDER-86346

Klyph
  • 1
  • 2
0

Not sure if this will help you, but I ran into this problem, and changed the build task to a MSBuild template, using build to x64 architecture.

image of the task in the yaml file