Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blazor-wasm] Not launching correct OS specific browser #4108

Open
ar0311 opened this issue Oct 12, 2020 · 23 comments
Open

[blazor-wasm] Not launching correct OS specific browser #4108

ar0311 opened this issue Oct 12, 2020 · 23 comments

Comments

@ar0311
Copy link

ar0311 commented Oct 12, 2020

Issue Description

When specifying browser to launch using "blazorwasm" debug type, it is only respected when using the root "browser" option. It is not respected when using stanza under OS such as "windows".

Steps to Reproduce

On windows, make sure Chrome is installed and set as default browser. Also make sure Edge is installed.

Edit launch.json in project using "blazorwasm" debug type, add

"browser": "edge"

Launch and confirm Edge was launched.

Stop debugging, edit launch.json:

"windows": {
"browser": "edge"
}

Launch and Chrome (default browser) is launched.

Expected Behavior

Edge is launched.

Actual Behavior

Chrome is launched.

Environment information

VSCode version: 1.50.0
C# Extension: 1.23.3

Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.100-rc.2.20480.7 Commit: 53e0c8c7f9

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.2.20480.7\

Host (useful for support):
Version: 5.0.0-rc.2.20475.5
Commit: c5a3f49c88

.NET SDKs installed:
3.1.402 [C:\Program Files\dotnet\sdk]
5.0.100-rc.2.20480.7 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.23.3
dotnet-test-explorer formulahendry 0.7.4
git-graph mhutchie 1.26.0
gitlens eamodio 10.2.2
html-css-class-completion Zignd 1.19.0
msbuild-project-tools tintoy 0.3.8
razor-plus austincummings 0.1.4
remote-ssh ms-vscode-remote 0.55.0
remote-ssh-edit ms-vscode-remote 0.55.0
vscode-sqlite alexcvzz 0.9.0
@gregg-miskelly
Copy link
Contributor

CC @captainsafia

@captainsafia
Copy link
Member

Thanks for reporting this, @ar0311.

The blazorwasm type doesn't support OS-specific configuration types for the browser to launch.

@gregg-miskelly Is this something the JS debugger supports? I don't believe so but I might be incorrect here.

@gregg-miskelly
Copy link
Contributor

I know that the C# extension supports it for launching a browser without debugging when using the somewhat-deprecated launchBrowser launch.json syntax, but I am not sure about scenarios when launching the browser under a debugger. @connor4312 do you know?

@connor4312
Copy link

js-debug supports this if you toggle the runtimeExecutable, but it doesn't have a browser field (chrome and edge are distinct launch types).

@captainsafia
Copy link
Member

Took a look at this.

The OS-specific options are supported by the O# configuration and allow a user to override what command is used to launch the browser, for example how to use open Google Chrome.app in macOS.

Given that the blazorwasm debug configuration type uses the vscode-js-debug under the hood, I don't think it's applicable for us to expose this option.

@jtsom
Copy link

jtsom commented Oct 30, 2020

I have a default Blazor-wasm application and, on Windows, when I try to run I get an error dialog:
image

My default system browser is set to Brave, but I do have Chrome installed:
image

The error dialog says to add an item to the launch.json specifying the "runtimeExecutable", but that setting is not recognized in the launch.json for a blazorwasm type.

If I set the "browser" field to "edge", it will correctly find and launch MS Edge browser.

@connor4312
Copy link

Where is chrome.exe located on your systems?

@jtsom
Copy link

jtsom commented Oct 30, 2020

"C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe"

@jtsom
Copy link

jtsom commented Oct 30, 2020

If I change the name of the folder from "Chrome Dev" to "Chrome", the error message does not appear, and my Chrome does launch. Guessing that could cause other problems if I do that though.

@connor4312
Copy link

Thanks, fixed in the linked commit. It'll ship in the next nightly js debugger.

connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Oct 30, 2020
@jtsom
Copy link

jtsom commented Nov 2, 2020

Has this been released? I believe I'm on the latest nightly:
image

@connor4312
Copy link

Yes, it's been published -- works for me by setting the runtimeExecutable: dev

Are you still running into issues?

@jtsom
Copy link

jtsom commented Nov 2, 2020

Yes, still having the same error.

However, this is my launch.json, created from the ".Net Generate Assets for Build and Debug" command:
image

@connor4312
Copy link

We should be able to detect that if the PROGRAMFILES(X86) environment variable is set to C:\Program Files (x86) in your extension host. You can check process.env in the console when running the Toggle Developer Tools command.

If it's not set you might be hitting microsoft/vscode#106537

@jtsom
Copy link

jtsom commented Nov 2, 2020

Looks like it is set correctly:

image

@jtsom
Copy link

jtsom commented Nov 2, 2020

I'm also seeing this in the console, not sure if it's relevant :
image

@connor4312
Copy link

That means the built-in extension is still installed (and probably stealing launches, which explains the issue). Make sure to do steps 1 and 2 here! https://github.com/microsoft/vscode-js-debug#nightly-extension

@jtsom
Copy link

jtsom commented Nov 2, 2020

Ok getting this now:
image
and when I try to add that item, I get:
image

@connor4312
Copy link

Ok, that makes more sense.

@captainsafia is there a way to pass the runtimeExecutable through the blazor launch to js-debug?

@captainsafia
Copy link
Member

@connor4312 Nope, we can add this if enough people express interest in it.

@jtsom As an alternative, you can try falling back to a two-step launch configuration by launching the application server via the .NET debugger and the front-end client by using the JS debugger.

@connor4312
Copy link

@jtsom here's another alternative that will arrive in the next js-debug nightly microsoft/vscode-js-debug#836

@jtsom
Copy link

jtsom commented Nov 3, 2020

I will give it a try when it drops. Though will it work with the standard launch.json, created by default with the .Net Generate Assets command, given your comment:

This can now be done via the debug.javascript.defaultRuntimeExecutable setting. Note that this happens at config resolution time, so for the moment only works with pwa- prefixed configs (e.g. if you have a launch type named node, then rename it to pwa-node)

@connor4312
Copy link

It will since blazor launches pwa-chrome internally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants