Check Installation
Determine which version is installed with the command line.
According to Microsoft documentation, we need to remove the SDKs and runtimes separately:
Pay attention to the difference in installed locations between the Intel Mac vs. Silicon M series chip.
Arm-based mac: /usr/local/share/dotnet/
Intel-based mac: /usr/local/share/dotnet/x64/dotnet/
In this example, I want to remove the .NET 6 RC on an M1 silicon Mac from previous test.
% dotnet --list-runtimes Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] % dotnet --list-sdks 6.0.100-rc.1.21463.6 [/usr/local/share/dotnet/sdk]
Uninstall .NET
From the example above, we’ll remove all instances. All these commands can be entered all at once in the Terminal, it will ask you to enter sudo password just once.
sudo rm -rf /usr/local/share/dotnet/sdk/$version sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.NETCore.App/$version sudo rm -rf /usr/local/dotnet/shared/Microsoft.AspNetCore.All/$version sudo rm -rf /usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/$version sudo rm -rf /usr/local/share/dotnet/host/fxr/$version
That’s it.
You can re-run the dotnet –list-runtimes and dotnet –list-sdks to verify that there’s no longer any .NET installed. You should see something similar to this:
% dotnet --list-runtimes A fatal error occurred. The folder [/usr/local/share/dotnet/host/fxr] does not exist % dotnet --list-sdks A fatal error occurred. The folder [/usr/local/share/dotnet/host/fxr] does not exist
Now you can install the new version for your .NET development.
Further Reading
How to remove the .NET Runtime and SDK
How to Check Installed .NET Core Version
Trying .NET 6 Preview on macOS Silicon M1