Search code examples
.netmacosvisual-studio-2022

VS2022 Mac can't build, claiming I have missing SDKs


I got a new Macbook for development and I'm now in the process of building the dev environment for it. I have installed .NET 6, 7, and 8 SDKs, then VS2022 and Rider (I mostly rely on Rider and VS2022 is more of a backup and a way to diagnose weirdness, like now).

So, I get some strange error with Rider when I build MAUI apps and wanted to try it with VS2022 to see if I get the same. Instead, turns out, VS2022 can't build any of my projects. When I do I get this:

Error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. (NETSDK1045) (TetraPak.XP.Common)

For troubleshooting I have made sure .NET 8 is indeed installed...

> dotnet --list-sdks
6.0.419 [/usr/local/share/dotnet/sdk]
7.0.313 [/usr/local/share/dotnet/sdk]
8.0.201 [/usr/local/share/dotnet/sdk]

printenv reveals a PATH to the .NET root folder at /usr/local/share/dotnet

I have made sure there is no global.json file or Directory.build.props anywhere that points to the wrong SDK

I tried point the environment variable export MSBuildSDKPath="/usr/local/share/dotnet/sdk"

I ensured VS2022 wasn't building with MSBuild on Mono

I'm now out of ideas. Is there anything else I can do?


Solution

  • There's no support for .NET 8. VS for Mac was discontinuted and goes out of support in August 2024.

    As the announcement says:

    Microsoft doesn't plan to add support for .NET 8 or C#12 to Visual Studio for Mac. We won't extend to any other workloads before retirement either.

    The official alternatives are to either work on VS on Windows with a paired Mac, or use VS Code with C# Dev Kit, which requires a subscription similar to Visual Studio. From the docs

    For personal, academic, and open-source projects, the C# Dev Kit can be used at no cost. For commercial purposes, teams of up to 5 can also use the C# Dev Kit at no cost. For 6+ developers, those users will need a Visual Studio Professional (or higher) subscription. The C# Dev Kit is also included in GitHub Codespaces and Microsoft Dev Box, so users of those products have access to the C# Dev Kit at no additional charge

    You could use Parallels to run VS for ARM on Windows 11 for ARM on a Mac. I have no idea if this is a viable option though