"Select the build task to run" in VSCode keeps popping up

Viewed 1614

Every time I run the code in VS Code (Python code run with Ctrl-Shift+B), the VS Code keeps asking me to "Select the build task to run" instead of just running the script (as it was previously). I do have only one task defined. How to solve this problem?

4 Answers

You need set the desired task as the default. In the file tasks.json, change the following from:

"group": "build",

to:

"group": {
    "kind": "build",
    "isDefault": true
},

Create a dummy-task in tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "dummy-task to not get the 'Select the build task to run'-popup",
            "command": "exit",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "isBackground": true,
            "presentation": {
                "echo": false,
                "reveal": "never",
                "panel": "shared",
            }
        }
    ]
}

NOTE: A small window on the right bottom side will appear but close immediatly since there is nothing to do after exit-command is executed.

This was resolved when I deleted the local tasks.json and relied on the global one.

In my case I had a project level tasks.json file and a user level tasks.json which both had a default build group set and thus VSCode asked every time.

It would be nice if they told you there was a conflict with multiple defaults so you could resolve them.

Related