DEV Community

Cover image for Manually Removing .NET SDKs from MacOS
Justin Yoo
Justin Yoo

Posted on • Originally published at devkimchi.com

Manually Removing .NET SDKs from MacOS

.NET SDKs including .NET Core, .NET 5 and .NET 6 support cross-platform. For some reason, you might feel like removing the latest preview version of SDK or a certain version of SDK. You can then use many different methods to delete the SDK and runtime. In this post, I'm going to discuss the manual way of removing a specific version of the .NET SDK and runtime from MacOS.

Installation Paths for .NET SDKs & Runtimes

In your terminal in Mac OS, type the command, dotnet --list-sdks, and you will see the whole list of .NET SDKs you've installed so far, including the full path.

Installed .NET SDKs

This time, run the command, dotnet --list-runtimes, to get the whole list of the installed .NET runtimes.

Installed .NET Runtimes

Did you find some differences between SDKs and runtimes, other than the paths? That's right. Although you say .NET 6, the SDK and the runtime versions are slightly different. The same goes to .NET 5, .NET Core 3.1 and .NET Core 2.1, etc. Therefore, you need to be careful when the time comes to delete both SDK and runtime manually.

NOTE: If you want to know more about the .NET SDK and runtime versions, visit this page, How to check that .NET is already installed.

Deleting .NET SDK and Runtime

First of all, you can use the .NET Uninstall Tool to automatically delete the SDK and runtime you want. But as the doc says, sometimes it's not perfect deleting. Therefore, at the end of the day, you might want to delete each directory manually.

As mentioned above, you should be aware that both the SDK and runtime versions of the same release are different. For example, at the time of this writing, the latest release of .NET 6 has the SDK version of 6.0.100 and runtime version of 6.0.0. On the other hand, in case of .NET 5, the SDK version is 5.0.403, and the runtime version is 5.0.12. Therefore, to manually delete all the related directories, it is best to refer to this page, How to remove the .NET Runtime and SDK. But let's dive a little deep here.

Manually Deleting .NET SDK

Assuming you're deleting .NET 6 SDK. The latest version of the .NET 6 SDK is 6.0.100 at the time of this writing. As there are only two relevant directories to SDK, run the following bash command:

The .NET SDKs have been completely removed.

Manually Deleting .NET Runtime

This time, let's delete the .NET 6 runtime directories. Then, run the following bash command. Beware that number of directories varies, depending on the version of the runtime. But, since this is the whole list of the runtime directories, there's no harm to run the command anyway.

The specified .NET runtime directories have all been removed.

Manually Deleting Both SDK and Runtime at Once via PowerShell

If you're familiar with bash shell scripting, you can create a more sophisticated one to do the job. Instead, let's use PowerShell to delete both specified SDK and runtime at once. PowerShell also supports cross-platform, meaning you can use PowerShell on your MacOS. Here's the sample script.

By running this PowerShell script above, you can delete both the SDK and runtime of a specific version at once.

Reinstalling .NET SDK & Runtime of Previous Versions

I guess this is the most crucial part. From time to time, after the manual SDK/runtime deleting is done, the remaining .NET SDKs and runtimes won't work. If it happens to you, then you should reinstall the existing .NET SDKs and runtimes. For example, if you delete .NET 6 SDK and runtime, then suddenly .NET Core 2.1 and 3.1, and .NET 5 start complaining, you should reinstall the latest release of each .NET SDKs and runtimes. To get the old release, visit this download page, download the corresponding version of your choice and install them.

.NET SDK Download Page


So far, I've walked through how to delete a specific .NET SDK and runtime from MacOS manually. In most cases, you won't need this approach, but I hope this walkthrough will be helpful if you do.

Top comments (0)