I am developing a vscode extension and I would like to launch a debug session from the extension. In my launch.json I have defined two separate launch configurations, (Debug Configuration A, Debug Configuration B)
Is there anyway to launch a specific configuration from an extension?
From the extension I am able to call the following command, but this opens a quickpick to specify the configuration and I don't want that:
await vscode.commands.executeCommand('workbench.action.debug.start');
I would like some kind of command like this,
await vscode.commands.executeCommand('workbench.action.debug.start', 'Debug Configuration A');
Here is a somewhat relevant PR, but this doesn't allow me to specify the exact launch configuration I want and still brings up a quickpick https://github.com/microsoft/vscode/pull/193156
I managed to solve it by doing something like this:
export function getLaunchConfigurations() {
let rootPath = getRootPath();
if (rootPath) {
const config = vscode.workspace.getConfiguration("launch", rootPath);
const configurations = config.get<any[]>("configurations");
return configurations;
}
}
export function getLaunchConfigurationByName(configName: string) {
let configurations = getLaunchConfigurations();
if (!configurations) {
return;
}
for (var config of configurations) {
if (config.name === configName) {
return config;
}
}
}
let debugConfig = getLaunchConfigurationByName(debugTarget);
if (debugConfig) {
await vscode.commands.executeCommand('debug.startFromConfig', debugConfig);
}