7

After installing VS 2022 for Mac (Apple Silicon), it looks like the bundled version of MSBuild does not work with VS ?!?

When opening a solution, VS reports the following error:

Unable to find SDK ‘Microsoft.NET.SDK.WorkloadAutoImportPropsLocator’. SDK not found Version 6.0.300 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.10.1.27501. Change the .NET SDK specified in global.json to an older version that requires the MSBuild version currently available.

HW: Apple Mac Studio, M1 Max OS: macOS Monterey, 12.4 .Net SDK: 6.0.300 .Net Runtimes: Microsoft.AspNetCore.App 6.0.5 Microsoft.NETCore.App 6.0.5 MSBuild: 16.10.1 for Mono

Ive tried uninstalling / reinstalling several times, nothing changes. Is there a MSBuild version 17.x that can be manually downloaded/installed to fix this ?

Any help is much appreciated !

Skima
  • 73
  • 1
  • 4
  • https://web.archive.org/web/20220513001032/https://learn.microsoft.com/en-us/answers/questions/478249/sdk-package-not-found-34microsoftnetsdkworkloadaut.html – Hans Passant Jun 01 '22 at 14:42
  • Downgrading to 6.0.203 fixed issue for me – pfedotovsky Jun 02 '22 at 13:05
  • With 6.0.300, the following error occurs for projects with Microsoft.NET.Sdk.Worker: error MSB4236: The SDK 'Microsoft.NET.Sdk.Worker' specified could not be found. – pfedotovsky Jun 07 '22 at 13:44

1 Answers1

9

If you have a mix of .NET and classic projects in a solution you may have problems building the solution with .NET 6.0.300 SDK installed.

To build classic projects MSBuild on mono has to be used, however that does not support .NET 6.0.300 so the .NET SDK is downgraded.

Possible workarounds:

  1. Install .NET 6.0.10x SDK (which MSBuild on mono supports)
  2. Solution options - Build - General, uncheck Build with MSBuild on mono

If workaround 1) does not completely allow the solution to build then try workaround 2) which requires workaround 1 otherwise the project cannot be loaded.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Well I unchecked Build with MSBuild on mono because downgrading NET 6.0.3 to 6.0.10x did not change anything. However, what is it using then if MSBuild on mono is unchecked ? How can I configure that for pipeline builds which don't rely on UI checkbox in VS ? Ty ! – Umar3x Jun 03 '22 at 18:31
  • Down grading to 6.0.105 enabled me to load the solution, but I had to leave the Build on Mono checked to get the project to build. – Skima Jun 04 '22 at 01:53
  • Visual Studio for Mac has to use MSBuild on mono, which is bundled with VS Mac itself, for classic projects (non-SDK style projects). With the MSBuild on mono unchecked then MSBuild on mono is still used for these classic projects, however SDK style projects will be using dotnet's MSBuild. – Matt Ward Jun 04 '22 at 13:51
  • @skima - what sort of projects are in your solution? – Matt Ward Jun 04 '22 at 13:51
  • Ty. This is also a solution that is "solution scoped". I have an agent on ADO that is configured with VS 2022 17.0.5 for mac, but it keeps using MSBUILD from mono (16.10), which causes it to not find C# 10. How can we make usage of MSBUILD 17.X OR even Msbuild from .NET SDK instead of the one shipped with mono ? – Umar3x Jul 05 '22 at 20:44
  • If you the project you are using is a classic project (non-SDK style) then VS Mac will always use msbuild on mono - there is no way to prevent this. Building a classic project may or may not work with dotnet's msbuild - it depends what msbuild targets it uses. The mono based MSBuild bundled with VS Mac 17 is MSBuild 16.10 and there are no plans to update this. Mono based MSBuild in VS Mac supports compiling C# 10 projects - not sure what problem you are seeing there. – Matt Ward Jul 06 '22 at 08:58
  • @MattWard the problem here is that we can't tell the build agent on AppCenter for example to use the bundled msbuild with VS. Any ideas how to do this? – Mr. Onion Jul 29 '22 at 15:14