Given the following auto-generated Visual Studio Code launch.json config:
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.
I left out my failed attempts at getting this to work how I want...
{
"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"
}
}
Opening VS Code with URLs You can use the URL in applications such as browsers or file explorers that can parse and redirect the URL. For example, on Windows, you could pass a vscode:// URL directly to the Windows Explorer or to the command line as start vscode://{full path to file} .
To create a launch.json file, click the create a launch.json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .vscode folder and added the launch.json file to your workspace.
There is a launch.json file...there you should be able to set the cwd property...( cwd stands for current working directory )
You enable auto attach by running Debug: Toggle Auto Attach command from the Command Palette, and once activated you can toggle auto attach from the Status Bar as well.
this one also works for me on 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"
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With