|
2 | 2 | * Copyright (c) Microsoft Corporation. All rights reserved. |
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | | - |
6 | 5 | import * as vscode from 'vscode'; |
7 | 6 | import * as vscodeapi from 'vscode'; |
8 | 7 | import { ExtensionContext } from 'vscode'; |
@@ -50,6 +49,7 @@ import { PlatformInformation } from '../../shared/platform'; |
50 | 49 | import { RazorLanguageServerOptions } from './razorLanguageServerOptions'; |
51 | 50 | import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver'; |
52 | 51 | import { RazorFormatNewFileHandler } from './formatNewFile/razorFormatNewFileHandler'; |
| 52 | +import * as path from "path"; |
53 | 53 |
|
54 | 54 | // We specifically need to take a reference to a particular instance of the vscode namespace, |
55 | 55 | // otherwise providers attempt to operate on the null extension. |
@@ -86,6 +86,15 @@ export async function activate( |
86 | 86 | ); |
87 | 87 |
|
88 | 88 | const dotnetInfo = await hostExecutableResolver.getHostExecutableInfo(); |
| 89 | + const dotnetRuntimePath = path.dirname(dotnetInfo.path); |
| 90 | + |
| 91 | + // Take care to always run .NET processes on the runtime that we intend. |
| 92 | + // The dotnet.exe we point to should not go looking for other runtimes. |
| 93 | + const env: NodeJS.ProcessEnv = { ...process.env }; |
| 94 | + env.DOTNET_ROOT = dotnetRuntimePath; |
| 95 | + env.DOTNET_MULTILEVEL_LOOKUP = '0'; |
| 96 | + // Save user's DOTNET_ROOT env-var value so server can recover the user setting when needed |
| 97 | + env.DOTNET_ROOT_USER = process.env.DOTNET_ROOT ?? 'EMPTY'; |
89 | 98 |
|
90 | 99 | // Set up DevKit environment for telemetry |
91 | 100 | if (csharpDevkitExtension) { |
|
0 commit comments