Search code examples
visual-studio-codecentos7vscode-tasks

Input not prompted for VSCode custom task


Moving to using VSCode under CentOS 7.

With the following tasks.json under ${workspaceFolder}/.vscode:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Test task",
            "type": "shell",
            "command": "echo ${input.param}",
            "problemMatcher": []
        }
    ],
    "inputs": [
        {
            "id": "param",
            "description": "Type some text",
            "type": "promptString",
            "default": "Hello world!"
        }
    ]
}

It is possible to launch the "Test task" by selecting "Terminal -> Run Task" in the menu bar.

The task starts but the "param" input prompt does not show up. The terminal output is then:

 *  Executing task: echo ${input.libraryName} 

/bin/bash: ${input.libraryName}: bad substitution

 *  The terminal process "/bin/bash '-c', 'echo ${input.libraryName}'" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it. 

Output from VSCode Help->About:

Version: 1.83.1
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:45:31.402Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 3.10.0-1160.45.1.el7.x86_64

Solution

  • Thanks to @rioV8's prompt suggestion, the working solution is:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Test task",
                "type": "shell",
                "command": "echo ${input:param}",
                "problemMatcher": []
            }
        ],
        "inputs": [
            {
                "id": "param",
                "description": "Type some text",
                "type": "promptString",
                "default": "Hello world!"
            }
        ]
    }