Skip to content

Commit 2aa29a9

Browse files
committed
Allow preLaunch task for compound list
fixes microsoft#45676
1 parent 4d71eba commit 2aa29a9

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/vs/workbench/contrib/debug/browser/debugService.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ export class DebugService implements IDebugService {
289289
throw new Error(nls.localize({ key: 'compoundMustHaveConfigurations', comment: ['compound indicates a "compounds" configuration item', '"configurations" is an attribute and should not be localized'] },
290290
"Compound must have \"configurations\" attribute set in order to start multiple configurations."));
291291
}
292+
if (compound.preLaunchTask) {
293+
const taskResult = await this.runTaskAndCheckErrors(launch?.workspace || this.contextService.getWorkspace(), compound.preLaunchTask);
294+
if (taskResult === TaskRunResult.Failure) {
295+
this.endInitializingState();
296+
return false;
297+
}
298+
}
292299

293300
const values = await Promise.all(compound.configurations.map(configData => {
294301
const name = typeof configData === 'string' ? configData : configData.name;
@@ -394,10 +401,10 @@ export class DebugService implements IDebugService {
394401
return false;
395402
}
396403

397-
const workspace = launch ? launch.workspace : undefined;
404+
const workspace = launch ? launch.workspace : this.contextService.getWorkspace();
398405
const taskResult = await this.runTaskAndCheckErrors(workspace, resolvedConfig.preLaunchTask);
399406
if (taskResult === TaskRunResult.Success) {
400-
return this.doCreateSession(workspace, { resolved: resolvedConfig, unresolved: unresolvedConfig }, options);
407+
return this.doCreateSession(launch?.workspace, { resolved: resolvedConfig, unresolved: unresolvedConfig }, options);
401408
}
402409
return false;
403410
} catch (err) {
@@ -701,7 +708,7 @@ export class DebugService implements IDebugService {
701708

702709
//---- task management
703710

704-
private async runTaskAndCheckErrors(root: IWorkspaceFolder | undefined, taskId: string | TaskIdentifier | undefined): Promise<TaskRunResult> {
711+
private async runTaskAndCheckErrors(root: IWorkspaceFolder | IWorkspace | undefined, taskId: string | TaskIdentifier | undefined): Promise<TaskRunResult> {
705712
try {
706713
const taskSummary = await this.runTask(root, taskId);
707714

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ export interface IConfig extends IEnvConfig {
505505

506506
export interface ICompound {
507507
name: string;
508+
preLaunchTask?: string | TaskIdentifier;
508509
configurations: (string | { name: string, folder: string })[];
509510
}
510511

src/vs/workbench/contrib/debug/common/debugSchemas.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ export const launchSchema: IJSONSchema = {
190190
}]
191191
},
192192
description: nls.localize('app.launch.json.compounds.configurations', "Names of configurations that will be started as part of this compound.")
193+
},
194+
preLaunchTask: {
195+
type: 'string',
196+
default: '',
197+
description: nls.localize('compoundPrelaunchTask', "Task to run before any of the compound configurations start.")
193198
}
194199
},
195200
default: defaultCompound

0 commit comments

Comments
 (0)