aspire publish + launch profiles
Today when you call aspire publish, it calls dotnet run on the AppHost project without specifying a launch profile. This means that the first launch profile in launchSettings.json is used to execute the AppHost for publishing.
This is a problem because the first launch profile is meant for F5 / local run mode.
https://github.com/dotnet/aspire/blob/8fd92afd7f3d9168c96f52f147a7b301b78ad349/src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.AppHost/Properties/launchSettings.json#L3-L16
Specifically the issue is that "DOTNET_ENVIRONMENT": "Development", is set, which means the AppHost is run with builder.Environment.IsDevelopment() == true. This is the wrong default for aspire publish. Instead when you aspire publish, it should be using the Production environment by default.
We should consider how launch profiles work all up with aspire publish. One strategy we could take:
- Allow the launch profile to be specified via
aspire publish. If it is supplied, use it. This allows for multiple publish profiles to be set in launchSettings.json. - Have a "default" publish launch profile, for example one named
publish. If it is found, use it. - Run the AppHost with
--no-launch-profileif none of the above 2 are true.
Or we could decide that launch profiles don't make sense at all during aspire publish, and always specify --no-launch-profile. But since we are running the AppHost project, it does feel natural to consider a "launch profile".
cc @mitchdenny @DamianEdwards @davidfowl
I think they don’t make much sense for publish but we do want to give people control. Maybe that means a cli arg that maps to ASPIRE_ENVIRONMENT which sets the env appropriately
I think they don’t make much sense for publish but we do want to give people control. Maybe that means a cli arg that maps to ASPIRE_ENVIRONMENT which sets the env appropriately
I think starting from this (a CLI arg for setting environment) plus passing --no-launch-profile to the app host when running it in publish mode is a reasonable start. We can then look at how folks are using the CLI arg to decide whether it's worthwhile supporting an actual launch profile as part of the publish execution.