microsoft / microsoft/aspire

Configure Environment of AppHost in Publish Mode

Open
#6,667 0 comments 0 reactions 0 assignees View on GitHub
area-app-model area-deployment
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

When deploying or running Aspire, every project in Aspire has Environment(e,g, Development, Staging, Production).

When we are on Run Mode, we could specify it in launchsettings.json.

But when we are on PublishMode, we could not specify it.

I'm using workaround for this issue.

```C#
if (builder.ExecutionContext.IsPublishMode)
{
var environmentName = builder.AddParameter("hostingEnvironment");
var environmentVariableName = "DOTNET_ENVIRONMENT";
apiService.WithEnvironment(environmentVariableName, environmentName);
webFrontend.WithEnvironment(environmentVariableName, environmentName);
}
```

But this workaround does not works for `builder.Environment` of AppHost itself.
Even if we are deploying for "Production" environment, `builder.Environment` is "Development". It is confusing.

### Describe the solution you'd like

Abillity to select launchSettings.json for each publish profile.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.