Skip to content

Handle Corrupt Install Script Installs #2235

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

Merged
merged 9 commits into from
Apr 15, 2025

Conversation

nagilson
Copy link
Member

The dotnet install script has a bug where it wont do the install if the folder is not empty. Sometimes it will leave a partially done install, like if killed, in which case we get to a bad state.

This fixes that by cleaning up the directory, and or checking if dotnet.exe exists, whether it works. dotnet --list-runtimes is a fast way to do this since it should only invoke the host and not need to invoke the SDK. doing just 'dotnet' will not work as that does not return 0.

Also, gets rid of the 'lock' exception since thats from the proper-lockfile lib which we don't use anymore.

Resolves: #2059
First scrapped attempt: #2106

The dotnet install script has a bug where it wont do the install if the folder is not empty. Sometimes it will leave a partially done install, like if killed, in which case we get to a bad state.

This fixes that by cleaning up the directory, and or checking if dotnet.exe exists, whether it works.
dotnet --list-runtimes is a fast way to do this since it should only invoke the host and not need to invoke the SDK. doing just 'dotnet' will not work as that does not return 0.

Also, gets rid of the 'lock' exception since thats from the proper-lockfile lib which we don't use anymore.

Resolves: dotnet#2059
First scrapped attempt: dotnet#2106
@Copilot Copilot AI review requested due to automatic review settings April 11, 2025 23:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

vscode-dotnet-runtime-extension/src/test/functional/DotnetCoreAcquisitionExtension.test.ts:337

  • Consider adding an assertion that verifies the presence of the dotnet executable after reinstall to ensure that the cleanup and reinstall logic works as expected.
const _ = await installRuntime('9.0', 'runtime');

wipe dir only wipes the files, and the script looks at the folders
The Install Multiple versions tests fails bc the deprecated sdk code installs everything into the same folder, so this new cleanup logic will wipe the older folder.

The uninstall logic fails because the original sdk code does not work with respect to finding a local sdk when a global sdk is on the machine (it finds a 7.0.4xx sdk), this code is not used by anything anymore so it is likely not worth investigating.
@nagilson nagilson requested a review from a team April 14, 2025 22:44
Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really clear as to why your dotnet --list-runtimes check really tests whether the installation is valid or not. Any part could be corrupted, right? And --list-runtimes skips a lot of that, so shouldn't we install or not install based entirely on user input, i.e., user says it's broken --> reinstall?

@nagilson
Copy link
Member Author

nagilson commented Apr 14, 2025

I'm not really clear as to why your dotnet --list-runtimes check really tests whether the installation is valid or not. Any part could be corrupted, right? And --list-runtimes skips a lot of that, so shouldn't we install or not install based entirely on user input, i.e., user says it's broken --> reinstall?

That's a great point. I've changed it to validate that the install includes a runtime that is correct and matches the correct version/arch. w.r.t user input, this is the runtime that devkit runs on, so it doesnt require any user interaction. We try to get all of this done early on in the process so CDK and C# don't load slowly, so we wouldn't want to add interaction here with how its currently designed.

@nagilson
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@nagilson
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this more directly tests what you need

@nagilson nagilson merged commit b8c8db2 into dotnet:main Apr 15, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET installation error
3 participants