diff --git a/src/Aspire.Hosting/Publishing/Publisher.cs b/src/Aspire.Hosting/Publishing/Publisher.cs index c609aa3c741..8479cb3aee8 100644 --- a/src/Aspire.Hosting/Publishing/Publisher.cs +++ b/src/Aspire.Hosting/Publishing/Publisher.cs @@ -29,6 +29,31 @@ public async Task PublishAsync(DistributedApplicationModel model, CancellationTo ); } + // Add a step to display the target environment when deploying + if (options.Value.Deploy) + { + var environmentStep = await progressReporter.CreateStepAsync( + "display-environment", + cancellationToken).ConfigureAwait(false); + + await using (environmentStep.ConfigureAwait(false)) + { + var hostEnvironment = serviceProvider.GetService(); + var environmentName = hostEnvironment?.EnvironmentName ?? "Production"; + + var environmentTask = await environmentStep.CreateTaskAsync( + $"Discovering target environment", + cancellationToken) + .ConfigureAwait(false); + + await environmentTask.CompleteAsync( + $"Deploying to environment: {environmentName.ToLowerInvariant()}", + CompletionState.Completed, + cancellationToken) + .ConfigureAwait(false); + } + } + // Check if --clear-cache flag is set and prompt user before deleting deployment state if (options.Value.Deploy && options.Value.ClearCache) {