Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions vscode-dotnet-runtime-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,17 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
const validator = new DotnetConditionValidator(workerContext, utilContext);
const finder = new DotnetPathFinder(workerContext, utilContext);

const dotnetOnShellSpawn = (await finder.findDotnetFastFromListOnly())?.[0] ?? '';
if (dotnetOnShellSpawn)
{
const validatedShellSpawn = await getPathIfValid(dotnetOnShellSpawn, validator, commandContext);
if (validatedShellSpawn)
{
loggingObserver.dispose();
return { dotnetPath: validatedShellSpawn };
}
}

const dotnetsOnPATH = await finder.findRawPathEnvironmentSetting();
for (const dotnetPath of dotnetsOnPATH ?? [])
{
Expand Down
13 changes: 13 additions & 0 deletions vscode-dotnet-runtime-library/src/Acquisition/DotnetPathFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ export class DotnetPathFinder implements IDotnetPathFinder
return undefined;
}

/**
* @remarks This only checks dotnet --list-runtimes or --list-sdks, so it can be more performant for the base case.
* This allows skipping which, where, and also does not rely on --info which is slower because it shells to the SDK instead of just being the host.
* @returns The path to the dotnet executable, which may be a symlink to the actual executable.
*/
public async findDotnetFastFromListOnly(): Promise<string[] | undefined>
{
const oldLookup = process.env.DOTNET_MULTILEVEL_LOOKUP;
process.env.DOTNET_MULTILEVEL_LOOKUP = '0'; // make it so --list-runtimes only finds the runtimes on that path: https://learn.microsoft.com/en-us/dotnet/core/compatibility/deployment/7.0/multilevel-lookup#reason-for-change
const finalPath = await this.getTruePath(['dotnet']);
return this.returnWithRestoringEnvironment(finalPath, 'DOTNET_MULTILEVEL_LOOKUP', oldLookup);
}

/**
*
* @returns A set of the path environment variable(s) for which or where dotnet, which may need to be converted to the actual path if it points to a polymorphic executable.
Expand Down