Skip to content

Commit fdf45c9

Browse files
committed
Preserve the tasks & configuration while adding .net specific ones
1 parent 81c6e32 commit fdf45c9

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/assets.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,16 @@ export function addTasksJsonIfNecessary(generator: AssetGenerator, operations: O
419419
return resolve();
420420
}
421421

422+
// Read existing Tasks configuration
423+
const tasksConfigs = vscode.workspace.getConfiguration('tasks');
424+
let existingTaskConfigs = tasksConfigs.get<Array<tasks.TaskDescription>>('tasks');
422425
const tasksJson = generator.createTasksConfiguration();
423-
const tasksJsonText = JSON.stringify(tasksJson, null, ' ');
424426

427+
if (existingTaskConfigs) {
428+
tasksJson['tasks'] = tasksJson['tasks'].concat(existingTaskConfigs);
429+
}
430+
431+
const tasksJsonText = JSON.stringify(tasksJson, null, ' ');
425432
fs.writeFile(generator.tasksJsonPath, tasksJsonText, err => {
426433
if (err) {
427434
return reject(err);
@@ -442,11 +449,21 @@ function addLaunchJsonIfNecessary(generator: AssetGenerator, operations: Operati
442449
return resolve();
443450
}
444451

452+
// Read existing launch configuration
453+
const launchConfigs = vscode.workspace.getConfiguration('launch');
454+
let existingLaunchConfigs = launchConfigs.get<{}[]>('configurations');
455+
445456
const isWebProject = generator.hasWebServerDependency();
446-
const launchJson: string = generator.createLaunchJson(isWebProject);
457+
let launchJson: string = generator.createLaunchJson(isWebProject);
447458

448-
const configurationsMassaged: string = indentJsonString(launchJson);
459+
if (existingLaunchConfigs) {
460+
launchJson = launchJson.substring(0, launchJson.length-1);
461+
let existingLaunchConfigsString = JSON.stringify(existingLaunchConfigs, null, ' ');
462+
existingLaunchConfigsString = existingLaunchConfigsString.substring(1, existingLaunchConfigsString.length-1);
463+
launchJson = `${launchJson},${existingLaunchConfigsString}]`;
464+
}
449465

466+
const configurationsMassaged: string = indentJsonString(launchJson);
450467
const launchJsonText = `
451468
{
452469
// Use IntelliSense to find out which attributes exist for C# debugging

0 commit comments

Comments
 (0)