VSCode. Setting up custom VSCode run shortcut

It is possible to configure custom run task in VSCode (shortcut CTRL + SHIFT + B).

This can be done by creating .vscode folder in your source root folder and create tasks.json file within that folder.

In the example json file below I have command python tests.py but it could be replaced with any command runnable in the shell. That shell is using the Pythonpath set by the VSCode. This Pythonpath can be set to point to environment created via robot.yaml by using command palette Robocorp. Set pythonPath based on robot.yaml (for troubleshooting this see the link at the bottom).

My example shell command could be for example running tests.sh which would set environment variables and then would run the Python tests.py.

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "run custom command",
            "type": "shell",
            "command": "python tests.py",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

About setting Pythonpath in the VSCode: VsCode Python extension acting up, code-completion not working etc

1 Like