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
625 stars 56 forks source link

[NETSDKE2E][MAC] Throw an unhandled exception in dotnet-core-uninstall list output. #287

Closed v-xiaofchen closed 7 months ago

v-xiaofchen commented 8 months ago

To Reproduce

1.install dotnet-core-uninstall(1.7.0) from https://dnceng.visualstudio.com/_apis/resources/Containers/16714346/drop-osx?itemPath=drop-osx%2Fdotnet-core-uninstall.tar.gz

  1. Use the following commands to install the tool:
    mkdir -p ~/dotnet-core-uninstall
    tar -zxf dotnet-core-uninstall.tar.gz -C ~/dotnet-core-uninstall
    cd ~/dotnet-core-uninstall
    ./dotnet-core-uninstall list

    3.Install SDK 8.0.201from https://dotnet.microsoft.com/en-us/download/dotnet/8.0

  2. Run "./dotnet-core-uninstall list" 5.check the output of dotnet-core-uninstall list

Expected Result:

The version(s) of the .NET 8 SDK you installed appear in the output.

Actual Result:

Throw an unhandled exception in dotnet-core-uninstall list output. image

dotnet --info:

image

Note:

This issue also repro on.NET 6/7.

baronfel commented 8 months ago

Here's the line in question:

https://github.com/dotnet/cli-lab/blob/main/src/dotnet-core-uninstall/Shared/Configs/CommandLineConfigs.cs#L244C79-L244C97

This looks like an incorrect use of System.CommandLine to me - we're getting Environment.GetCommandLineArgs() in the static constructor of a type - this should only happen sometime after Main(stirng[] argv).