Table of Contents

Location

tasks.json file in the workspace .vscode folder

Shortcut

  • Ctrl+Shift+B (Run Build Task)
  • Terminal > Configure Tasks > Create tasks.json file from templates > Others

Example

Run a command

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo Hello"
        }
    ]
}

Run a npm script

What are npm scripts and how to use them ? The script property of Package.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "test",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Run Typescript

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
“version”: “2.0.0”,
“tasks”: [
{
“label”: “sh”,
“type”: “shell”,
“command”: “tsc -w -p .”,
“group”: {
“kind”: “build”,
“isDefault”: true
}
}
]
}
</code>