import { commands } from 'vscode' ; import { callWithTelemetryAndErrorHandling , IActionContext , parseError } from 'vscode-azureextensionui' ; import { ext } from '../extensionVariables' ; import { wrapError } from '../util/wrapError' ; interface IDotnetAcquireResult { dotnetPath : string ; } export async function acquireSharedDotnetInstallation ( version ) { return await callWithTelemetryAndErrorHandling ( 'acquireSharedDotnet' , async ( actionContext ) => { actionContext . errorHandling . suppressDisplay = true ; actionContext . errorHandling . rethrow = false ; let message ; let result ; let dotnetPath ; try { result = await commands . executeCommand < IDotnetAcquireResult > ( 'dotnet.acquire' , { version , requestingExtensionId : ext . extensionId } ) ; } catch ( err ) { message = parseError ( err ) . message ; } actionContext . telemetry . properties . dotnetAcquireResult = result ?. dotnetPath ? 'path returned' : 'undefined' ; if ( ! message ) { if ( ! result ) { message = "dotnet.acquire failed" ; } else { dotnetPath = result . dotnetPath ; if ( ! dotnetPath ) { message = "dotnet.acquire returned an undefined dotnetPath" ; } } } if ( message ) { const linkMessage = `This extension requires .NET Core for full functionality, but we were unable to download and install a local copy for the extension. If this error persists, please see https://aka.ms/vscode-armtools-dotnet for troubleshooting tips.` ; const err = wrapError ( linkMessage , `Details: ${ message }` ) ; ext . outputChannel . appendLog ( parseError ( err ) . message ) ; ext . outputChannel . appendLog ( `See '.NET Runtime' in the output window for more information.` ) ; ext . outputChannel . show ( ) ; actionContext . telemetry . properties . dotnetAcquireError = message ; throw err ; } return dotnetPath ; } ) ; }