dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.87k stars 467 forks source link

Aspire dies silently having failed to launch browser when running `dotnet watch run` on .NET 9 RC1 #5838

Closed DovydasNavickas closed 2 weeks ago

DovydasNavickas commented 1 month ago

Is there an existing issue for this?

Describe the bug

I have transitioned the project I have to .NET 9 RC1 and running aspire as usual with dotnet watch run resulted in it hanging and not giving the token for the dashboard in the console. As the dashboard itself ran successfully and could be reached on https://localhost:17259, this spiraled into a long ghost hunt. Afterwards, I ran dotnet watch run --verbose (should have started with that.... 🫠 ), I got to the culprit: An exception occurred when attempting to launch a browser

Full logs:

warn: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[9]
      The ASP.NET Core developer certificate is only trusted by some clients. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.2.0+75fdcff28495bdd643f6323133a7d411df71ab70
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /home/devops/data/projects/company/project/src/projects/Company.AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:17259
dotnet watch ⌚ Launching browser: https://localhost:17259/ 
dotnet watch ⌚ An exception occurred when attempting to launch a browser: System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'https://localhost:17259/' with working directory '/home/devops/data/projects/company/project/src/projects/Company.AppHost'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.DotNet.Watcher.Tools.BrowserConnector.LaunchBrowser(LaunchSettingsProfile launchProfile, String launchUrl)

This seems like a pretty important error to print to the developer as I am running in WSL and it simply fails opening the browser.

Also, what's worse, dotnet run simply worked and no error happened even with --verbose.

Not sure if this has something to do with .NET 9 RC1 or I just stumbled upon some other bug after updating everything.

Expected Behavior

An error would be printed to the console, when Aspire fails to run open the browser. I would have set "launchBrowser": false and called it a night 😄

Steps To Reproduce

If this is not reproducible with just running the project with <TargetFramework>net9.0</TargetFramework> and .NET 9 RC1, I will investigate further.

I used:

<PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.0" />

Exceptions (if any)

No response

.NET Version info

dotnet --info .NET SDK: Version: 9.0.100-rc.1.24452.12 Commit: 81a714c6d3 Workload version: 9.0.100-manifests.67cd1eb6 MSBuild version: 17.12.0-preview-24422-09+d17ec720d

Runtime Environment: OS Name: debian OS Version: 12 OS Platform: Linux RID: linux-x64 Base Path: /home/devops/.dotnet/sdk/9.0.100-rc.1.24452.12/

.NET workloads installed: Configured to use loose manifests when installing new manifests. [aspire] Installation Source: SDK 9.0.100-rc.1 Manifest Version: 8.2.0/8.0.100 Manifest Path: /home/devops/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.2.0/WorkloadManifest.json Install Type: FileBased

Host: Version: 9.0.0-rc.1.24431.7 Architecture: x64 Commit: static

.NET SDKs installed: 8.0.303 [/home/devops/.dotnet/sdk] 8.0.400 [/home/devops/.dotnet/sdk] 8.0.401 [/home/devops/.dotnet/sdk] 9.0.100-rc.1.24452.12 [/home/devops/.dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.7 [/home/devops/.dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.8 [/home/devops/.dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 9.0.0-rc.1.24452.1 [/home/devops/.dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.7 [/home/devops/.dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.8 [/home/devops/.dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 9.0.0-rc.1.24431.7 [/home/devops/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: DOTNET_ROOT [/home/devops/.dotnet]

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Anything else?

Aspire.Hosting.AppHost: 8.2.0

davidfowl commented 2 weeks ago

dotnet watch is being re-designed to work with aspire. That work is happening in 9.0.200 SDK which is not shipping with .NET 9. This has been fixed in that branch.

You can see the work items for watch and aspire here https://github.com/dotnet/sdk/issues?q=is%3Aissue%20label%3AAspire%20