无法在 VS Code 中多次使用预启动任务
Unable to use pre - launch task more than once in VS Code
我正在尝试多次使用预启动任务在我的launch.json文件中执行两个不同的任务。不幸的是,它只执行我的launch.json文件中的最后一个预启动任务。我的tasks.json中的任务使用相同的命令("g++"(来编译我的程序,但它们的参数不同(这是因为我需要先将我的源代码编译成"O"文件,然后将"O"文件编译为"exe"文件(,所以我正在寻找一种方法如何仅使用一个预启动任务在launch.json文件中执行这两个任务。请问还有其他想法吗?
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"tasks": [
{
"taskName": "CompileToOfile",
"command": "g++",
"args": [
"-c","${fileBasename}",
"-o","${fileBasenameNoExtension}.o",
"-I","/Users/Acer/MinGW64/include",
"-I","/Users/Acer/MinGW64/x86_64-w64-mingw32/include",
"-I","/Users/Acer/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include",
"-I","/Users/Acer/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++",
"-m32"
],
"isShellCommand": true
},
{
"taskName": "CompileWGDBWBGI",
"command": "g++",
"args": [
"${fileBasenameNoExtension}.o",
"-o",
"${fileBasenameNoExtension}.exe",
"-L","/Users/Acer/MinGW64/lib32",
"-L","Users/Acer/MinGW64/x86_64-w64-mingw32/lib32",
"-static-libgcc",
"-lbgi",
"-lgdi32",
"-lcomdlg32",
"-luuid",
"-loleaut32",
"-lole32",
"-m32"
],
"isShellCommand": true
}
]
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"preLaunchTask": "CompileToOfile",
"preLaunchTask": "CompileWGDBWBGI",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "CompileToOfile",
"preLaunchTask": "CompileWGDBWBGI",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/Users/Acer/MinGW64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
您只能有一个preLaunchTask
,但您可以将"dependsOn": "CompileToOfile"
添加到CompileWGDBWBGI
任务中,然后将其用作preLaunchTask
。这样,CompileToOfile
在每次执行CompileWGDBWBGI
之前执行
相关文章:
- 如何创建一个空的全局类并在启动时实例化它
- 即使我读取了所有内容,在FIFO上打开的QSocketNotifier也会一直启动
- 有没有任务栏API可以立即应用注册表更改
- 使用 std::string () const 函数启动线程或未来
- 如何修复valgrind启动时的致命错误(与libc6-dbg和libc6-dbg:i386连接)
- 将向量作为类>(值)<向量启动和向量<类>[值]有什么区别
- 如何创建线程序列以按照启动顺序执行任务?
- 为什么我在启动任务时收到成功代码,但它什么也不做?
- DJI SDK 无法启动协同航点任务
- 无法在 VS Code 中多次使用预启动任务
- 预启动任务和启动可以在VSCode的同一终端内启动吗?
- 启动时C++ MFC 软件请求焦点(在任务栏中闪烁)
- 有可能知道我的应用程序是从Windows7的任务栏启动的吗
- 简单C++程序在多个实例中启动,任务管理器无法关闭它
- Qt App在任务调度程序启动时不加载sql驱动程序
- 从没有任务栏按钮的c++启动c#应用程序
- 应用程序是不可见的,如果没有任何用户登录从任务调度程序启动
- 从c++启动一个c#应用程序,并在该应用程序上执行一个任务
- 如何先启动另一个终端任务
- 在一个任务的状态被另一个任务更改后重新启动该任务