Skip to content

Commit a9b09e5

Browse files
committed
Merge pull request #137 from chuckries/rid
Update coreclr-debug nuget package references and dynamically generate project.json
2 parents 9e7556e + d507594 commit a9b09e5

File tree

4 files changed

+99
-34
lines changed

4 files changed

+99
-34
lines changed

coreclr-debug/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ obj
33
project.lock.json
44
debugAdapters
55
install.log
6-
extension.log
6+
extension.log
7+
project.json

coreclr-debug/project.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/coreclr-debug/main.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export function activate(context: vscode.ExtensionContext, reporter: TelemetryRe
5656
let installError = '';
5757

5858
writeInstallBeginFile().then(function() {
59+
installStage = 'writeProjectJson';
60+
return writeProjectJson();
61+
}).then(function() {
5962
installStage = 'dotnetRestore'
6063
return spawnChildProcess('dotnet', ['--verbose', 'restore', '--configfile', 'NuGet.config'], _channel, _util.coreClrDebugDir())
6164
}).then(function() {
@@ -237,6 +240,66 @@ function ensureAd7EngineExists(channel: vscode.OutputChannel, outputDirectory: s
237240
});
238241
}
239242

243+
function writeProjectJson(): Promise<void> {
244+
return new Promise<void>(function(resolve, reject) {
245+
var projectJson = createProjectJson(CoreClrDebugUtil.getPlatformRuntimeId());
246+
247+
fs.writeFile(path.join(_util.coreClrDebugDir(), 'project.json'), JSON.stringify(projectJson, null, 2), {encoding: 'utf8'}, function(err) {
248+
if (err) {
249+
reject(err.code);
250+
}
251+
else {
252+
resolve();
253+
}
254+
});
255+
});
256+
}
257+
258+
function createProjectJson(targetRuntime: string): any
259+
{
260+
let projectJson = {
261+
name: "dummy",
262+
compilationOptions: {
263+
emitEntryPoint: true
264+
},
265+
dependencies: {
266+
"Microsoft.VisualStudio.clrdbg": "14.0.25201-preview-2911579",
267+
"Microsoft.VisualStudio.clrdbg.MIEngine": "14.0.30401-preview-1",
268+
"Microsoft.VisualStudio.OpenDebugAD7": "1.0.20401-preview-1",
269+
"NETStandard.Library": "1.5.0-rc2-23931",
270+
"Newtonsoft.Json": "7.0.1",
271+
"Microsoft.VisualStudio.Debugger.Interop.Portable": "1.0.1",
272+
"System.Collections.Specialized": "4.0.1-rc2-23931",
273+
"System.Collections.Immutable": "1.2.0-rc2-23931",
274+
"System.Diagnostics.Process" : "4.1.0-rc2-23931",
275+
"System.Diagnostics.StackTrace": "4.0.1-rc2-23931",
276+
"System.Dynamic.Runtime": "4.0.11-rc2-23931",
277+
"Microsoft.CSharp": "4.0.1-rc2-23931",
278+
"System.Threading.Tasks.Dataflow": "4.6.0-rc2-23931",
279+
"System.Threading.Thread": "4.0.0-rc2-23931",
280+
"System.Xml.XDocument": "4.0.11-rc2-23931",
281+
"System.Xml.XmlDocument": "4.0.1-rc2-23931",
282+
"System.Xml.XmlSerializer": "4.0.11-rc2-23931",
283+
"System.ComponentModel": "4.0.1-rc2-23931",
284+
"System.ComponentModel.Annotations": "4.1.0-rc2-23931",
285+
"System.ComponentModel.EventBasedAsync": "4.0.11-rc2-23931",
286+
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-23931",
287+
"System.Net.Http": "4.0.1-rc2-23931"
288+
},
289+
frameworks: {
290+
"netstandardapp1.5": {
291+
imports: [ "dnxcore50", "portable-net45+win8" ]
292+
}
293+
},
294+
runtimes: {
295+
}
296+
}
297+
298+
projectJson.runtimes[targetRuntime] = {};
299+
300+
return projectJson;
301+
}
302+
240303
function spawnChildProcess(process: string, args: string[], channel: vscode.OutputChannel, workingDirectory: string) : Promise<void> {
241304
const promise = new Promise<void>(function(resolve, reject) {
242305
const child = child_process.spawn(process, args, {cwd: workingDirectory});

src/coreclr-debug/util.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import * as path from 'path';
88
import * as fs from 'fs';
99
import * as os from 'os';
10+
import * as child_process from 'child_process'
1011

1112
let _extensionDir: string = '';
1213
let _coreClrDebugDir: string = '';
@@ -111,6 +112,39 @@ export default class CoreClrDebugUtil
111112
}
112113
}
113114

115+
static getPlatformRuntimeId() : string {
116+
switch(process.platform) {
117+
case 'win32':
118+
return 'win7-x64';
119+
case 'darwin':
120+
return CoreClrDebugUtil.getDotnetRuntimeId();
121+
case 'linux':
122+
return CoreClrDebugUtil.getDotnetRuntimeId();
123+
default:
124+
throw Error('Unsupported platform ' + process.platform);
125+
}
126+
}
127+
128+
static getDotnetRuntimeId() : string {
129+
let out = child_process.execSync('dotnet --info').toString();
130+
131+
let lines = out.split('\n');
132+
let ridLine = lines.filter(function(value) {
133+
return value.trim().startsWith('RID');
134+
});
135+
136+
if (ridLine.length < 1) {
137+
throw new Error('Cannot obtain Runtime ID from dotnet cli');
138+
}
139+
140+
let rid = ridLine[0].split(':')[1].trim();
141+
142+
if (!rid) {
143+
throw new Error('Unable to determine Runtime ID');
144+
}
145+
146+
return rid;
147+
}
114148

115149
/** Used for diagnostics only */
116150
logToFile(message: string): void {

0 commit comments

Comments
 (0)