Skip to content

Fix interactive C# aspire init config collision#16447

Open
adamint wants to merge 3 commits intomicrosoft:mainfrom
adamint:dev/adamint/issue-15750
Open

Fix interactive C# aspire init config collision#16447
adamint wants to merge 3 commits intomicrosoft:mainfrom
adamint:dev/adamint/issue-15750

Conversation

@adamint
Copy link
Copy Markdown
Member

@adamint adamint commented Apr 24, 2026

Description

Fixes interactive aspire init in 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 the aspire.config.json overwrite collision. The single-file AppHost template now records appHost.language so 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.csproj

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

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>
Copilot AI review requested due to automatic review settings April 24, 2026 22:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16447

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16447"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-singlefile template’s aspire.config.json to include appHost.language.
  • Add a unit regression test and a new end-to-end test covering the interactive default-C# aspire init flow.

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.

Comment thread src/Aspire.Cli/Commands/InitCommand.cs Outdated
Comment thread src/Aspire.Cli/Commands/InitCommand.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@radical radical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two suggestions from review — both are about making the fix more self-documenting and robust.

Comment thread src/Aspire.Cli/Commands/InitCommand.cs Outdated
Comment thread src/Aspire.Cli/Commands/InitCommand.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running aspire init in empty folder fails

3 participants