在Visual Studio代码中一次运行两个项目

时间:2016-07-22 15:13:28

标签: visual-studio-code

我开发了web项目。 Server是用TypeScript编写的node.js应用程序。客户端也写在Typescript中。我需要两个能力:

  1. 使用不同文件夹中的不同编译器选项编译不同的项目。
  2. 同时调试两个项目。
  3. 我该怎么做?

1 个答案:

答案 0 :(得分:10)

请参阅我们关于多目标调试的文档:https://code.visualstudio.com/Docs/editor/debugging#_multitarget-debugging

launch.json中,只需创建一个包含您要调试的目标的compounds部分

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Server",
            "program": "${workspaceRoot}/server.js",
            "cwd": "${workspaceRoot}"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Client",
            "program": "${workspaceRoot}/client.js",
            "cwd": "${workspaceRoot}"
        }
    ],
    "compounds": [
        {
            "name": "Server/Client",
            "configurations": ["Server", "Client"]
        }
    ]
}