visual-studio-code - Visual Studio 代码中的条件任务
问题描述
我正在尝试创建一个分层的任务结构。由于该项目目前有超过 100 个任务,我们需要通过使用“子任务”或input
s 作为其在 vs 代码中的调用来简化其结构,以获得对我们任务的更多可见性。
考虑这个例子(下面为此提供的代码):
Run Task -> option(s) --> sub-options
option --> sub-options
我理想中想要的是:
Run "myTask" -> option(s) --> sub-options based on previous
|
|--> sub-options based on previous
|
|--> sub-options based on previous
可以说我选择Run Task -> Option1 -> avaliable sub-options for option1
我想有条件地查看“父母”的选项。
一个真实世界的场景:
[Build Customer] Task -> CustomerName -> Avaliable products for customer
-> CustomerName2 -> Avaliable products for customer2
任务.json
{
"version": "2.0.0",
"tasks": [
{
"label": "myTask",
"type": "shell",
"command": ".\\AutoBuild.bat",
"options": {
"shell": {
"executable": "powershell.exe"
},
"cwd": "${workspaceFolder}",
},
"args": [
"${input:myArg1}",
"${input:myArg2}"
],
"group": "build",
"problemMatcher": []
}
],
"inputs": [
{
"type": "pickString",
"id":"myArg1",
"options": [
"option1",
"option2",
"option3",
"option4"
],
"description": "myArg1",
"default": ""
},
{
"type": "pickString",
"id":"myArg2",
"description": "myArg2",
"options": [
"sub-option1",
"sub-option2",
"sub-option3",
"sub-option4"
],
"default": ""
},
]
}
这有可能以某种方式实现吗?
欢迎使用丑陋或概念验证解决方案!
解决方案
不幸的是,像键绑定'“何时”这样的扩展没有条件属性。解决方法是执行一个脚本文件,可以对输入进行操作。例如:
{
"version": "2.0.0",
"tasks": [
{
"label": "myTask",
"type": "shell",
"command": ".\\AutoBuild.bat",
"args": [
"${input:myArg1}",
"${input:myArg2}"
]
}
]
}
AutoBuild.bat
然后将有逻辑来测试和采取行动myArg1
和myArg2
。
推荐阅读
- python - 无法使用用户数据目录 msedge
- reactjs - 如何使用反应共享将图像共享为缩略图
- azure-devops - 在开关盒中重复 Microsoft Power Automate 步骤
- database - 我正在尝试从数据库中获取数据,它返回给我这个未来
- > 我该如何迭代这个
- c-preprocessor - 预处理期间会发生什么?
- python - 如何在线程上发送消息?
- c# - 如何通过 orderBy 对嵌套的 Linq 对象进行排序
- flutter - 当小吃栏显示在屏幕上并且同时如果按下后退按钮时,它会在颤动/飞镖中的控制台中引发错误
- javascript - Fieldset 类似于带有标题/子标题的 div 容器
- javascript - jquery下一个div元素选择