diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a68e59b..7b8ca6fa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Bug Fixes: - CMake Tools should choose cmake.exe from the newest VS when it's not found in the PATH. [#2753](https://github.com/microsoft/vscode-cmake-tools/issues/2753) - Calling build targets from CMake Project Outline always builds default target if useTasks option is set. [#2778](https://github.com/microsoft/vscode-cmake-tools/issues/2768) [@piomis]](https://github.com/piomis) - Remove the default path for `cmake.mingwSearchDirs` since the path is world-writable. [PR #2942](https://github.com/microsoft/vscode-cmake-tools/pull/2942) +- Build command is not able to properly pick-up tasks from tasks.json file if configured with isDefault option and cancellation of running build task is not working. [#2935](https://github.com/microsoft/vscode-cmake-tools/issues/2935) [@piomis]](https://github.com/piomis) ## 1.12.27 Bug Fixes: diff --git a/src/cmakeBuildRunner.ts b/src/cmakeBuildRunner.ts index 7f72c4a4b..9b3322e9a 100644 --- a/src/cmakeBuildRunner.ts +++ b/src/cmakeBuildRunner.ts @@ -36,6 +36,7 @@ export class CMakeBuildRunner { this.currentBuildProcess = { child: undefined, result: new Promise(resolve => { const disposable: vscode.Disposable = vscode.tasks.onDidEndTask((endEvent: vscode.TaskEndEvent) => { if (endEvent.execution === this.taskExecutor) { + this.taskExecutor = undefined; disposable.dispose(); resolve({ retc: 0, stdout: '', stderr: '' }); } @@ -53,7 +54,6 @@ export class CMakeBuildRunner { } if (this.taskExecutor) { this.taskExecutor.terminate(); - this.taskExecutor = undefined; } } diff --git a/src/cmakeTaskProvider.ts b/src/cmakeTaskProvider.ts index 6e86c036f..b282a1104 100644 --- a/src/cmakeTaskProvider.ts +++ b/src/cmakeTaskProvider.ts @@ -190,7 +190,7 @@ export class CMakeTaskProvider implements vscode.TaskProvider { // Fetch all CMake task from `tasks.json` files. const allTasks: vscode.Task[] = await vscode.tasks.fetchTasks({ type: CMakeTaskProvider.CMakeScriptType }); const tasks: (CMakeTask | undefined)[] = allTasks.map((task: any) => { - if (!task.definition.label || !task.group || (task.group && task.group !== vscode.TaskGroup.Build)) { + if (!task.definition.label || !task.group || (task.group && task.group.id !== vscode.TaskGroup.Build.id)) { return undefined; } const definition: CMakeTaskDefinition = { @@ -236,7 +236,7 @@ export class CMakeTaskProvider implements vscode.TaskProvider { return matchingTargetTasks[0]; } else { // Search for the matching default task. - const defaultTask: CMakeTask[] = matchingTargetTasks.filter(task => task.group?.isDefault); + const defaultTask: CMakeTask[] = matchingTargetTasks.filter(task => task.isDefault); if (defaultTask.length === 1) { return defaultTask[0]; } else {