[Bug] Task defined inside workspace file can not be run, it is stuck in "Task is running" state.
Brief Issue Summary
If the task is defined in workspace file, it is stuck with error:
[error] TypeError: Cannot read properties of undefined (reading 'path')
at CustomBuildTaskTerminal.getProject (<home>\.vscode\extensions\ms-vscode.cmake-tools-1.21.36\dist\main.js:87896:80)
Seems the problem with workspaceFolder.uri. The task example: <...>.code-workspace:
{
"launch": {
"version": "0.2.0",
"configurations": [
<...>
],
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "Prelaunch Build",
"command": "build",
"targets": [
"all"
],
}
]
},
"folders": [
{
"path": "."
}
],
}
If the task is replaced into tasks.json, the workspace folder is recognized and everything works correctly
CMake Tools Diagnostics
{
"os": "win32",
"vscodeVersion": "1.95.3",
"cmtVersion": "1.22.2",
"configurations": [
{
"folder": "<>",
"cmakeVersion": "3.26.4",
"configured": true,
"generator": "Ninja",
"usesPresets": false,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 1,
"executablesCount": 1,
"librariesCount": 0,
"targets": [
{
"name": "main",
"type": "EXECUTABLE"
}
]
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
Debug Log
ExtensionHost window (output window is empty):
[error] TypeError: Cannot read properties of undefined (reading 'path')
at CustomBuildTaskTerminal.getProject (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:87966:80)
at CustomBuildTaskTerminal.runBuildTask (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:88014:34)
at CustomBuildTaskTerminal.open (<>\.vscode\extensions\ms-vscode.cmake-tools-1.22.2\dist\main.js:87876:28)
at X0.startSendingEvents (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:40456)
at Jw.S (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:44872)
at Jw.attachPtyToTerminal (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:114:42916)
at Qw.$onDidStartTask (file:///<>/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:121:52658)
Additional Information
No response
Hi @nadiaivc , thank you for reporting this issue. We tried to check this issue in Visual Studio Code v1.102.3 + CMake Tools v1.22.2. But we can't reproduce this issue. Could you help to take a look at it? In order for us to investigate this further, could you please provide a sample project to us that can reproduce this issue? Thanks.
Hi @yanghhhhhhh ,
Thank you for your answer.
To reproduce the issue it is necessary to move task from tasks,json to sample.code_workspace and the task type should be cmake. And then try to run "Run Task" in the same way. This scenario is necessary for using launch->preLaunchTask property, in this case the task should be placed inside workspace file. There is a simple example, you don't need any extra files, because cmake anyway will not start the build.
Hi @nadiaivc , thanks for reporting issue here! Reproduced this issue on VS Code 1.102.3 + CMake Tools v1.22.3 release version. Repro Steps: 1. Download the file example.code-workspace (example.code-workspace.txt). 2. Launch VS Code, open Workspace from File, choose the file example.code-workspace. 3. Press F1 and click "Tasks: Run Task" > "cmake" > "Prelaunch Build". 4. Observe the task process, open output (ExtensionHost window) window, observe the error message.
Details please see following video:
FYI: @gcampbell-msft