New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove old .NET Core SDKs? #2295

Closed
AArnott opened this Issue May 31, 2018 · 8 comments

Comments

Projects
None yet
6 participants
@AArnott
Contributor

AArnott commented May 31, 2018

After installing .NET Core 2.1 SDK (great job, BTW), dotnet --info showed me I had all this installed:

.NET Core SDKs installed:
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100-preview-007328 [C:\Program Files\dotnet\sdk]
  2.1.100-preview-007341 [C:\Program Files\dotnet\sdk]
  2.1.100-preview-007354 [C:\Program Files\dotnet\sdk]
  2.1.100-preview-007363 [C:\Program Files\dotnet\sdk]
  2.1.100-preview-007391 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007480 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007509 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007513 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007517 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007570 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007576 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007587 [C:\Program Files\dotnet\sdk]
  2.1.200-preview-007589 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

How do I remove the old cruft (especially the previews)?

@davkean

This comment has been minimized.

Show comment
Hide comment
@davkean

davkean May 31, 2018

Member

Cough, cough: dotnet/cli#6896. :)

Member

davkean commented May 31, 2018

Cough, cough: dotnet/cli#6896. :)

@AArnott

This comment has been minimized.

Show comment
Hide comment
@AArnott

AArnott May 31, 2018

Contributor

That is related, but yours seems to be mostly around VS automatically uninstalling these, which is interesting, but not my point. When I go to Add/Remove Programs, I can't discern between the previews and the non preview versions (of 2.1.100, for example):
image

So there doesn't appear to be a way to actually target one of these and uninstall them. It's random which one gets deleted.

Contributor

AArnott commented May 31, 2018

That is related, but yours seems to be mostly around VS automatically uninstalling these, which is interesting, but not my point. When I go to Add/Remove Programs, I can't discern between the previews and the non preview versions (of 2.1.100, for example):
image

So there doesn't appear to be a way to actually target one of these and uninstall them. It's random which one gets deleted.

@svick

This comment has been minimized.

Show comment
Hide comment
@svick

svick May 31, 2018

@AArnott

When I go to Add/Remove Programs, I can't discern between the previews and the non preview versions (of 2.1.100, for example)

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).

svick commented May 31, 2018

@AArnott

When I go to Add/Remove Programs, I can't discern between the previews and the non preview versions (of 2.1.100, for example)

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).

@AArnott

This comment has been minimized.

Show comment
Hide comment
@AArnott

AArnott May 31, 2018

Contributor

Thanks, @svick. I just a few minutes ago figured that out. But it's so tedious to look through each one and uninstall each one (each with its own UAC prompt, uninstall experience, etc).

As a workaround, here's what I came up with:

$products = Get-WmiObject -Class win32_product
$remove = $products |? { $_.name -match 'Microsoft .NET Core SDK - 2.1.200' }

I would then review the contents of $remove and look to find the one with the highest version number (and assume that's the RTW version I want to keep). Then I would refine the $remove collection with:

$remove = $products |? { $_.name -match 'Microsoft .NET Core SDK - 2.1.200' -and $_.version -ne '8.50.7609' }

Finally, I would remove all the selected MSIs with:

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

I can't use the /passive switch because it would no-op since the MSI thinks that a product requires the MSI to be installed. If I remove it, I have two dialogs to click "Yes" to for each MSI, but the process is still faster and less tedious than using the Apps & Features dialog.

Contributor

AArnott commented May 31, 2018

Thanks, @svick. I just a few minutes ago figured that out. But it's so tedious to look through each one and uninstall each one (each with its own UAC prompt, uninstall experience, etc).

As a workaround, here's what I came up with:

$products = Get-WmiObject -Class win32_product
$remove = $products |? { $_.name -match 'Microsoft .NET Core SDK - 2.1.200' }

I would then review the contents of $remove and look to find the one with the highest version number (and assume that's the RTW version I want to keep). Then I would refine the $remove collection with:

$remove = $products |? { $_.name -match 'Microsoft .NET Core SDK - 2.1.200' -and $_.version -ne '8.50.7609' }

Finally, I would remove all the selected MSIs with:

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

I can't use the /passive switch because it would no-op since the MSI thinks that a product requires the MSI to be installed. If I remove it, I have two dialogs to click "Yes" to for each MSI, but the process is still faster and less tedious than using the Apps & Features dialog.

@nguerrera

This comment has been minimized.

Show comment
Hide comment
@nguerrera

nguerrera May 31, 2018

Member

Closing this as the question is answered and dotnet/cli#6896 tracks preventing these from accumulating via build-to-build upgrades of VS. If you feel there's a change that is needed to the installer that is not dotnet/cli#6896, file a new issue on the dotnet/cli repo.

Member

nguerrera commented May 31, 2018

Closing this as the question is answered and dotnet/cli#6896 tracks preventing these from accumulating via build-to-build upgrades of VS. If you feel there's a change that is needed to the installer that is not dotnet/cli#6896, file a new issue on the dotnet/cli repo.

@shanselman

This comment has been minimized.

Show comment
Hide comment
@shanselman

shanselman Sep 24, 2018

Here's a small improvement to reduce errors with @AArnott's excellent script. You can get errors like "This installation package could not be opened" if you aren't in System32 when doing the uninstall.

$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 $_" }

popd

shanselman commented Sep 24, 2018

Here's a small improvement to reduce errors with @AArnott's excellent script. You can get errors like "This installation package could not be opened" if you aren't in System32 when doing the uninstall.

$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 $_" }

popd

@dub505

This comment has been minimized.

Show comment
Hide comment
@dub505

dub505 Sep 26, 2018

Can unnecessary runtimes be removed this way also?

dub505 commented Sep 26, 2018

Can unnecessary runtimes be removed this way also?

@shanselman

This comment has been minimized.

Show comment
Hide comment
@shanselman

shanselman Sep 27, 2018

@dub505 I believe those can just be deleted

shanselman commented Sep 27, 2018

@dub505 I believe those can just be deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment