Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that projects with no launch profile can still run #478

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Aspire.Hosting/Dcp/ApplicationExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ internal sealed class ApplicationExecutor(DistributedApplicationModel model) : I
{
private const string DebugSessionPortVar = "DEBUG_SESSION_PORT";

// These environment variables should never be inherited from app host;
// they only make sense if they come from a launch profile of a service project.
private static readonly string[] s_doNotInheritEnvironmentVars =
{
"ASPNETCORE_URLS",
"DOTNET_LAUNCH_PROFILE",
"ASPNETCORE_ENVIRONMENT",
"DOTNET_ENVIRONMENT"
};

private readonly DistributedApplicationModel _model = model;
private readonly List<AppResource> _appResources = new();
private readonly KubernetesService _kubernetesService = new();
Expand Down Expand Up @@ -368,6 +378,14 @@ private async Task CreateExecutablesAsync(IEnumerable<AppResource> executableRes
{
ApplyLaunchProfile(er, config, launchProfileName, launchSettings);
}
else
{
// If there is no launch profile, we want to make sure that certain environment variables are NOT inherited
foreach (var envVar in s_doNotInheritEnvironmentVars)
{
config.Add(envVar, "");
}
}

if (er.ModelResource.TryGetEnvironmentVariables(out var envVarAnnotations))
{
Expand Down