【发布时间】:2019-03-30 08:38:08
【问题描述】:
我有具有以下结构的顶级文件夹主页:
--Homepage
----Client <- Angular app, created with `ng new` command
----Server <- .NET Core WebApi, created with `dotnet new webapi` command
我在主页级别打开 VSCode:
我已经安装了这些扩展:
问题
如果我想使用单个 VSCode 环境来处理客户端和服务器这两个项目,是否可以绑定 F5(或 Ctrl+F5)以同时启动两个项目?
我开始使用 ng serve 的客户端应用程序(它将在 http 端口 4200 上运行)
我开始使用 dotnet run 的服务器应用程序(它将在 https 端口 5001 上运行)
我在主页(根级别)上只有一个常见的 .vscode 文件夹:
默认情况下,第一次创建时,launch.json的内容是这样的:
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Server/bin/Debug/netcoreapp2.1/Server.dll",
"args": [],
"cwd": "${workspaceFolder}/Server",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
,]
}
所以,当我按 F5 时,它会构建并启动服务器应用程序,页面会在 https://localhost:5001 打开,从那里我可以导航到 https://localhost:5001/api/values 并查看 WebApi 的工作原理。
但是客户端应用程序根本没有启动。
所以,我想如果我将 Debugger for Chrome 扩展的设置添加到 launch.json,它应该可以工作,所以我点击了添加配置并添加了相应的部分:
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
我将端口从 8080 更改为 4200,因为 ng 服务于端口 4200 上的主机
但它不会启动客户端应用程序。
请指教。谢谢
【问题讨论】: