How to Uninstall Old .NET SDK and Runtime Versions on macOS
Learn how to safely uninstall outdated .NET SDK and Runtime versions from your macOS system.
If you’re a .NET developer using macOS, you might not realize that old versions of the .NET SDK and Runtime can take up valuable storage space. When you install a new .NET version, previous versions are usually left behind. This is often helpful for testing different .NET versions side by side.
Fortunately, you can easily identify all installed .NET versions on macOS using Terminal.
Check Installed .NET SDKs and Runtimes
First, let’s see which .NET SDKs and Runtimes are installed on your system. Run the following command:
dotnet sdk check
Here’s an example of the command output:
$ dotnet sdk check
.NET SDKs:
Version Status
----------------------------------------
6.0.421 Patch 6.0.422 is available.
6.0.422 Up to date.
7.0.408 .NET 7.0 is out of support.
8.0.204 Patch 8.0.205 is available.
Try out the newest .NET SDK features with .NET 9.0.100-preview.4.24267.66.
.NET Runtimes:
Name Version Status
----------------------------------------------------------------------
Microsoft.AspNetCore.App 6.0.29 Patch 6.0.30 is available.
Microsoft.NETCore.App 6.0.29 Patch 6.0.30 is available.
Microsoft.AspNetCore.App 6.0.30 Up to date.
Microsoft.NETCore.App 6.0.30 Up to date.
Microsoft.AspNetCore.App 7.0.18 .NET 7.0 is out of support.
Microsoft.NETCore.App 7.0.18 .NET 7.0 is out of support.
Microsoft.AspNetCore.App 8.0.4 Patch 8.0.5 is available.
Microsoft.NETCore.App 8.0.4 Patch 8.0.5 is available.
The latest versions of .NET can be installed from https://aka.ms/dotnet-core-download. For more information about .NET lifecycles, see https://aka.ms/dotnet-core-support.
Removing Unused .NET SDKs
Review the list and decide which SDK versions you no longer need. To find the installation directories for each SDK, use:
$ dotnet --list-sdks
6.0.421 [/usr/local/share/dotnet/sdk]
6.0.422 [/usr/local/share/dotnet/sdk]
7.0.408 [/usr/local/share/dotnet/sdk]
8.0.204 [/usr/local/share/dotnet/sdk]
For example, to remove the .NET SDK version 6.0.421
, delete its directory:
$ rm -rf /usr/local/share/dotnet/sdk/6.0.421
Repeat this process for any other SDK versions you wish to uninstall to free up space.
Removing Unused .NET Runtimes
.NET runtimes, including ASP.NET and the generic .NET runtime, are also installed alongside the SDK. To list all installed runtimes, run:
$ dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.29 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.30 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.29 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.30 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
If you want to remove the .NET and ASP.NET runtime version 6.0.29
, delete these directories:
/usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.29
/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/6.0.29
Use the following commands:
$ rm -rf /usr/local/share/dotnet/shared/Microsoft.NETCore.App/6.0.29
$ rm -rf /usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/6.0.29
Remove any other runtime versions you no longer need.
Conclusion
.NET developers on macOS often overlook the storage used by old SDK and Runtime versions, since they’re hidden from view, unlike on Windows. Hopefully, this guide helps you tidy up your macOS storage.
Developing .NET apps on macOS is an enjoyable experience!
Thanks for reading, and see you next time.