@@ -8,17 +8,18 @@ import * as vscode from 'vscode';
88import * as child_process from 'child_process' ;
99import * as fs from 'fs' ;
1010import * as path from 'path' ;
11- import * as util from './util' ;
1211import TelemetryReporter from 'vscode-extension-telemetry' ;
12+ import CoreClrDebugUtil from './util'
1313
1414let _channel : vscode . OutputChannel ;
1515let _installLog : NodeJS . WritableStream ;
1616let _reporter : TelemetryReporter ; // Telemetry reporter
17+ let _util : CoreClrDebugUtil ;
1718
1819export function activate ( context : vscode . ExtensionContext , reporter : TelemetryReporter ) {
19- util . setExtensionDir ( context . extensionPath ) ;
20+ _util = new CoreClrDebugUtil ( context . extensionPath ) ;
2021
21- if ( util . installCompleteExists ( ) ) {
22+ if ( CoreClrDebugUtil . existsSync ( _util . installCompleteFilePath ( ) ) ) {
2223 console . log ( '.NET Core Debugger tools already installed' ) ;
2324 return ;
2425 }
@@ -40,7 +41,7 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
4041 _channel = vscode . window . createOutputChannel ( 'coreclr-debug' ) ;
4142
4243 // Create our log file and override _channel.append to also output to the log
43- _installLog = fs . createWriteStream ( util . installLogPath ( ) ) ;
44+ _installLog = fs . createWriteStream ( _util . installLogPath ( ) ) ;
4445 ( function ( ) {
4546 let proxied = _channel . append ;
4647 _channel . append = function ( val : string ) {
@@ -56,13 +57,13 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
5657
5758 writeInstallBeginFile ( ) . then ( function ( ) {
5859 installStage = 'dotnetRestore'
59- return spawnChildProcess ( 'dotnet' , [ '--verbose' , 'restore' , '--configfile' , 'NuGet.config' ] , _channel , util . coreClrDebugDir ( ) )
60+ return spawnChildProcess ( 'dotnet' , [ '--verbose' , 'restore' , '--configfile' , 'NuGet.config' ] , _channel , _util . coreClrDebugDir ( ) )
6061 } ) . then ( function ( ) {
6162 installStage = "dotnetPublish" ;
62- return spawnChildProcess ( 'dotnet' , [ '--verbose' , 'publish' , '-o' , util . debugAdapterDir ( ) ] , _channel , util . coreClrDebugDir ( ) ) ;
63+ return spawnChildProcess ( 'dotnet' , [ '--verbose' , 'publish' , '-o' , _util . debugAdapterDir ( ) ] , _channel , _util . coreClrDebugDir ( ) ) ;
6364 } ) . then ( function ( ) {
6465 installStage = "ensureAd7" ;
65- return ensureAd7EngineExists ( _channel , util . debugAdapterDir ( ) ) ;
66+ return ensureAd7EngineExists ( _channel , _util . debugAdapterDir ( ) ) ;
6667 } ) . then ( function ( ) {
6768 installStage = "additionalTasks" ;
6869 let promises : Promise < void > [ ] = [ ] ;
@@ -113,27 +114,27 @@ function logTelemetry(eventName: string, properties?: {[prop: string]: string})
113114}
114115
115116function rewriteManifest ( ) : void {
116- const manifestPath = path . join ( util . extensionDir ( ) , 'package.json' ) ;
117+ const manifestPath = path . join ( _util . extensionDir ( ) , 'package.json' ) ;
117118 let manifestString = fs . readFileSync ( manifestPath , 'utf8' ) ;
118119 let manifestObject = JSON . parse ( manifestString ) ;
119120 manifestObject . contributes . debuggers [ 0 ] . runtime = '' ;
120- manifestObject . contributes . debuggers [ 0 ] . program = './coreclr-debug/debugAdapters/OpenDebugAD7' + util . getPlatformExeExtension ( ) ;
121+ manifestObject . contributes . debuggers [ 0 ] . program = './coreclr-debug/debugAdapters/OpenDebugAD7' + CoreClrDebugUtil . getPlatformExeExtension ( ) ;
121122 manifestString = JSON . stringify ( manifestObject , null , 2 ) ;
122123 fs . writeFileSync ( manifestPath , manifestString ) ;
123124}
124125
125126function writeInstallBeginFile ( ) : Promise < void > {
126- return writeEmptyFile ( util . installBeginFilePath ( ) ) ;
127+ return writeEmptyFile ( _util . installBeginFilePath ( ) ) ;
127128}
128129
129130function deleteInstallBeginFile ( ) {
130- if ( util . existsSync ( util . installBeginFilePath ( ) ) ) {
131- fs . unlinkSync ( util . installBeginFilePath ( ) ) ;
131+ if ( CoreClrDebugUtil . existsSync ( _util . installBeginFilePath ( ) ) ) {
132+ fs . unlinkSync ( _util . installBeginFilePath ( ) ) ;
132133 }
133134}
134135
135136function writeCompletionFile ( ) : Promise < void > {
136- return writeEmptyFile ( util . installCompleteFilePath ( ) ) ;
137+ return writeEmptyFile ( _util . installCompleteFilePath ( ) ) ;
137138}
138139
139140function writeEmptyFile ( path : string ) : Promise < void > {
@@ -149,11 +150,11 @@ function writeEmptyFile(path: string) : Promise<void> {
149150}
150151
151152function renameDummyEntrypoint ( ) : Promise < void > {
152- let src = path . join ( util . debugAdapterDir ( ) , 'dummy' ) ;
153- let dest = path . join ( util . debugAdapterDir ( ) , 'OpenDebugAD7' ) ;
153+ let src = path . join ( _util . debugAdapterDir ( ) , 'dummy' ) ;
154+ let dest = path . join ( _util . debugAdapterDir ( ) , 'OpenDebugAD7' ) ;
154155
155- src += util . getPlatformExeExtension ( ) ;
156- dest += util . getPlatformExeExtension ( ) ;
156+ src += CoreClrDebugUtil . getPlatformExeExtension ( ) ;
157+ dest += CoreClrDebugUtil . getPlatformExeExtension ( ) ;
157158
158159 const promise = new Promise < void > ( function ( resolve , reject ) {
159160 fs . rename ( src , dest , function ( err ) {
@@ -170,9 +171,9 @@ function renameDummyEntrypoint() : Promise<void> {
170171
171172function removeLibCoreClrTraceProvider ( ) : Promise < void >
172173{
173- const filePath = path . join ( util . debugAdapterDir ( ) , 'libcoreclrtraceptprovider' + util . getPlatformLibExtension ( ) ) ;
174+ const filePath = path . join ( _util . debugAdapterDir ( ) , 'libcoreclrtraceptprovider' + CoreClrDebugUtil . getPlatformLibExtension ( ) ) ;
174175
175- if ( ! util . existsSync ( filePath ) ) {
176+ if ( ! CoreClrDebugUtil . existsSync ( filePath ) ) {
176177 return Promise . resolve ( ) ;
177178 } else {
178179 return new Promise < void > ( function ( resolve , reject ) {
@@ -209,7 +210,7 @@ function isOnPath(command : string) : boolean {
209210 }
210211
211212 const segmentPath = path . join ( segment , fileName ) ;
212- if ( util . existsSync ( segmentPath ) ) {
213+ if ( CoreClrDebugUtil . existsSync ( segmentPath ) ) {
213214 return true ;
214215 }
215216 }
0 commit comments