I have a multi root workspace with several projects in it. Each project has its own build task that calls an external script to do the build. One project requires all the others to be built prior to it's build as it is required to link against them. I will call this the "app" project from now on.
I have tried using the dependsOn in the app's tasks.json build config, but referencing the name of the external build tasks has no effect if a command is specified, and throws an error if no command is specified. e.g:
{
"label": "build-app",
"group": "build",
"dependsOn": [
"devices"
"app",
],
"dependsOrder": "sequence",
"problemMatcher": []
}
Gives this error, even though the task 'devices' does exist and works in devices/tasks.json
file:
Couldn't resolve dependent task 'devices' in workspace folder 'file:///home/simon/git-repos/workspace/app'
Now that suggests it is not searching outside the current workspace folder, so I tried creating a top level "workspace" tasks in the .code-workspace file and referencing the build tasks in there:
{
"label": "build-app",
"group": "build",
"dependsOn": [
"devices"
"app",
],
"dependsOrder": "sequence",
"problemMatcher": []
}
This results in a similar error:
Couldn't resolve dependent task 'devices' in workspace folder 'file:///home/simon/git-repos/workspace/app.code-workspace'
Couldn't resolve dependent task 'app' in workspace folder 'file:///home/simon/git-repos/workspace/app.code-workspace'
Now that looks like the it is not searching outside the .code-workspace file.
I can with a little bit of trickery get it to work the way I want, but I have to specify all the tasks in the app/tasks.json
file change directory to dependency project and specify the problem matcher "relative path" for each task. e.g.:
{
"type": "shell",
"label": "devices",
"command": "cd ${workspaceFolder}/../devices && ./build.py",
"problemMatcher": {
"base": "$gcc",
"fileLocation": ["relative", "${workspaceRoot}/../devices"]
},
"group": "build",
},
That is all kind of OK, as I can now do what I want and create a build dependency but the task definitions are not in the correct place. They are all in the app/tasks.json
not in each project's own tasks.json
. It just seems like the logic is in the wrong place.
I checked the tasks.json Schema at https://code.visualstudio.com/docs/editor/tasks-appendix to see if there were extra parameters you can set on the dependsOn
entries, and there is not even a mention of dependsOn
or dependsOrder
.
Is there are way to configure the tasks in the individual project tasks.json
files and reference them in the dependsOn
of a task in another project or the top level workspace configuration?
Where can I find the full schema for the tasks.json file? Or the code that is used to read this file in?