The preceding launch settings for the ApiService ASP.NET Core project resource results in this situation:
Basically, the launch settings are correctly read and loaded, but the ASPNETCORE_URLS environment variable is set by Aspire, disregarding them.
This is due to code in src/Aspire.Hosting/Dcp/ApplicationExecutor.cs, inside the ApplyLaunchProfile method.
if (executableResource.DcpResource is ExecutableReplicaSet)
{
var urls = executableResource.ServicesProduced.Select(sar =>
{
var url = sar.EndpointAnnotation.UriScheme + "://localhost:{{- portForServing \"" + sar.Service.Metadata.Name + "\" -}}";
return url;
});
config.Add("ASPNETCORE_URLS", string.Join(";", urls));
}
else
{
config.Add("ASPNETCORE_URLS", launchProfile.ApplicationUrl);
}
This check is flawed, because, while you indeed need to use generated portForServing when you have multiple replicas to avoid conflicts, a single replica can and should use the launch profile's applicationUrl property.
A simple fix should be to actually check this (I'll make a PR for it).
In Aspire, an ASP.NET Core project's
applicationUrl
property of the launchSettings.json profile is not respected.Project.ApiService\Properties\launchSetting.json
The preceding launch settings for the ApiService ASP.NET Core project resource results in this situation:
Basically, the launch settings are correctly read and loaded, but the
ASPNETCORE_URLS
environment variable is set by Aspire, disregarding them.This is due to code in
src/Aspire.Hosting/Dcp/ApplicationExecutor.cs
, inside theApplyLaunchProfile
method.This check is flawed, because, while you indeed need to use generated
portForServing
when you have multiple replicas to avoid conflicts, a single replica can and should use the launch profile'sapplicationUrl
property.A simple fix should be to actually check this (I'll make a PR for it).