I recently started a Udemy course on programming in c, and when the instructor was detailing how to set up a c project in VS Code, he had as go through the tasks.json file and add the following code. From a little bit of research, it seems that this is not necessary, but I am not entirely certain. If anyone could elaborate on the importance of the group>kind>build and isDefault>true lines in general, that would be fantastic.
"group": {
"kind": "build",
"isDefault": true
As I said, I tried doing some online research, but nothing was clear, and was phrased in a "duh, you should know this", kind of tone, which really through off my understanding.
As a side note, this is my second ever question asked on stack overflow, and I would love some feedback on the formatting.
This isn't particularly well documented on the VSCode Tasks page or tasks schema page, so I was confused too. Here's my current understanding (which may have some holes in!)
The group's kind can be either "test"
or "build"
. Which you choose determine where the task is listed or run.
"test"
task is listed/run when you choose the Tasks: Run Test Task
command from the command palette."build"
task is listed/run when you choose the Tasks: Run Build Task
command from the command palette. By default, this also has a keyboard shortcut of cmd+shift+b (Mac) or ctrl-shift-b (Windows/Linux).(The command palette can be shown with cmd+shift+p on Mac or ctrl+shift+p on Windows/Linux.)
If you only have one task of a certain kind, or have multiple but only one has isDefault
set, then that task is run when the command above is invoked, otherwise the relevant tasks are listed and you can choose one. In my testing, isDefault
is ignored if it's set for multiple tasks of the same kind.
The kind can either be provided as the only value or with the specific "kind
" key:
"group": "test"
or
"group": {
"kind": "test"
}
The reason to use the second form is that it allows you to specify the isDefault
key as well (see above for what that does):
"group": {
"kind": "test",
"isDefault": true
}