【发布时间】:2016-05-21 12:03:09
【问题描述】:
根据the documentation,可以在调试前启动程序:
要在每个调试会话开始之前启动任务,请将
preLaunchTask设置为 tasks.json 中指定的任务之一的名称。
我没有看到“命名”任务的示例语法,但schema documentation 显示了一个名为taskName 的属性。我尝试使用它将我的 launch.json preLaunchTasks 链接到任务,但它没有工作。当我启动我的程序时,Visual Studio Code 报告了这个错误:
找不到独特的任务“启动核心”。确保任务存在并且具有唯一的名称。
我的自定义“命名”任务如下所示:
{
"taskName": "launch-core",
"version": "0.1.0",
"command": "C:\\utils\\mystuff.exe",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
}
然后我尝试将属性名称从 taskName 更改为 name、based on this link。那也没用。
Intellisense 没有给出如何命名任务的建议。
有人知道如何在 tasks.json 文件中唯一地命名一个任务吗?语法是什么?属性名称是什么?
最终我想在我自己的 node.js 应用程序启动之前执行两个或三个 node.js 进程。例如,我想在我的应用程序启动到调试器之前启动以下三个应用程序:
sh -c 'cd ./manager/ && node manager.js'
sh -c 'cd ./adapter/ && node adapter.js'
sh -c 'cd ./core/ && node core.js'
如果我在 Windows 机器上工作,我的任务可能如下所示:
{
"taskName": "core-launch",
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "start",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": [
"ACD-Manager",
"/B",
"/D",
"./manager/",
"node",
"manager.js"
]
}
上述任务使用cmd start capability。我还不确定如何启动多个节点任务而不是一个,但由于这个任务命名问题,我什至无法启动一个任务。
如何在 tasks.json 文件中命名任务?
【问题讨论】:
标签: node.js visual-studio-code