vscode launch.json 调试并打开特定的url

Kiz*_*mar 10 debugging visual-studio-code

给定以下自动生成的 Visual Studio Code launch.json 配置:

我希望localhost:5000/swagger在调试时启动浏览器,但我已经尝试了六种不同的东西,但没有任何效果。它只是打开到localhost:5000. 我在这里缺少什么?除了按 Ctrl+空格键查看列表之外,没有关于所有可用属性的通用文档(我可以找到),这没有多大帮助。

我遗漏了我试图让它按照我想要的方式工作的失败尝试......

{
    "name": "Launch Demo.Api",
    "type": "coreclr",
    "request": "launch",
    "preLaunchTask": "build",
    "program": "${workspaceRoot}/Demo.Api/bin/Debug/netcoreapp2.1/Demo.Api.dll",
    "args": [],
    "cwd": "${workspaceRoot}/Demo.Api",
    "stopAtEntry": false,
    "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"
    }
}
Run Code Online (Sandbox Code Playgroud)

Sor*_*ren 32

这个也适用于 VSCode 1.39.2

// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
    "action": "openExternally",
    "pattern": "\\bNow listening on:\\s+(https?://\\S+)",
    "uriFormat": "%s/swagger"
}, 
Run Code Online (Sandbox Code Playgroud)


小智 7

这个对我有用:

{
     "launchBrowser": {
            "enabled": true,
            "args": "${auto-detect-url}",
            "windows": {
                "command": "cmd.exe",
                "args": "/C start ${auto-detect-url}/swagger"
            },
}
Run Code Online (Sandbox Code Playgroud)


小智 6

我尝试了以下方法,它似乎有效

"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}/swagger",
Run Code Online (Sandbox Code Playgroud)