I'm developing a Web API with .NET Core in macOS with deployment to Linux. I have absolutely no interest in using the browser. However, when building and running from Visual Studio Code (Debug or not), the browser launches every time.
I have to close the tab, remove the browser out of the way, go to Paw, where I actually test the API, then go back to VS Code.
It's really annoying doing this every time.
Isn't there some configuration to disable browser launch?
Thanks
Go to Project Properties > Debug > Uncheck "Launch Browser" > Save.
This behavior is enabled by default, but you can disable it by clearing the Enable Hot Reload when debugging checkbox on the Build, Execution, Deployment | Hot Reload page of JetBrains Rider settings Ctrl+Alt+S .
It is changed in version 0.2.0.
Just comment out the below lines.
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
// },
Open the .vscode/launch.json
file and disable launchBrowser
.
dotnet new webapi
At this point, there is a .vscode
directory that contains a launch.json
file. Open that file and disable or delete the following.
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
See also: https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
Just to add, it works for Visual Studio 2017 as well (Not only VS Code). The file is called launchSettings.json, and is located inside the Properties folder of the project.
Open the Properties/launchSettings.json
file and set "launchBrowser": false
. It works for Visual Studio 2019.
Properties/launchSettings.json
"launchBrowser": false
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyApi": {
"commandName": "Project",
"launchBrowser": false,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
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