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

Use the .NET runtime extension to find an appropriate .NET install #7684

Merged
merged 12 commits into from
Nov 21, 2024

Conversation

dibarbet
Copy link
Member

C# extension side of microsoft/vscode-dotnettools#1243

Switches from our custom dotnet resolution to call the .net install tool API. Also ensures that a high enough version of the install tool exists.

@dibarbet dibarbet requested review from a team as code owners October 23, 2024 02:19
env: this.getEnvironmentVariables(dotnetPath),
};
let dotnetExecutablePath: string;
if (commonOptions.dotnetPath) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this should be deprecated in favor of the options on the .net install tool side. However I plan to tackle that in a separate PR as we'll need to separate out the O# usage of this option.

Copy link
Member

Choose a reason for hiding this comment

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

I thought about whether we should keep the existing logic as a backup, but if this has about a mo in pre-release I'm not so concerned.

},
versionSpecRequirement: 'greater_than_or_equal',
};
const result = await vscode.commands.executeCommand<string>('dotnet.findPath', findPathRequest);
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It can return an IDotnetAcquireResult if the existingDotnetPath is set. It should always return an IDotnetAcquireResult. This was a mistake on my part, thank you for bringing this to my attention. I will make a fix.

src/main.ts Outdated Show resolved Hide resolved
src/main.ts Outdated
@@ -83,6 +84,35 @@ export async function activate(
requiredPackageIds.push('OmniSharp');
}

const dotnetRuntimeExtensionId = 'ms-dotnettools.vscode-dotnet-runtime';
const requiredDotnetRuntimeExtensionVersion = '2.2.1';
Copy link
Member

Choose a reason for hiding this comment

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

Too bad this can't be expressed in the package.json

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, unfortunately no versions in extension dependencies :(

@dibarbet
Copy link
Member Author

converting to draft - there is one slight modification to the API coming in version 2.2.2 to consistently return a IDotnetAcquireResult instead of just a string. Will update this PR once it is available.

@dibarbet dibarbet marked this pull request as ready for review November 19, 2024 01:51
@dibarbet
Copy link
Member Author

2.2.3 is now available which also includes support for requiring at least a patch version. this is ready for review

l10n/bundle.l10n.json Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
src/main.ts Show resolved Hide resolved
src/main.ts Outdated
if (lt(dotnetRuntimeExtensionVersion, requiredDotnetRuntimeExtensionVersion)) {
const button = vscode.l10n.t('Update and reload');
const prompt = vscode.l10n.t(
'The {0} extension requires version {1} or greater of the .NET Install Tool ({2}) extension. Please update to continue',
Copy link
Member

@nagilson nagilson Nov 19, 2024

Choose a reason for hiding this comment

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

Some people who install C# have no idea what .NET is, so we might expect some amount of confusion from users who don't understand why they would need a '.NET Install Tool' -- it may be helpful to include more context, but people don't tend to read long error messages, so this is likely better. Might be worth PM consultant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah - I think this is already fairly long and am hesitant to increase it. cc @webreidi for thoughts.

src/main.ts Outdated Show resolved Hide resolved
@@ -39,38 +36,47 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
private hostInfo: HostExecutableInformation | undefined;

async getHostExecutableInfo(): Promise<HostExecutableInformation> {
let dotnetRuntimePath = commonOptions.dotnetPath;
Copy link
Member

@nagilson nagilson Nov 19, 2024

Choose a reason for hiding this comment

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

A breaking change document for dotnetPath should be created, IMO - though for later of course. I would also make sure this is remarked in the release notes, and that our existingPath setting is mentioned.
https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-runtime&ssr=false#overview:~:text=I%20already%20have%20a%20.NET%20Runtime%20or%20SDK%20installed%2C%20and%20I%20want%20to%20use%20it

cc @baronfel @webreidi for awareness.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't removed this in this PR - plan to in a followup. What might be an even better option is to migrate existing users of dotnet.dotnetPath to the new setting. We already do that for migrating O# options

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Looks great, thank you :) Left some thoughts.

@dibarbet
Copy link
Member Author

merging - validation looked fine (encountered only known issues that behave the same way in the current version)

@dibarbet dibarbet merged commit eb8041d into dotnet:main Nov 21, 2024
16 checks passed
@dibarbet dibarbet deleted the find_dotnet_runtime branch November 21, 2024 21:05
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.

3 participants