By accident I selected "don’t ask me again" on some feature in VS Code after pressing F5. Now, every time I press F5, it adds the default task in the tasks.json even when I have two other tasks in there. How do I make it stop doing that or ask me which build task to run when I press F5? Here is the before and after tasks.json.
Before:
{
"tasks": [
{
"label": "C/C++: g++-13: Debug, x64",
"group": "build",
"detail": "g++ build: Debug x64",
"type": "cppbuild",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"-O0",
"-m64",
"${workspaceFolder}/${workspaceFolderBasename}/main.cpp",
"-o",
"${workspaceFolder}/build/${workspaceFolderBasename}.out",
"-I${workspaceFolder}/dependencies/MAVSDK/include/mavsdk",
"-L${workspaceFolder}/dependencies/MAVSDK/lib"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "C/C++: g++-13: Release, x64",
"group": "build",
"detail": "g++ build: Release x64",
"type": "cppbuild",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"-O3",
"-m64",
"${workspaceFolder}/${workspaceFolderBasename}/main.cpp",
"-o",
"${workspaceFolder}/build/${workspaceFolderBasename}.out",
"-I${workspaceFolder}/dependencies/MAVSDK/include/mavsdk",
"-L${workspaceFolder}/dependencies/MAVSDK/lib"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
]
}
],
"version": "2.0.0"
}
After:
{
"tasks": [
{
"label": "C/C++: g++-13: Debug, x64",
"group": "build",
"detail": "g++ build: Debug x64",
"type": "cppbuild",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"-O0",
"-m64",
"${workspaceFolder}/${workspaceFolderBasename}/main.cpp",
"-o",
"${workspaceFolder}/build/${workspaceFolderBasename}.out",
"-I${workspaceFolder}/dependencies/MAVSDK/include/mavsdk",
"-L${workspaceFolder}/dependencies/MAVSDK/lib"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "C/C++: g++-13: Release, x64",
"group": "build",
"detail": "g++ build: Release x64",
"type": "cppbuild",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"-O3",
"-m64",
"${workspaceFolder}/${workspaceFolderBasename}/main.cpp",
"-o",
"${workspaceFolder}/build/${workspaceFolderBasename}.out",
"-I${workspaceFolder}/dependencies/MAVSDK/include/mavsdk",
"-L${workspaceFolder}/dependencies/MAVSDK/lib"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
]
},
{
"type": "cppbuild",
"label": "C/C++: g++-13 build active file",
"command": "/usr/bin/g++-13",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
2
Answers
I found the issue to be the "label". I renamed "label" to be "C/C++: g++-13 build active file" in my two tasks and it stopped generating the third default task. I don't know why, but VS Code searches for tasks with label ""C/C++: g++-13 build active file". If it does not find it, it generates a new one and runs that one.
Either remove the "isDefault": true line or set it to ‘false’ or delete the entire task if you don’t need it anymore.