.netvisual-studio-codedebugging

vscode launch.json debug and open specific url


Given the following auto-generated Visual Studio Code launch.json config:

{
    "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"
    }
}

I'd like this to launch the browser to localhost:5000/swagger when I debug, but I've tried half a dozen different things and nothing works. It just opens to localhost:5000. What am I missing here? There's no general documentation (that I could find) on all of the attributes available aside from hitting Ctrl+space to see a list, which doesn't help much.


Solution

  • I tried the following and it seems to work

    "launchBrowser": {
    "enabled": true,
    "args": "${auto-detect-url}/swagger",