A recent change seems to have changed the structure of the launch.json file. I need to launch a specific page when I start my project (an API web app).
In a Dotnet web application, choose the .NET Generate Assets for Build and Debug.
Be able to launch a specific page. Previous launch.json had this configuration:

After (re)generating the launch.json (and tasks.json file, which also changed format), the file looks like:

I'm not sure if I should add the launchBrowser section (as it launches the browser already, but tries to go the default page).
VSCode version: 1.38.0-exploration
C# Extension: 1.21.2-beta1
Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk3.0.100-preview8-013656
Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc
.NET Core SDKs installed:
2.1.700 [C:Program Filesdotnetsdk]
2.1.800 [C:Program Filesdotnetsdk]
2.2.300 [C:Program Filesdotnetsdk]
2.2.301 [C:Program Filesdotnetsdk]
2.2.400 [C:Program Filesdotnetsdk]
3.0.100-preview8-013656 [C:Program Filesdotnetsdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.5 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:Program FilesdotnetsharedMicrosoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|auto-close-tag|formulahendry|0.5.6|
|auto-rename-tag|formulahendry|0.1.0|
|azure-account|ms-vscode|0.8.4|
|csharp|ms-vscode|1.21.2-beta1|
|debugger-for-chrome|msjsdiag|4.11.7|
|linux-themes|SolarLiner|1.0.1|
|material-icon-theme|PKief|3.9.0|
|monokai-plusplus|dcasella|1.6.10|
|ng-template|Angular|0.802.3|
|night-owl|sdras|1.1.3|
|night-wolf|MaoSantaella|1.8.0|
|one-monokai|azemoh|0.3.7|
|output-colorizer|IBM|0.1.2|
|theme-cobalt2|wesbos|2.1.6|
|theme-panda|tinkertrain|1.3.0|
|vetur|octref|0.22.2|
|vscode-azurefunctions|ms-azuretools|0.18.1|
|vscode-cosmosdb|ms-azuretools|0.10.2|
|vscode-eslint|dbaeumer|1.9.1|
|vscode-typescript-tslint-plugin|ms-vscode|1.2.2|
|vscodeintellicode|VisualStudioExptTeam|1.1.9|;
I found https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md but it doesn't specify how to launch a specific page (ie. http://localhost:5000/swagger/index.html)
@jtsom you want to look at this part of the instructions
Ex: "uriFormat": "http://localhost:5000/swagger/index.html"
Or I think this would better match what you had before:
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
"uriFormat": "%s/swagger"
}
Unfortunately it still tries to open the browser to http://localhost:5000 with no further path...
You get this even if you set uriFormat to exactly what you want (Ex: "uriFormat": "http://localhost:5000/swagger/index.html")?
Yes. It doesn't matter what I put in uriFormat, it always defaults to http://localhost:5000 (in this case). That doesn't seem to specify what the launch url is. I think that needs to be set elsewhere?
Ok. Did more testing.
Setting the pattern to: "^\\s*Now listening on:\\s+https?://\\S+"
and the uriFormat to: "http://localhost:5000/swagger"
causes the right page to launch. But to not have to hard code the port (or url), trying to use the %s substitution doesn't seem to work:
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)",
"uriFormat": "http://localhost:%s/swagger" or %s/swagger"
The behavior you are seeing isn't how I thought VS Code designed this feature, but it sounds like there is a bug open to change it: https://github.com/microsoft/vscode/issues/79596
For future reference, here is the VS Code source code for handling serverReadyAction: https://github.com/microsoft/vscode/blob/bd9458e6b8cf2f24bbc759520795998a071a6db2/extensions/debug-server-ready/src/extension.ts#L114
I will leave this bug open to see what updates, if any, we should make to our documentation once VS Code resolves that issue.
Most helpful comment
Or I think this would better match what you had before: