如何使用 launch.json 停止 vscode 中的多个项目
我在启动中有。要停止API,我需要单独停止它们,它们是一种创建配置文件以同时停止两个项目的方法吗?
观察:我在此代码示例中仅使用两个项目,但实际上,我有六个API和其他项目,例如服务和前端项目。
大多数C#项目,Windows Services和Web API,但我想将来包括JavaScript前端项目。
我的启动:json:
// Components for start menu in vscode debug mode
{
"version": "0.2.0",
"compounds":
[
{
"name": "Web API",
"configurations":
[
"Web API One",
"Web API Two"
]
}
],
// Configuration of each project
"configurations":
[
{
"name": "Web API One",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildWEBAPI",
"program": "${workspaceFolder}/WEBAPI/PATH",
"args":
[
"--force"
],
"cwd": "${workspaceFolder}/01.Application/WEBAPI",
"stopAtEntry": false,
"env":
{
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": "Web API Two",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildWEBAPI",
"program": "${workspaceFolder}/WEBAPI/PATH",
"args":
[
"--force"
],
"cwd": "${workspaceFolder}/01.Application//WEBAPI/",
"stopAtEntry": false,
"env":
{
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
]
}
I have in my launch.JSON a configuration that allows me to start two different API projects at the same time (Web API One and Web API Two), both are components of the same project, everything works fine on start, but if I need to stop the APIs I need to stop each of them individually, theirs a way to create a config file to stop both projects at the same time?
Observation: I use only two projects in this code example, but in reality, I have six APIs and other projects like services and front-end projects.
Most C# projects, Windows Services and Web APIs, but I want to include JavaScript front-end projects in the future.
My launch.JSON:
// Components for start menu in vscode debug mode
{
"version": "0.2.0",
"compounds":
[
{
"name": "Web API",
"configurations":
[
"Web API One",
"Web API Two"
]
}
],
// Configuration of each project
"configurations":
[
{
"name": "Web API One",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildWEBAPI",
"program": "${workspaceFolder}/WEBAPI/PATH",
"args":
[
"--force"
],
"cwd": "${workspaceFolder}/01.Application/WEBAPI",
"stopAtEntry": false,
"env":
{
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
"name": "Web API Two",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildWEBAPI",
"program": "${workspaceFolder}/WEBAPI/PATH",
"args":
[
"--force"
],
"cwd": "${workspaceFolder}/01.Application//WEBAPI/",
"stopAtEntry": false,
"env":
{
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会回答自己的问题,因为我找到了解决方案。基于我的搜索,这种使用.json配置文件的方法是不可能的,但是另一种选择是在项目运行并保存之前,在VSCODE中的呼叫堆栈选项卡上单击“ shift + f5”,直到停止所有项目
I will answer my own question because I found a solution. Based on my search, this approach using .json config file is not possible, but an alternative is to click "shift + F5" on a call stack tab in vscode when the project is running and held until all projects has been stopped