How to Remove the .NET Runtime and SDK

Over time, as you install updated versions of the .NET runtime and SDK, you may want to remove outdated versions of .NET from your machine. Uninstalling older versions of the runtime may change the runtime chosen to run shared framework applications, as detailed in the article on .NET version selection.

Should I remove a version?

The .NET version selection behaviors and the runtime compatibility of .NET across updates enables safe removal of previous versions. .NET runtime updates are compatible within a major version band such as 7.x and 6.x. Additionally, newer releases of the .NET SDK generally maintain the ability to build applications that target previous versions of the runtime in a compatible manner.

In general, you only need the latest SDK and latest patch version of the runtimes required for your application. Instances where you might want to keep older SDK or runtime versions include maintaining project.json-based applications. Unless your application has specific reasons for earlier SDKs or runtimes, you may safely remove older versions.

Determine what is installed

The .NET CLI has options you can use to list the versions of the SDK and runtime that are installed on your computer. Use dotnet --list-sdks to see the list of installed SDKs and dotnet --list-runtimes for the list of runtimes. For more information, see How to check that .NET is already installed.

Uninstall .NET

.NET uses the Windows Apps & features dialog to remove versions of the .NET runtime and SDK. The following figure shows the Apps & features dialog. You can search for core or .net to filter and show installed versions of .NET.

Add / Remove programs to remove .NET

Select any versions you want to remove from your computer and click Uninstall.

.NET Uninstall Tool

The .NET Uninstall Tool (dotnet-core-uninstall) lets you remove .NET SDKs and runtimes from a system. A collection of options is available to specify which versions should be uninstalled.

Visual Studio dependency on .NET SDK versions

Before Visual Studio 2019 version 16.3, Visual Studio installers called the standalone SDK installer for .NET Core version 2.1 or 2.2. As a result, the SDK versions appear in the Windows Apps & features dialog. Removing .NET SDKs that were installed by Visual Studio using the standalone installer may break Visual Studio. If Visual Studio has problems after you uninstall SDKs, run Repair on that specific version of Visual Studio. The following table shows some of the Visual Studio dependencies on .NET Core SDK versions:

Visual Studio version.NET Core SDK version
Visual Studio 2019 version 16.2.NET Core SDK 2.2.4xx, 2.1.8xx
Visual Studio 2019 version 16.1.NET Core SDK 2.2.3xx, 2.1.7xx
Visual Studio 2019 version 16.0.NET Core SDK 2.2.2xx, 2.1.6xx
Visual Studio 2017 version 15.9.NET Core SDK 2.2.1xx, 2.1.5xx
Visual Studio 2017 version 15.8.NET Core SDK 2.1.4xx

Starting with Visual Studio 2019 version 16.3, Visual Studio is in charge of its own copy of the .NET SDK. For that reason, you no longer see those SDK versions in the Apps & features dialog.

Remove the NuGet fallback directory

Before .NET Core 3.0 SDK, the .NET Core SDK installers used a directory named NuGetFallbackFolder to store a cache of NuGet packages. This cache was used during operations such as dotnet restore or dotnet build /t:Restore. The NuGetFallbackFolder was located under the sdk folder where .NET is installed. For example it could be at C:\Program Files\dotnet\sdk\NuGetFallbackFolder on Windows and at /usr/local/share/dotnet/sdk/NuGetFallbackFolder on macOS.

You may want to remove this directory, if:

  • You’re only developing using .NET Core 3.0 SDK or .NET 5 or later versions.
  • You’re developing using .NET Core SDK versions earlier than 3.0, but you can work online.

If you want to remove the NuGet fallback directory, you can delete it, but you’ll need administrative privileges to do so.

It’s not recommended to delete the dotnet directory. Doing so would remove any global tools you’ve previously installed. Also, on Windows:

  • You’ll break Visual Studio 2019 version 16.3 and later versions. You can run Repair to recover.
  • If there are .NET Core SDK entries in the Apps & features dialog, they’ll be orphaned.

Ref: Remove the .NET runtime and SDK – .NET | Microsoft Learn