I am having an issue with .NET 6 on Visual Studio 2022 Mac M1 chip. What happens is when I want to build or clean my WebApi project I get the following error.
The operation failed due to an internal error: Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. An attempt was made to load a program with an incorrect format.
This is what I have for dotnet --info command
.NET SDK (reflecting any global.json):
Version: 6.0.200
Commit: 4c30de7899
Runtime Environment:
OS Name: Mac OS X
OS Version: 12.2
OS Platform: Darwin
RID: osx.12-x64
Base Path: /usr/local/share/dotnet/x64/sdk/6.0.200/
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
.NET SDKs installed:
3.1.416 [/usr/local/share/dotnet/x64/sdk]
5.0.405 [/usr/local/share/dotnet/x64/sdk]
6.0.102 [/usr/local/share/dotnet/x64/sdk]
6.0.200 [/usr/local/share/dotnet/x64/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.22 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.14 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.22 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.14 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]`
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
I have tried many things but none of them has worked. I would appricate any help!
I was facing the same issue and I was able to make it work. (also Mac M1 chip)
But I did several actions, I'm not sure which one was responsible for fixing it.
I think my problem was related to having both "Visual Studio 2019 for Mac" and "Visual Studio 2022 Preview for Mac" installed.
I've uninstalled both. Then I removed all SDK files cleaning both:
/usr/local/share/dotnet/x64
and
/usr/local/share/dotnet/
(YMMV here, I used this article to discover those paths)
Then I installed only the "Visual Studio 2022 Preview for Mac", with its net6.0 sdk.
Opened my solution and it didn't work (because my solution was net5.0).
Then I installed the old "Visual Studio 2019 for Mac" (to get the x64 net5.0 sdk installed).
And when I opened the solution in the new "VS 2022 Preview", it now worked.
At a given moment, I updated the .NET Core SDK location on Preferences:
To /usr/local/share/dotnet/dotnet (which I think is the location for the net6)
I know my answer is not precise, but I count on the community help to test these steps and then I can edit it here. :)