@@ -45,6 +45,7 @@ import { installRuntimeDependencies } from './InstallRuntimeDependencies';
4545import { isValidDownload } from './packageManager/isValidDownload' ;
4646import { BackgroundWorkStatusBarObserver } from './observers/BackgroundWorkStatusBarObserver' ;
4747import { getDecompilationAuthorization } from './omnisharp/decompilationPrompt' ;
48+ import { getDotnetPackApi } from './DotNetPack' ;
4849
4950export async function activate ( context : vscode . ExtensionContext ) : Promise < CSharpExtensionExports > {
5051
@@ -148,7 +149,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
148149 return null ;
149150 }
150151
151- await tryAddDotNetToPath ( ) ;
152+ // If the dotnet bundle is installed, this will ensure the dotnet CLI is on the path.
153+ await initializeDotnetPath ( ) ;
152154
153155 let telemetryObserver = new TelemetryObserver ( platformInfo , ( ) => reporter ) ;
154156 eventStream . subscribe ( telemetryObserver . post ) ;
@@ -229,24 +231,10 @@ async function ensureRuntimeDependencies(extension: vscode.Extension<CSharpExten
229231 return installRuntimeDependencies ( extension . packageJSON , extension . extensionPath , installDependencies , eventStream , platformInfo ) ;
230232}
231233
232- async function tryAddDotNetToPath ( ) {
233- const sdkExtension = vscode . extensions . getExtension ( "ms-dotnettools.vscode-dotnet-pack" ) ;
234- if ( sdkExtension ) {
235- try {
236- if ( ! sdkExtension . isActive ) {
237- await sdkExtension . activate ( ) ;
238- }
239-
240- // Invoking acquireStatus updates the process.env.PATH with the folder that contains the dotnet cli.
241- // This will allow child processes such as OmniSharp to use the dotnet cli.
242- const request = { version : '5.0' , requestingExtensionId : 'ms-dotnettools.csharp' } ;
243- const statusResult = await vscode . commands . executeCommand < { dotnetPath : string } > ( 'dotnet-sdk.acquireStatus' , request ) ;
244-
245- return statusResult . dotnetPath ?. length > 0 ;
246- }
247- catch {
248- }
234+ async function initializeDotnetPath ( ) {
235+ const dotnetPackApi = await getDotnetPackApi ( ) ;
236+ if ( ! dotnetPackApi ) {
237+ return null ;
249238 }
250-
251- return false ;
239+ return await dotnetPackApi . getDotnetPath ( ) ;
252240}
0 commit comments