diff --git a/src/coreclr-debug/activate.ts b/src/coreclr-debug/activate.ts index df401ad9be..92240c48dd 100644 --- a/src/coreclr-debug/activate.ts +++ b/src/coreclr-debug/activate.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import * as os from 'os'; import * as path from 'path'; import * as vscode from 'vscode'; import * as common from './../common'; @@ -23,42 +22,55 @@ export async function activate(thisExtension : vscode.Extension, context: v _logger = logger; if (!CoreClrDebugUtil.existsSync(_debugUtil.debugAdapterDir())) { - let platformInformation: PlatformInformation; - - try { - platformInformation = await PlatformInformation.GetCurrent(); - } - catch (err) { - // Somehow we couldn't figure out the platform we are on - logger.appendLine("[ERROR]: C# Extension failed to install the debugger package"); + let isInvalidArchitecture: boolean = await checkForInvalidArchitecture(logger); + if (!isInvalidArchitecture) { + logger.appendLine("[ERROR]: C# Extension failed to install the debugger package."); showInstallErrorMessage(channel); } + } else if (!CoreClrDebugUtil.existsSync(_debugUtil.installCompleteFilePath())) { + completeDebuggerInstall(logger, channel); + } +} + +async function checkForInvalidArchitecture(logger: Logger): Promise { + let platformInformation: PlatformInformation; - if (platformInformation) { - if (platformInformation.architecture !== "x86_64") { - if (platformInformation.isWindows() && platformInformation.architecture === "x86") { - logger.appendLine(`[WARNING]: x86 Windows is not currently supported by the .NET Core debugger. Debugging will not be available.`); - } else { - logger.appendLine(`[WARNING]: Processor architecture '${platformInformation.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`); - } + try { + platformInformation = await PlatformInformation.GetCurrent(); + } + catch (err) { + // Somehow we couldn't figure out the platform we are on + logger.appendLine("[ERROR] The debugger cannot be installed. Could not determine current platform."); + return true; + } + + if (platformInformation) { + if (platformInformation.isMacOS() && !CoreClrDebugUtil.isMacOSSupported()) { + logger.appendLine("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."); + return true; + } + else if (platformInformation.architecture !== "x86_64") { + if (platformInformation.isWindows() && platformInformation.architecture === "x86") { + logger.appendLine(`[WARNING]: x86 Windows is not currently supported by the .NET Core debugger. Debugging will not be available.`); } else { - logger.appendLine("[ERROR]: C# Extension failed to install the debugger package"); - showInstallErrorMessage(channel); + logger.appendLine(`[WARNING]: Processor architecture '${platformInformation.architecture}' is not currently supported by the .NET Core debugger. Debugging will not be available.`); } + return true; } - } else if (!CoreClrDebugUtil.existsSync(_debugUtil.installCompleteFilePath())) { - completeDebuggerInstall(logger, channel); } + + return false; } async function completeDebuggerInstall(logger: Logger, channel: vscode.OutputChannel) : Promise { return _debugUtil.checkDotNetCli() - .then((dotnetInfo: DotnetInfo) => { + .then(async (dotnetInfo: DotnetInfo) => { + + let isInvalidArchitecture: boolean = await checkForInvalidArchitecture(logger); - if (os.platform() === "darwin" && !CoreClrDebugUtil.isMacOSSupported()) { - logger.appendLine("[ERROR] The debugger cannot be installed. The debugger requires macOS 10.12 (Sierra) or newer."); + if (isInvalidArchitecture) { channel.show(); - + vscode.window.showErrorMessage('Failed to complete the installation of the C# extension. Please see the error in the output window below.'); return false; } @@ -123,15 +135,14 @@ export async function getAdapterExecutionCommand(channel: vscode.OutputChannel): let util = new CoreClrDebugUtil(common.getExtensionPath(), logger); // Check for .debugger folder. Handle if it does not exist. - if (!CoreClrDebugUtil.existsSync(util.debugAdapterDir())) - { + if (!CoreClrDebugUtil.existsSync(util.debugAdapterDir())) { // our install.complete file does not exist yet, meaning we have not completed the installation. Try to figure out what if anything the package manager is doing // the order in which files are dealt with is this: // 1. install.Begin is created // 2. install.Lock is created // 3. install.Begin is deleted // 4. install.complete is created - + // install.Lock does not exist, need to wait for packages to finish downloading. let installLock: boolean = await common.installFileExists(common.InstallFileType.Lock); if (!installLock) { @@ -142,15 +153,14 @@ export async function getAdapterExecutionCommand(channel: vscode.OutputChannel): else if (!CoreClrDebugUtil.existsSync(util.installCompleteFilePath())) { let success: boolean = await completeDebuggerInstall(logger, channel); - if (!success) - { + if (!success) { channel.show(); throw new Error('Failed to complete the installation of the C# extension. Please see the error in the output window below.'); } } } - // debugger has finished install, kick off our debugger process + // debugger has finished installation, kick off our debugger process return { command: path.join(common.getExtensionPath(), ".debugger", "vsdbg-ui" + CoreClrDebugUtil.getPlatformExeExtension()) };