Skip to content

Commit 88c95b4

Browse files
committed
Merged PR 475808: Use environment DOTNET_ROOT for DebugAdapterExe
Use environment DOTNET_ROOT for DebugAdapterExe This PR updates the DOTNET_ROOT variable for vsdbg/vsdbg-ui if it is set in the environment. It will prioritize using the environment variable DOTNET_ROOT over the dotnet CliPath option for omnisharp. This PR also changes not passing DOTNET_ROOT if either of those are empty. Related work items: #1825824
1 parent ff7c76d commit 88c95b4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/coreclr-debug/activate.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,20 @@ export class DebugAdapterExecutableFactory implements vscode.DebugAdapterDescrip
203203
const dotNetInfo = await getDotnetInfo(this.options.omnisharpOptions.dotNetCliPaths);
204204
const targetArchitecture = getTargetArchitecture(this.platformInfo, _session.configuration.targetArchitecture, dotNetInfo);
205205
const command = path.join(common.getExtensionPath(), ".debugger", targetArchitecture, "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension());
206-
executable = new vscode.DebugAdapterExecutable(command, [], {
207-
env: {
208-
DOTNET_ROOT: dotNetInfo.CliPath ? path.dirname(dotNetInfo.CliPath) : '',
209-
}
210-
});
206+
207+
// Look to see if DOTNET_ROOT is set, then use dotnet cli path
208+
let dotnetRoot: string = process.env.DOTNET_ROOT ?? (dotNetInfo.CliPath ? path.dirname(dotNetInfo.CliPath) : '');
209+
210+
let options: vscode.DebugAdapterExecutableOptions | undefined = undefined;
211+
if (dotnetRoot) {
212+
options = {
213+
env: {
214+
DOTNET_ROOT: dotnetRoot,
215+
}
216+
};
217+
}
218+
219+
executable = new vscode.DebugAdapterExecutable(command, [], options);
211220
}
212221

213222
// make VS Code launch the DA executable

0 commit comments

Comments
 (0)