Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions src/coreclr-debug/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -23,42 +22,55 @@ export async function activate(thisExtension : vscode.Extension<any>, context: v
_logger = logger;

if (!CoreClrDebugUtil.existsSync(_debugUtil.debugAdapterDir())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should probably just delete this check all together and move both checks into completeDebuggerInstall.

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<boolean> {
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<boolean> {
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;
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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())
};
Expand Down