Skip to content

Commit a5d03fb

Browse files
committed
Find Locally Managed Runtimes
This was implemented but then backed out for release in dotnet#2302. This includes one fix which is to respect DOTNET_ROOT over the locally installed runtimes. Users who set DOTNET_ROOT typically have an explicit scenario that they want. This was backed out because we need to do auto update of the local installed runtimes for this feature to be compatible with the API shape of keeping customers secure. We will do that in this release.
1 parent f4fd370 commit a5d03fb

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

vscode-dotnet-runtime-extension/src/extension.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,21 @@ export function activate(vsCodeContext: vscode.ExtensionContext, extensionContex
569569
return { dotnetPath: validatedRoot };
570570
}
571571

572+
if (commandContext.acquireContext.mode === 'runtime' || commandContext.acquireContext.mode === 'aspnetcore')
573+
{
574+
const extensionManagedRuntimeRecordPaths = await finder.findExtensionManagedRuntimes();
575+
const filteredExtensionManagedRuntimeRecordPaths = validator.filterValidPaths(extensionManagedRuntimeRecordPaths, commandContext);
576+
for (const dotnetPath of filteredExtensionManagedRuntimeRecordPaths ?? [])
577+
{
578+
const validatedExistingManagedPath = await getPathIfValid(dotnetPath.path, validator, commandContext);
579+
if (validatedExistingManagedPath)
580+
{
581+
loggingObserver.dispose();
582+
return { dotnetPath: dotnetPath.path };
583+
}
584+
}
585+
}
586+
572587
const dotnetOnHostfxrRecord = await finder.findHostInstallPaths(commandContext.acquireContext.architecture);
573588
for (const dotnetPath of dotnetOnHostfxrRecord ?? [])
574589
{

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ suite('DotnetCoreAcquisitionExtension End to End', function ()
447447
}
448448
}).timeout(standardTimeoutTime);
449449

450-
test('Find dotnet PATH Command does not work with extension-managed runtime installations', async () =>
450+
test('Find dotnet PATH Command does work with extension-managed runtime installations', async () =>
451451
{
452452
// First install a runtime that we'll try to find
453453
const version = '7.0';
@@ -474,7 +474,9 @@ suite('DotnetCoreAcquisitionExtension End to End', function ()
474474

475475
// Then verify we can find the extension-managed runtime
476476
const result = await vscode.commands.executeCommand<IDotnetAcquireResult>('dotnet.findPath', findPathContext);
477-
assert.notExists(result, 'Should find a runtime');
477+
assert.exists(result, 'Should find a runtime');
478+
assert.exists(result!.dotnetPath, 'Should find a runtime path');
479+
assert.equal(result!.dotnetPath.toLowerCase(), runtimePath.toLowerCase(), 'Should find the correct runtime path');
478480
}
479481
finally
480482
{

0 commit comments

Comments
 (0)