Skip to content

The "inputs" section is not working in tasks.json. #12845

Open
@MellowOrchid

Description

@MellowOrchid

Environment

  • OS and version: Windows 11 23H2
  • VS Code: 1.94.2 (system setup)
  • C/C++ extension: v1.22.9
  • OS and version of remote machine (if applicable): Ubuntu Server 24.04.1 LTS
  • GDB / LLDB version: GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git

Bug Summary and Steps to Reproduce

Bug Summary:

  1. Prepare a clean environment for C or C++ source file, which excludes tasks.json and launch.json under .vscode folder.
  2. Write hello_world.cpp.
  3. Generate a tasks.json by click Run C/C++ File. It should be able to run correctly.
  4. Add inputs section that includes "id": "ext" to tasks.json and append ${input:ext} to the last line in args.
  5. Run the .cpp file again, and VS Code will tell you "Variable 'ext' must be defined in an 'inputs' section of the debug or task configuration."

Debugger Configurations

tasks.json:

{
    "inputs": [
        {
            "id": "ext",
            "type": "pickString",
            "description": "Choose the extension",
            "options": [
                ".app",
                ".exe"
            ],
            "default": ".app"
        }
    ],
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${cwd}/bin/${fileBasenameNoExtension}${input:ext}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Generated task by Debugger."
        }
    ],
    "version": "2.0.0"
}

launch.json:
None

Debugger Logs

VS Code window: Variable 'ext' must be defined in an 'inputs' section of the debug or task configuration.

Other Extensions

None, only C/C++ by Microsoft installed

Additional Information

Actually, I want the tasks.json could use different extension name by judging the platform.

I want to compile C/C++ source code on Linux and Windows by using one 'tasks.json' and no need to install other extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceenhancementImprovement to an existing featurehelp wantedCan be fixed in the public (open source) repo.tasks/build/debugAn issue relating to tasks.json (e.g. build issues)

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions