我正在尝试弄清楚如何在launch.json文件的预启动任务中一次运行多个任务。
我在tasks.json中的代码如下:
"version": "2.0.0",
"tasks": [
{
"label": "CleanUp_Client",
"type": "shell",
"command": "rm",
"args": [
"-f",
"Client"
],
},
{
"label": "Client_Build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"client.cpp",
"-o",
"Client",
"-lssl",
"-lcrypto"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$gcc"
}
]
在preLaunchTask参数的launch.json中,如果我只放置构建任务,它可以工作,但是我想运行多个任务,在本例中是CleanUp_Client和Client_Build。
我尝试添加另一个preLaunchTask -但是看起来您只能使用该参数一次,所以我尝试了:
"preLaunchTask": "build" + "clean",
"preLaunchTask": "build"; "clean",
"preLaunchTask": "build" & "clean",
"preLaunchTask": "build" && "clean",
所有这些都没有成功,没有正确的语法。
另外,作为第二部分,我想知道组部分是如何工作的,以及它对“isDefault”的意义是什么: true。
发布于 2018-07-31 02:15:57
下面是一些有用的东西。基本上,您可以创建另一个任务,其中包含您希望使用dependsOn
关键字在preLaunchTask上运行的所有其他任务。
参考代码:
"tasks": [
{
"label": "CleanUp_Client",
"type": "shell",
"command": "rm",
"args": [
"-f",
"Client"
]
},
{
"label": "Client_Build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"client.cpp",
"-o",
"Client",
"-lssl",
"-lcrypto"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$gcc"
},
{
"label": "Build",
"dependsOn": [
"CleanUp_Client",
"Client_Build"
]
}
]
在这种情况下,您可以将preLaunchTask设置为"Build“,它将同时运行这两个任务。
我很好奇是否有人知道从launch.json preLaunchTask运行几个任务的替代语法或正确语法
https://stackoverflow.com/questions/51599106
复制相似问题