Fix interactive C# aspire init config collision#16447
Open
adamint wants to merge 3 commits intomicrosoft:mainfrom
Open
Fix interactive C# aspire init config collision#16447adamint wants to merge 3 commits intomicrosoft:mainfrom
adamint wants to merge 3 commits intomicrosoft:mainfrom
Conversation
Avoid writing local language config before the single-file C# AppHost template runs, and include the C# language metadata in the generated config. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16447Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16447" |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an aspire init failure in empty folders when accepting the default C# AppHost language by avoiding a premature aspire.config.json write that caused dotnet new to fail due to conflicting files.
Changes:
- Stop persisting the prompted language selection before running the single-file C# template; persist only after successful scaffolding where appropriate.
- Update the
aspire-apphost-singlefiletemplate’saspire.config.jsonto includeappHost.language. - Add a unit regression test and a new end-to-end test covering the interactive default-C#
aspire initflow.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Aspire.Cli/Commands/InitCommand.cs | Defers language persistence to avoid aspire.config.json overwrite collisions during single-file C# init. |
| src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json | Ensures the single-file AppHost template emits appHost.language in config. |
| tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs | Adds regression coverage for the collision scenario described in #15750. |
| tests/Aspire.Cli.EndToEnd.Tests/CSharpInitTests.cs | Adds interactive E2E coverage to ensure default C# init succeeds and outputs expected files/config. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
radical
reviewed
Apr 24, 2026
Member
radical
left a comment
There was a problem hiding this comment.
Two suggestions from review — both are about making the fix more self-documenting and robust.
radical
approved these changes
Apr 24, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes interactive
aspire initin an empty folder when the user accepts the default C# AppHost language. The language selection is no longer written to local config before the single-file C# template runs, which avoids theaspire.config.jsonoverwrite collision. The single-file AppHost template now recordsappHost.languageso the generated config still has complete AppHost metadata.Fixes #15750
Validation:
dotnet test tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj -- --filter-class "*.InitCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csprojChecklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: