Problem
Launching the App Host run configuration causes every child project launched from App Host to open up in browser. Sample AppHost/Program.cs:
var builder = DistributedApplication.CreateBuilder(args);
var apiService = builder.AddProject<Projects.MyApiService>("apiservice");
builder.AddProject<Projects.MyFrontend>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
.WaitFor(apiService);
builder.Build().Run();
Cause
This behavior is controlled either by IDE settings nor by ExactProject/Properties/launchSettings.json:"launchBrowser": true/false
Resolution
There are two available approaches to come to the desired behavior:
-
Edit per-project
{ExactProject}/Properties/launchSettings.json:"launchBrowser": true/false. This approach allows flexibly setting up which projects Rider should open on App Host run configuration runs.Sample. Consider there are the following projects:
- AppHost; It's
Program.csadds two below projects (code snippet is provided above). - MyApiService; It's
Properties/launchSettings.jsonhas"launchBrowser": false. - MyFrontend; It's
Properties/launchSettings.jsonhas"launchBrowser": true.
Having such a configuration, when the App Host http/https run configuration runs, only the AppHost and MyFrontend will open in browser on AppHost run configuration start. A page for MyApiService will not open in a browser. The disadvantage of that approach is that editing
SampleProject/Properties/launchSettings.jsonaffects the scenario of running the SampleProject project outside App Host. If it has"launchBrowser": false, the app will not open in browser on its start. - AppHost; It's
-
Enable the "Settings | Tools | Aspire | Do not launch the browser for child projects" setting. As it says, when this setting is enabled, child projects launched from App Host will not open up in a browser on App Host launch. Having it turned on, the
{ChildProject}/Properties/launchSettings.json:"launchBrowser": trueis ignored.
It that doesn't help, do not hesitate to report an issue.
Comments
0 comments
Please sign in to leave a comment.