Example of a single task

nRF Connect for VS Code

tags
nRF Connect for VS Code

For example, let's assume you have a tasks.json file. If you have only one task that you would like to bind to an action, the file may look like follows:

{
  "version": "2.0.0",
  "tasks": [
        {
            "label": "My custom flash",
            "command": "${workspaceFolder}/my-flash-script.sh",
            "args": ["--build", "--erase", "--nrf52"],
            "presentation": {
                "echo": true,
                "reveal": "never",
                "clear": true
            }
        }
    ]
}

You can bind the task to the action by adding the following lines to the nrf-connect.taskBindings configuration option in the binding configuration file:

{
    "nrf-connect.taskBindings": {
      "build": [{ "taskName": "My custom flash" }]
  }
}

This way, the My custom flash task runs whenever the Build action is run.