Skip to content

Commit 301ad26

Browse files
CopilotcaptainsafiaCopilot
authored
Display target environment during aspire deploy (#12218)
* Initial plan * Add environment display to deploy command Co-authored-by: captainsafia <[email protected]> * Apply ToLowerInvariant to environment names Co-authored-by: captainsafia <[email protected]> * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Move environment display to Publisher as a step Co-authored-by: captainsafia <[email protected]> * Change order and logging --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: captainsafia <[email protected]> Co-authored-by: Safia Abdalla <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent b9817e2 commit 301ad26

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Aspire.Hosting/Publishing/Publisher.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ public async Task PublishAsync(DistributedApplicationModel model, CancellationTo
2929
);
3030
}
3131

32+
// Add a step to display the target environment when deploying
33+
if (options.Value.Deploy)
34+
{
35+
var environmentStep = await progressReporter.CreateStepAsync(
36+
"display-environment",
37+
cancellationToken).ConfigureAwait(false);
38+
39+
await using (environmentStep.ConfigureAwait(false))
40+
{
41+
var hostEnvironment = serviceProvider.GetService<Microsoft.Extensions.Hosting.IHostEnvironment>();
42+
var environmentName = hostEnvironment?.EnvironmentName ?? "Production";
43+
44+
var environmentTask = await environmentStep.CreateTaskAsync(
45+
$"Discovering target environment",
46+
cancellationToken)
47+
.ConfigureAwait(false);
48+
49+
await environmentTask.CompleteAsync(
50+
$"Deploying to environment: {environmentName.ToLowerInvariant()}",
51+
CompletionState.Completed,
52+
cancellationToken)
53+
.ConfigureAwait(false);
54+
}
55+
}
56+
3257
// Check if --clear-cache flag is set and prompt user before deleting deployment state
3358
if (options.Value.Deploy && options.Value.ClearCache)
3459
{

0 commit comments

Comments
 (0)