Skip to content
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

Try to find a valid dotnet version from the path before falling back to runtime extension #6074

Merged
merged 4 commits into from
Aug 10, 2023

Conversation

dibarbet
Copy link
Member

@dibarbet dibarbet commented Aug 8, 2023

We've gotten lots of reports of issues with the .net runtime downloader extension, e.g. #6004

While we wait for those to be fixed, we can workaround the issue by seeing if there is a valid dotnet version on the path that we can use to start the server instead. This will not fix issues in devkit.

TODO - verify on linux/mac.

@dibarbet dibarbet requested a review from a team as a code owner August 8, 2023 23:01
throw new Error(`Unknown result output from 'dotnet --version'. Received ${result.stdout}`);
}

if (semver.lt(dotnetVersion, this.minimumDotnetVersion)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

everything before here is the exact code O# uses which has been working

@@ -25,6 +25,7 @@ export async function getDotnetInfo(dotNetCliPaths: string[]): Promise<DotnetInf

Copy link
Member

Choose a reason for hiding this comment

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

This file uses --info. --info is not meant for automation and does not have a guaranteed format. The recommendation is to use --list-runtimes and --list-sdks. If there is data you need that is not avaialble in those existing commands, please let us know and we can look into additional stable, machine readable options that are not --info.

CC @elinor-fung @vitek-karas since the work would come out of the host to add new information/commands potentially.

Copy link
Member Author

@dibarbet dibarbet Aug 9, 2023

Choose a reason for hiding this comment

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

I can probably replace the version lookup using the --list-sdks command with some work. However we also read the runtimeid (for the debugger) and the architecture (for this PR) which don't appear to be in either of those commands.

Generally I would like to avoid needing to parse dotnet info as well - and once the new version of the sdk acquisition extension is available I will likely be able to remove the part of the code I'm adding here. I'm not so sure about the other use cases like the debugger (cc @gregg-miskelly).

Copy link
Contributor

Choose a reason for hiding this comment

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

For the debugger, we are trying to check the version and architecture of the globally installed .NET, as we need the one the application is going to run on. If we want to switch the target app to run on the version of .NET that the acquisition extension downloads, we could probably get rid of the check. But dotnet --list-runtimes and dotnet --list-sdks don't have architecture information, so those commands aren't useful enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it more: as long as we provide a way to specify a .NET SDK in the extension, we probably are going to need a way to check the architecture.

@dibarbet dibarbet merged commit 6624e2e into dotnet:main Aug 10, 2023
4 checks passed
@dibarbet dibarbet deleted the dotnet_from_path branch August 10, 2023 17:51
Comment on lines +160 to +169
const command = this.platformInfo.isWindows() ? 'where' : 'which';
const whereOutput = await promisify(exec)(`${command} dotnet`);
if (!whereOutput.stdout) {
throw new Error(`Unable to find dotnet from ${command}.`);
}

const path = whereOutput.stdout.trim();
if (!existsSync(path)) {
throw new Error(`dotnet path does not exist: ${path}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I reused this code for C# Dev Kit, but it failed in AzP because where returns one line for each dotnet found on the PATH, and this code assumes exactly one line will be produced. I'll fix my copy. But I suspect your code here will fail on any customer machine that has dotnet.exe installed in two places.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah - thanks for the info. I'll take a look.

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.

6 participants