在项目中有许多辅助工具。在启动和任务的json文件中,它们被配置为允许用户选择要构建或调试的特定工具。我想做的是让来自启动的选择传递到任务,并让任务使用该选择。launch.json配置文件如下所示:
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug: <Utility App>",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/apps/${input:utility}/${input:utility}",
"args": ["--notimeout", "--pit"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/apps/${input:utility}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "make utility",
},
"inputs": [
{
"type": "pickString",
"id": "utility",
"description": "Which utility app do you want to run?",
"options": [
"utility_1",
"utility_2",
"utility_3",
"utility_4",
]
},
]
}
tasks.json配置文件的格式如下:
tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make utility",
"type": "process",
"command": "make",
"args": [ "${input:BuildUtility}" ],
"group": "build",
"problemMatcher": "$gcc"
},
],
"inputs": [
{
"type": "pickString",
"id": "BuildUtility",
"description": "Which utility do you want to build?",
"options": [
"utility_1",
"utility_2",
"utility_3",
"utility_4",
]
}
]
}
我该如何通过从launch中选择的preLaunchTask来传递选择,从而有效地覆盖"${input:BuildUtility}",以便用户不需要为"args"字段做出选择?如果没有向任务传递任何内容,任务仍会要求进行选择。谢谢。