Guide for using tasks in VS Code
How to open and use the tasks menu
Based on the Tasks tutorial.
How to run a task in VS Code - use one of these approaches.
- Open the tasks menu using one of these approaches:
- Keyboard shortcut
- Press CTRL+SHIFT+P.
- Use the menu
- Open
Terminaltab from the top menu bar. - Click
Run task....
- Open
- Keyboard shortcut
- Type "Task" after ">" to search. This will narrow down the list.
- Select a task.
- Open tasks menu, as per instructions in
1.above. - Type "Build" after ">" to search. This will narrow down the list.
- Click
Tasks: Run build taskorTasks: Configure build task.
VS Code can detect tasks for NPM, Make and other configured tools. These are available from the tasks menu.
This can be turned off with VS Code settings.
{
"typescript.tsc.autoDetect": "off",
"grunt.autoDetect": "off",
"jake.autoDetect": "off",
"gulp.autoDetect": "off",
"npm.autoDetect": "off"
}Use the task menu.
Create a tasks file in your repo.
.vscode/tasks.json.
Or in your user directory.
For Linux: ~/.config/Code/User/tasks.json.
{
// 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. This is a global VS Code task."
}
]
}NPM install and start.
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "install",
"problemMatcher": [],
"label": "npm: install",
"detail": "install dependencies from package"
},
{
"type": "npm",
"script": "start",
"problemMatcher": [],
"label": "npm: start",
"detail": "docsify serve docs"
}
]
}If you set the install task as the "Build" tasks (accessible via a keyboard shortcut), an extra field is added after detail.
"group": {
"kind": "build",
"isDefault": true
}