我试图弄清楚如何在launch.json文件的prelaunchtask中一次运行多个任务。
我在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。
这是行得通的。基本上,您要执行另一个任务,其中您要使用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运行多个任务
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句