aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Aspire disregards specified launch-settings commands

Open g-martin772 opened this issue 1 year ago • 10 comments

When running a Project with Aspire locally there is the option to specify a launch profile in the builder.AddProject(string, string), which is being ten being read. After reviewing the code a bit, it appears that only the "applicationUrl" and "commandLineArgs" fields are being evaluated. Personally, I am mostly interested in the "executablePath" field. For example, referencing the dotnet executable to run the project using .NET "dotnet watch" when running locally to enable nice hot reloading (outside of VS, and yes, I am aware of the open SDK issue regarding watch support for aspire).

"Watch": {
      "commandName": "Executable",
      "executablePath": "dotnet",
      "workingDirectory": "$(ProjectDir)",
      "hotReloadEnabled": true,
      "hotReloadProfile": "aspnetcore",
      "commandLineArgs": "watch run",
      "launchBrowser": false,
      "applicationUrl": "http://localhost:4110",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },

This is what I used to do with basically all of my projects and it used to work pretty great so far, and I don't know if I am going insane at that point but I feel like this also used to work when running in Aspire....

It would be cool if the "commandName" and "executablePath" (and maybe some of the other more relevant fields as well) would be interpreted correctly. I think this should only require changes to the builder and how the executable path is being set in the end. I actually tried implementing this myself but it didn't work as expected.

Would this be possible or is running the application directly a strict requirement here?

g-martin772 avatar Jul 15 '24 17:07 g-martin772

Could I please get any feedback on this?

g-martin772 avatar Jul 28 '24 14:07 g-martin772

I think this would break debugging. Maybe that's ok in this situation?

davidfowl avatar Sep 07 '24 08:09 davidfowl

Ahh, yes, thats probably true. But for everyone working outside of visual studio having atleast some sort of hot reloading whould really be great. I know some of thoose things are still being worked on. Whould this be a viable option to consider? Otherwise you can just close the issue.

g-martin772 avatar Sep 07 '24 09:09 g-martin772

You can use dotnet watch on the apphost project today without changing the launch profile.

davidfowl avatar Sep 07 '24 17:09 davidfowl

Yes, but doesn’t that only apply to the apphost itself? I am talking about making this work for "sub project" aswell that are started using the apphost because you have no control on how it does that internally.

g-martin772 avatar Sep 07 '24 17:09 g-martin772

No it doesn’t. It’s handled specially

davidfowl avatar Sep 07 '24 22:09 davidfowl

I am on the latest version of .NET 8 and Aspire workloads and then I run the apphost project from the terminal using dotnet watch I only get

 dotnet watch
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.                 
  💡 Press "Ctrl + R" to restart.                                                                                        
dotnet watch ⌚ Started                                                                                                   
Building...                                                                                                              
C:\dev\work\AspireApp1\AspireApp1.AppHost\AspireApp1.AppHost.csproj : warning NU1903: Package 'System.Text.Json' 8.0.0 has a known high severity vulnerability, https://github.com/advisories/GHSA-hh2w-p6rv-4g7w
C:\dev\work\AspireApp1\AspireApp1.AppHost\AspireApp1.AppHost.csproj : warning NU1903: Package 'System.Text.Json' 8.0.0 has a known high severity vulnerability, https://github.com/advisories/GHSA-hh2w-p6rv-4g7w
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: C:\dev\work\AspireApp1\AspireApp1.AppHost
info: Aspire.Hosting.DistributedApplication[0]
      Now listening on: https://localhost:15222

instead of what I get when launching it via IDE:

image

Also using the default Aspire App template, even with dotnet watch, it does not recognize file changes to for example the razor home page in the Web Project. I also found this issue which still seems to be not resolved. Am I doing something wrong here?

g-martin772 avatar Sep 08 '24 04:09 g-martin772

Does it detect changes to .cs files?

davidfowl avatar Sep 08 '24 05:09 davidfowl

Only in the apphost project, it doesn't pick up any other changes.

g-martin772 avatar Sep 08 '24 10:09 g-martin772

We're updating dotnet watch to better handle aspire scenarios (it'll make things like razor files work and it'll be more incremental for aspire), hopefully it will fix these problems.

Follow this issue https://github.com/dotnet/sdk/issues/36971

davidfowl avatar Oct 03 '24 04:10 davidfowl

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

davidfowl avatar Nov 01 '24 09:11 davidfowl

For the original issue https://github.com/dotnet/aspire/issues/5310

davidfowl avatar Nov 01 '24 09:11 davidfowl