VSCode 调试 ASP.NET 核心应用在特定端口上启动浏览器
VSCode debug ASP.NET Core app launch browser on specific port
我有以下 .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "My Web App",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-frontend",
"program": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2/MyWebAp.dll",
"args": [],
"cwd": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5001"
},
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}",
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/src/MyWebAppb/Views"
},
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
但是,调试会话总是在默认端口 5000 上打开浏览器。它不支持 ASPNETCORE_URLS
。感谢任何建议和见解。
问题的根本原因是我在 5000 上的 program.cs 中配置了 kestrel。将其更改为所需的端口号即可。
我有以下 .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "My Web App",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-frontend",
"program": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2/MyWebAp.dll",
"args": [],
"cwd": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5001"
},
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}",
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/src/MyWebAppb/Views"
},
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
但是,调试会话总是在默认端口 5000 上打开浏览器。它不支持 ASPNETCORE_URLS
。感谢任何建议和见解。
问题的根本原因是我在 5000 上的 program.cs 中配置了 kestrel。将其更改为所需的端口号即可。