Search code examples
.netvisual-studiosdk.net-6.0visual-studio-2022

Visual Studio 2019 & 2022 (Preview) not finding .NET 6 SDK on launch - mac osx


I'm trying to run a C# .NET Core project locally on Mac and encountering some issues both on Visual Studio 2019 and 2022.

Firstly, every time on loading up the project in Visual Studio, I get a red cross beside each directory in the file tree of the project and a message at the top of the screen to say:

.NET 6.0 SDK is required to build this application and is not installed.

The console says:

error: Unknown MSBuild failure. Please try building the project again Unable to create package spec for project.

In Visual Studio Preferences>SDK Locations>.Net Core, I get an error to say 'SDKs found: None' even though in the boxes below it's showing SDK's that are found, as below. If I change the location then change it back, the red crosses next to the directories disappear in the file tree but the build still fails and I still have the error message to say .NET 6.0 SDK is required to build.

enter image description here

In project options, the target framework is set to .NET 6.0 and it shows as installed.

I have tried completely uninstalling dotnet and reinstalling both from the browser and using homebrew, reinstalling Visual Studio, adding a global.json file with sdk version, and checking dotnet is definitely installed.

$ dotnet --info in terminal produces the following:

enter image description here

What I do notice is the 'Base Path' here is different to the path in preferences (in the picture above). I'm not sure if this could be related, or if this could be a path related issue but possibly someone might be able to advise with more knowledge than me.

Thank you.


Solution

  • The location of the sdk should be as below ( attached screenshot as well )

    /usr/local/share/dotnet/dotnet
    

    instead of

    /usr/local/share/dotnet
    

    enter image description here