dotnet / cli-lab

A guided tool will be provided to enable the controlled clean up of a system such that only the desired versions of the Runtime and SDKs remain.
MIT License
615 stars 56 forks source link

[dotnet-core-uninstall] Allow preview version removal #269

Open pjcollins opened 12 months ago

pjcollins commented 12 months ago

Context: https://github.com/dotnet/cli-lab/issues/265

Updates the uninstall tool to ignore the upper version check and uninstallation restriction when the --force parameter is provided.

Local testing output:

% sudo dotnet artifacts/bin/dotnet-core-uninstall/Debug/net8.0/dotnet-core-uninstall.dll list                   

This tool cannot uninstall versions of the runtime or SDK that are installed using zip/scripts. The versions that can be uninstalled with this tool are:

.NET Core SDKs:
  9.0.100-preview.2.24157.14  (arm64)  [Cannot uninstall version 9.0.0 and above. Use —-force to remove]             
  8.0.101                     (arm64)  [Used by Visual Studio for Mac. Specify individually or use —-force to remove]

.NET Core Runtimes:
  9.0.0-preview.2.24128.5  (arm64)  [Used by Visual Studio for Mac or SDKs. Specify individually or use —-force to remove]
  9.0.0-preview.2.24128.5  (x64)                                                                                          
  9.0.0-preview.2.24128.4  (arm64)                                                                                        
  9.0.0-preview.2.24128.4  (x64)  
  8.0.1   (arm64)  [Used by Visual Studio for Mac or SDKs. Specify individually or use —-force to remove]
  8.0.1   (x64)                                                                                          

% sudo dotnet artifacts/bin/dotnet-core-uninstall/Debug/net8.0/dotnet-core-uninstall.dll remove --sdk 9.0.100-preview.2.24157.14
Uninstallation not allowed. This tool cannot uninstall .NET Core SDKs with version 9.0.0 or above. Use --force to ignore this restriction.

% sudo dotnet artifacts/bin/dotnet-core-uninstall/Debug/net8.0/dotnet-core-uninstall.dll remove --sdk 9.0.100-preview.2.24157.14 --force
The following items will be removed:
  Microsoft .NET Core SDK 9.0.100-preview.2.24157.14 (x64)

To avoid breaking Visual Studio for Mac or other problems, read https://aka.ms/dotnet-core-uninstall-docs.

Do you want to continue? [y/n] y
Uninstalling: Microsoft .NET Core SDK 9.0.100-preview.2.24157.14 (x64).
joeloff commented 11 months ago

cc @Forgind

marcpopMSFT commented 7 months ago

@baronfel per our chat earlier about removing the upper limit. This PR provides an alternative option for customers though is not exacty what we were talking about.

pjcollins commented 6 months ago

I reworked this to use the --force argument to uninstall versions over the upper limit, rather than adding a new parameter.