-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Provide a way to launch the browser when running dotnet run
#9038
Comments
I imagine the idea here is to add the capability for Should it again be similar to what we have in VS? This was one of the reasons why when we talked about this I wanted VS to provide us with a shared library between the CLI and VS. We started the conversation with supporting just a subset of what VS did and now we are adding more and more features to it regarding launchSettings.json. Is it time to re-hash our conversation about having a shared library for launchSettings.json? |
Here is my idea for what we could add to dotnet-watch to make this work well: aspnet/DotNetTools#387 - would require dotnet-run to change launch behavior when started by dotnet-watch. |
I also opened SO thread related to this issue As a developer, my expectation for |
Adding @vijayrkn and @mlorbetske who added the original support to launchsettings.json to the CLI. launchsettings.json was originally added to the CLI because we needed it to support HTTPS and a couple other features of ASP.NET that would not work without it. There are many different details on launchsettings.json that will take a while to bring to parity. Besides, as it was originally developed to VS, there are things that don't directly translate to the command line experience that we need to discuss and find an alternative for. |
The recently demonstrated HTTP CLI for Web APIs would add to that.. |
But until "full" launchSettings party, even something as "simple" as opening the URL would be cool - similar to what @natemcmaster's |
The current handling for launch settings ends before the app actually starts running. Spawning another process or thread to launch the browser once the port for the app opens (and terminating that thread or process in the event that the app fails to start) seems like it’d be the thing to do here. |
Definitely agree. Another idea I had was to build a "callback" command line into "dotnet run" that could execute after the run has fully started. Such would remind me of
To be clear, I called it after-init but maybe there's a better term for "run this after the initial steps are done and the executable is running." This would be more flexible than starting a browser directly. |
@KathleenDollard Many of the users that we tested the Blazor getting started experience with expected |
Do the Blazor templates create a launchUrl / launchBrowser in launchSettings.json? This could be used unless a user runs |
@dasMulli I believe pretty much all of the ASP.NET Core templates set |
Quick prototype tells me that there is already logic that looks for aa Quick protoype wires it up: dasMulli/sdk@master...dasMulli:prototype/dotnet-run-open-browser @danroth27 looks like the templates do set ToDos / Thoughts for continuing on that prototype:
|
I'd be happy to work on this, though i'd need some definitive input on the canonical understanding of |
|
Would be cool to see such feature, but I'd prefer a richer functionality:
|
I guess additional options could go into launchSettings.json in some form as well to be less breaking. |
Been browsing around a bit and only found references that it is "mostly" okay but one could bundle it. the |
@pranavkm didn't we do this in 5.0.0? |
I have to support #9038 (comment) Working with Blazor WASM on Linux (where firefox often is the default browser for good reasons: My current solution is to use 2 terminals Terminal 1 $ dotnet run --no-launch-profile Terminal 2 $ google-chrome http://localhost:5000 One strange thing is that I can't seem to get this to work with Terminal 1 $ dotnet watch run --no-launch-profile does use the default REQUEST: Add new "profiles": {
"BlazorWasmApp": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"browsers": ["chrome"], <---- REQEUST: Please add this feature
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
} NOTE: Each opened browser should probably also have config values for extra args. I guess this all starts to be a bit platform dependent, but a design should be possible accross windows, macos and the dotnet supported linux distros. |
+1 |
It seems that this been fixed in version 6.0.201. Can anybody else confirm? Update: We use |
It should work in |
@janaagaard75 I am on 6.0.201 and the browser is not opening on |
Use compounds launch settings in VS Code
This will run the app and launch chrome at the URL you want. |
This feature is still not added even in .NET 7 :( |
It would be great to add this - the mechanism clearly exists in 'watch' already, we should look at what it would take to reuse it. I've added the help wanted label to signify that we'd gladly take contributions here - we'd want to keep the behaviors the same between watch and run commands, but if someone took a pass at it the team would love to help get it over the finish line. |
I use net 6.0 Works for me this way note in launch.json "uriFormat": "%s/swagger/index.html"
in vscode or linux console and launch the bowser on swagger page. |
Related issue: dotnet/aspire#3812 @davidfowl Please provide details about how the auth works so that it can be incorporated into |
It would be great if there was a way to run an ASP.NET Core app from the command line using
dotnet run
and have the default browser launch at the right URL. CLIs for other platforms let you do this. For example, with the Angular CLI you can dong serve --open
to both run the app and open the default browser.This would be particularly useful for projects that you created using VS, which generate random ports for the server URLs.
There are already
launchBrowser
andlaunchUrl
properties the launch profiles inlaunchSettings.json
that let you specify that you want this behavior in VS.We would also want this to work with
dotnet watch
without having the browser pop up multiple times, which may require some coordination.@mlorbetske @natemcmaster @livarcocc @KathleenDollard
The text was updated successfully, but these errors were encountered: