Skip to content
Merged
Show file tree
Hide file tree
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
Binary file added images/csharpIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"name": "csharp",
"publisher": "ms-vscode",
"version": "0.3.6",
"version": "0.3.8",
"description": "C# for Visual Studio Code (powered by OmniSharp).",
"displayName": "C#",
"author": "Microsoft Corporation",
"license": "SEE LICENSE IN RuntimeLicenses/license.txt",
"icon": "images/csharpIcon.png",
"categories": [
"Debuggers",
"Languages",
"Linters",
"Snippets"
],
"main": "./out/omnisharpMain",
"scripts": {
"postinstall": "gulp omnisharp && tsc"
},
"dependencies": {
"run-in-terminal": "*",
"semver": "*"
"semver": "*",
"vscode-extension-telemetry": "0.0.4"
},
"devDependencies": {
"vscode": "^0.10.1",
Expand Down
44 changes: 39 additions & 5 deletions src/coreclr-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import * as vscode from 'vscode';
import * as child_process from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import TelemetryReporter from 'vscode-extension-telemetry';

let _coreClrDebugDir: string;
let _debugAdapterDir: string;
let _channel: vscode.OutputChannel;
let _installLog: NodeJS.WritableStream;
let _reporter: TelemetryReporter; // Telemetry reporter
const _completionFileName: string = 'install.complete';

export function installCoreClrDebug(context: vscode.ExtensionContext) {
export function installCoreClrDebug(context: vscode.ExtensionContext) {
_coreClrDebugDir = path.join(context.extensionPath, 'coreclr-debug');
_debugAdapterDir = path.join(_coreClrDebugDir, 'debugAdapters');

Expand All @@ -30,6 +32,7 @@ export function installCoreClrDebug(context: vscode.ExtensionContext) {
return;
}

initializeTelemetry(context);
_channel = vscode.window.createOutputChannel('coreclr-debug');

// Create our log file and override _channel.append to also outpu to the log
Expand All @@ -45,34 +48,65 @@ export function installCoreClrDebug(context: vscode.ExtensionContext) {
_channel.appendLine("Downloading and configuring the .NET Core Debugger...");
_channel.show(vscode.ViewColumn.Three);

var installStage = 'dotnet restore';
var installError = '';

spawnChildProcess('dotnet', ['--verbose', 'restore', '--configfile', 'NuGet.config'], _channel, _coreClrDebugDir)
.then(function() {
installStage = "dotnet publish";
return spawnChildProcess('dotnet', ['--verbose', 'publish', '-o', _debugAdapterDir], _channel, _coreClrDebugDir);
}).then(function() {
installStage = "ensureAd7";
return ensureAd7EngineExists(_channel, _debugAdapterDir);
}).then(function() {
installStage = "additionalTasks"
var promises: Promise<void>[] = [];

promises.push(renameDummyEntrypoint());
promises.push(removeLibCoreClrTraceProvider());

return Promise.all(promises);
}).then(function() {
installStage = "writeCompletionFile";
return writeCompletionFile();
}).then(function() {
installStage = "completeSuccess";
_channel.appendLine('Succesfully installed .NET Core Debugger.');
})
.catch(function(error) {
_channel.appendLine('Error while installing .NET Core Debugger.');

installError = error.toString();
console.log(error);
}).then(function() {
// log telemetry
logTelemetry('Acquisition', {installStage: installStage, installError: installError});
});
}

function initializeTelemetry(context: vscode.ExtensionContext) {
// parse our own package.json into json
var packageJson = JSON.parse(fs.readFileSync(path.join(context.extensionPath, 'package.json')).toString());

let extensionId = packageJson["publisher"] + "." + packageJson["name"];
let extensionVersion = packageJson["version"];
let aiKey = packageJson.contributes.debuggers[0]["aiKey"];

_reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
}

function logTelemetry(eventName: string, properties?: {[prop: string]: string}) {
if (_reporter)
{
_reporter.sendTelemetryEvent('coreclr-debug/' + eventName, properties);
}
}

function writeCompletionFile() : Promise<void> {
return new Promise<void>(function(resolve, reject) {
fs.writeFile(path.join(_debugAdapterDir, _completionFileName), '', function(err) {
if (err) {
reject(err);
reject(err.code);
}
else {
resolve();
Expand All @@ -91,7 +125,7 @@ function renameDummyEntrypoint() : Promise<void> {
var promise = new Promise<void>(function(resolve, reject) {
fs.rename(src, dest, function(err) {
if (err) {
reject(err);
reject(err.code);
} else {
resolve();
}
Expand All @@ -111,7 +145,7 @@ function removeLibCoreClrTraceProvider() : Promise<void>
return new Promise<void>(function(resolve, reject) {
fs.unlink(filePath, function(err) {
if (err) {
reject(err);
reject(err.code);
} else {
_channel.appendLine('Succesfully deleted ' + filePath);
resolve();
Expand All @@ -129,7 +163,7 @@ function existsSync(path: string) : boolean {
if (err.code === 'ENOENT') {
return false;
} else {
throw err;
throw Error(err.code);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/typings/vscode-extension-telemetry.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'vscode-extension-telemetry' {
export default class TelemetryReporter {
constructor(extensionId: string,extensionVersion: string, key: string);
sendTelemetryEvent(eventName: string, properties?: { [key: string]: string }, measures?: { [key: string]: number }): void;
}
}