cli-lab icon indicating copy to clipboard operation
cli-lab copied to clipboard

.NET Core SDKs: 8.0.100-rc.2.23502.2 (arm64) [Cannot uninstall version 8.0.0 and above]

Open tibinthomas opened this issue 1 year ago • 10 comments

.NET Core SDKs: 8.0.100-rc.2.23502.2 (arm64) [Cannot uninstall version 8.0.0 and above]

tibinthomas avatar Nov 12 '23 18:11 tibinthomas

.NET 8.0 has been released today (November 14, 2023) and the .NET uninstall tool (dotnet-core-uninstall) doesn't handle SDK versions 8 and above.

Steps to Reproduce

Running the command

dotnet-core-uninstall dry-run --sdk 8.0.100-rc.2.23502.2

produces the message

Uninstallation not allowed. This tool cannot uninstall .NET Core SDKs with version 8.0.0 or above.

jrdodds avatar Nov 14 '23 17:11 jrdodds

Anyone have a solution to this?

penkin avatar Nov 20 '23 17:11 penkin

Steps for manually deleting an SDK or Runtime:

  1. Run dotnet --info and note the base path, e.g.
 Base Path:   /usr/local/share/dotnet/sdk/8.0.100/
  1. To remove an SDK:
    • The dotnet/sdk directory (e.g. /usr/local/share/dotnet/sdk) will have a sub-directory for each installed sdk version.
    • Within the dotnet/sdk directory, delete the sdk version directory (e.g. 8.0.100-rc.2.23502.2).
  2. To remove a runtime:
    • The dotnet/shared directory (e.g. /usr/local/share/dotnet/shared) will have sub-directories for different runtimes (e.g. Microsoft.AspNetCore.App and Microsoft.NETCore.App). Each runtime directory will have version sub-directories.
    • For each relevant runtime, delete the version directory.

jrdodds avatar Nov 21 '23 04:11 jrdodds

Running into the same issue, this is an important functionality required to test forwards compatibility with .NET 8

thomasgauvin avatar Nov 22 '23 14:11 thomasgauvin

I have about 85 windows servers that I need to maintain with the latest version of dotnet SDK/hosting bundle.

I am not very amused by the conecept of in logging in and doing the uninstall interactively on all of them.

The dotnet-core-uninstall has been a very useful tool up until v8 was released.

I have ended up using the powershell script below instead as of lately, may be useful if someone else find themselves in a similar situation.

Be careful, the script is a blunt tool, as at your own risk - althoug it gets the job done for me.

$softwareName = '.NET'
$searchString = "*$softwareName*"
$msiExecPath = Join-Path -Path $env:SystemRoot -ChildPath 'system32' | Join-Path -ChildPath 'msiexec.exe'

function Find-DotNetCoreInstall {
    param (
        $softName = $softwareName
    )
    $software = @( 
        'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
    )
    $searchString = "*$softwareName**"
    $allDotNetItems = Get-ItemProperty $software | Where-Object {$_.displayName -like $searchString} | Select-Object DisplayName,DisplayVersion,UninstallString
    Write-Output $allDotNetItems
}
$allDotNetItems = Find-DotNetCoreInstall

if($allDotNetItems.count -gt 0) {
    Write-Host "Uninstalling $($allDotNetItems.count) components for $softwareName $version"

    foreach($item in $allDotNetItems) {
        $uninstallString = $item.UninstallString
        $name = $item.DisplayName
        if ($uninstallString -like "MsiExec.exe *") {
            Write-Host "Uninstalling $name version: $($item.displayVersion)"
            $guid = ([regex]'{[A-Z0-9-]+}').Match($uninstallString).Value

            start-process -FilePath $msiExecPath -ArgumentList @("/x$guid", "/passive", "/quiet", "/norestart", "IGNOREDEPENDENCIES=ALL", "/log `"$env:temp\$($name)_Uninstall_$($version).log`"") -Wait
        } 
        else {
            $filepath = ($uninstallString.Split('/')[0]).replace('"','')
            Write-Host "Uninstalling $name version: $($item.displayVersion)"
            Start-Process -FilePath $filepath -ArgumentList @("/uninstall", "/silent") -Wait
        }
    }
}
else {
    Write-Host "There are no installed components of $software $version"
    exit 0
}

$finalCheck = Find-DotNetCoreInstall
if ($finalCheck.count -eq 0){
    Write-Host "All .NET components have been uninstalled"
    exit 0
}
else {
    Write-Host "Error: NOT ALL COMPONENTS uninstalled! `n $finalCheck "
    exit 1
}

np422 avatar Dec 22 '23 08:12 np422

+1

Documentation still points to this tool as the only alternative to removing old .NET runtimes and SDKs. https://learn.microsoft.com/en-us/dotnet/core/install/remove-runtime-sdk-versions?pivots=os-macos https://github.com/dotnet/core/issues/1202

durandt avatar Feb 05 '24 12:02 durandt

Users that don't have permission to delete the folders in such paths currently have no way of uninstalling. Without uninstalling all the dotnet versions, there is no way to work around the issue mentioned here, running around in circles now :(

At the time this issue was opened, .NET 8 was in preview. But shortly after this issue was opened, .NET 8 was released.

As it stands now, the dotnet-core-uninstall tool doesn't support the current LTS release (.NET 8) and doesn't support the current preview release (.NET 9).

The source for the dotnet-core-uninstall tool was last updated in December 2022 and looking at the source there appears to be a hard-coded upper limit:

https://github.com/dotnet/cli-lab/blob/86b3ccddf425a7724b9b48f3feabeceb33730546/src/dotnet-core-uninstall/Shared/VSVersioning/VisualStudioSafeVersionsExtractor.cs#L15-L16

But there is a PR from a member of the Microsoft team that is pending review that would advance the supported versions to include v9 - see #268.

jrdodds avatar Feb 25 '24 16:02 jrdodds

We're aware that this is a long gap, and that macOS users especially don't have another answer for the problem that the uninstall tool solves. The current plan is for @joeloff and I to close out our current tasking and get dedicated time to do a few things in this repo:

  • merge the .NET8/9 enablement PRs and make a new release available
  • update the tool to modern .NET, potentially with AOT/trimming to make it smaller and easier to acquire
  • re-evaluate if the version-bound concept is needed anymore

We'll update this space with more details as we find out more about that dedicated chunk of time.

baronfel avatar Feb 25 '24 16:02 baronfel

Thanks @baronfel. That's great news.

jrdodds avatar Feb 25 '24 16:02 jrdodds

I've logged a new issue detailing the roadmap for the next release(s) of the tool at https://github.com/dotnet/cli-lab/issues/279.

baronfel avatar Mar 04 '24 18:03 baronfel

We've now released a new version of the tool that supports managing .NET 8 installs. Please see the release notes for more details!

baronfel avatar Apr 22 '24 20:04 baronfel