thecrumb

developer | thinker | tinkerer

Visual Studio Code - Tasks Followup


In my last VSCode Tasks post I created a simple task to run my Robot tests.

This recently broke and I was trying to figure out why and discovered that Tasks do not like altnerate terminals. I had recently tweaked my VSCode to use Cmder/Conemu as my terminal.

In my updated tasks.json I've added a 'windows' section where I define what shell I'm using - in this case the vanilla Windows cmd.exe:

{
    "version": "2.0.0",

    "windows": {
        "options": {
            "shell": {
                "executable": "cmd.exe",
                "args": [
                    "/d", "/c"
                ]
            }
        }
    },

    "tasks": [
        {
            "label": "Clean Results",
            "type": "shell",
            "command": "DEL /F /Q ${workspaceFolder}\\results\\*.*"
        },
        {
            "label": "Run Robot Tests",
            "dependsOn": "Clean Results",
            "type": "shell",
            "command": "robot",
            // quote each argument and flag
            "args": [
                "-d", "results"
                , "-v", "password:${input:Password}"
                , "--suite", "${input:Suite}"
                , "tests/${input:Test}"],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": true,
        "panel": "shared"

    },
    "inputs":[
        {
            "id": "Password",
            "description": "Please enter a password",
            "default": "",
            "type": "promptString",
        },
        {
            "id": "Location",
            "description": "Select where to run test",
            "default": "TEST",
            "type": "pickString",
            "options": ["TEST", "DEV"]
        },
        {
            "id": "Test",
            "description": "Select test",
            "default": "login",
            "type": "pickString",
            "options": ["foo", "bar", "test", "general", "login"]
        },
        {
            "id": "Suite",
            "description": "Enter specific suite (optional)",
            "default": "login_tests",
            "type": "promptString"
        }
    ],
}

Now my terminal still uses Cmder/Conemu but when I run a task it runs using the default cmd.exe.

I'm not sure why the task doesn't work with a different shell but that was a quick fix with no drawbacks.


Pi-hole - Say Goodbye to Ads thecrumb.com - Under the hood

More like this...