Scott Hanselman

Scripts to remove old .NET Core SDKs

September 21, 2018 Comment on this post [8] Posted in DotNetCore
Sponsored By

That's a lot of .NET Core installations.NET Core is lovely. Its usage is skyrocketing, it's open source, and .NET Core 2.1 has some amazing performance improvements. Just upgrading from 2.0 to 2.1 gave Bing a 34% performance boost.

However, for those of us who are installing multiple .NET Core SDKs side by side have noticed that they add-up if you are installing daily builds or very often. As of 2.x, .NET Core doesn't yet have an "uninstall all" or "uninstall all previews" option. There will be work done in .NET Core 3.0 that will mitigate this cumulative effect when you have lots of installers.

Here's a PowerShell Script you can run on Windows as admin that will aggressively uninstall .NET Core SDKs.

Note the match at the top. Depending on your goals, you might want to change it to "Microsoft .NET Core SDK 2.1" or just "Microsoft .NET Core SDK 2."

Once it's all removed, then add the latest from

A list of .NET Core SDKs

Here's the script, which is an improvement on Andrew's comment here. You can improve it as it's on GitHub here This scripts currently requires you to hit YES as the MSIs elevate. It doesn't work right then you try /passive as a switch. I'm interesting if you can get a "torch all Core SDK installers and install LTS and Current" script working.

$app = Get-WmiObject -Class Win32_Product | Where-Object { 
    $_.Name -match "Microsoft .NET Core SDK" 

Write-Host $app.Name 
Write-Host $app.IdentifyingNumber
pushd $env:SYSTEMROOT\System32

$app.identifyingnumber |% { Start-Process msiexec -wait -ArgumentList "/x $_" }


This PowerShell is Windows-only, of course.

If you're on RHEL, Ubuntu/Debian, there are scripts here to try out

Let me know if this script works for you.

Sponsor: Copy: Rider 2018.2 is here! Publishing to IIS, Docker support in the debugger, built-in spell checking, MacBook Touch Bar support, full C# 7.3 support, advanced Unity support, and more.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
September 24, 2018 10:49
I tested it and when I see the "Add remove programs" of Windows, nothing has changed and nothing is uninstalled.
September 24, 2018 10:54
You might want to be careful using win32_product on a server. It causes all msi packages on the system to run a repair. Shouldn't be a problem on your local dev box but keep it in mind.
September 24, 2018 10:57
Also it doesn't see the ".NET Core 1.0.0 - sdk"'s. There's a version number here in between.
September 24, 2018 11:37
I started writing a global tool to do this at the Summit hackathon last year and just never got it published, maybe time to revisit that :)
September 24, 2018 12:27
I can easily add a "One elevation to rule them all" code to this PowerShell script, if anyone's interested.
September 24, 2018 17:30
Tread lightly while uninstalling .NET Core SDKs. Over a week ago attempt at doing just that on my machine rendered VS 2017 installation completely dead - couldn't install the updates. Uninstall didn't work either. Manually removed it and could no longer install it either. MS support ticket is still open for over a week now with no end in sight. So, machine's been re-imaged. You've been warned.
September 28, 2018 21:50
When you click on one of those installed SDKs, it will show you the version. For previews, it should show 4 part version (e.g. 2.1.300.8866 for .Net Core SDK 2.1.300 "RTM"). For non-previews, it will show only 3 parts (e.g. 2.1.300).
October 02, 2018 8:06
Thanks, its work on my windows computer.

Tubi TV Activate

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.