vscode-cpptools
vscode-cpptools copied to clipboard
The "inputs" section is not working in `tasks.json`.
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:
- Prepare a clean environment for C or C++ source file, which excludes
tasks.jsonandlaunch.jsonunder.vscodefolder. - Write
hello_world.cpp. - Generate a
tasks.jsonby clickRun C/C++ File. It should be able to run correctly. - Add
inputssection that includes"id": "ext"totasks.jsonand append${input:ext}to the last line inargs. - 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.