Skip to content

Remove redundant CLI bundle opt-ins from templates - #21986

Merged
Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-template-cli-bundle
Nov 12, 2026
Merged

Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt-template-cli-bundle

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Description

Current C# AppHost SDKs enable the CLI bundle by default. Remove the redundant opt-in from the project and single-file templates and from aspire init.

Previously, generated project files contained <AspireUseCliBundle>true</AspireUseCliBundle> and single-file AppHosts contained #:property AspireUseCliBundle=true. Current templates now omit those settings. CLI generation still emits the directive for versions before 17.0 and all 17.0.0 prereleases, because their defaults can differ.

This also allows an explicitly inherited AspireUseCliBundle=false from the environment or Directory.Build.props to take effect instead of being overridden by the generated project. The SDK reports ASPIRE013 in that configuration.

Validation

  • Passed: 11 focused CLI generation and snapshot tests.
    $env:MSBUILDTERMINALLOGGER='false'
    dotnet test --project tests\Aspire.Cli.Tests\Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method '*.NewCommandCSharpTemplateUsesVersionCompatibleDirectives' --filter-method '*.InitCommand_WhenNoSolutionExists_SingleFileSkeletonUsesVersionCompatibleDirectives' --filter-method '*.InitCommand_FileBased_SkipsSolutionDiscovery' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • Passed: 13 SDK default, run-hook, and inherited-setting tests.
    $env:MSBUILDTERMINALLOGGER='false'
    $env:MSBUILDDISABLENODEREUSE='1'
    dotnet test --project tests\Aspire.Hosting.Sdk.Tests\Aspire.Hosting.Sdk.Tests.csproj -c Release --no-launch-profile -- --filter-method '*.ComputeRunArgumentsUsesAspireCliWhenCliBundleIsEnabledOrDefaulted' --filter-method '*.ComputeRunArgumentsUsesFileBasedAppHostPathWhenCliBundleIsEnabledOrDefaulted' --filter-method '*.CSharpAppHostRespectsInheritedDisabledCliBundle' --filter-method '*.AddReferenceToDashboardAndDcpIsSkippedWhenCliBundleIsDefaulted' --filter-method '*.NonCSharpAppHostsDefaultToDisabledCliBundle' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
  • Passed: CLI E2E test project Release build.
    dotnet build tests\Aspire.Cli.EndToEnd.Tests\Aspire.Cli.EndToEnd.Tests.csproj -c Release --no-restore --verbosity quiet
  • Not run: the Linux CLI E2E scenarios. Building their local bundle from Windows failed because Linux NativeAOT tray publishing requires a Linux build lane.

Fixes # (issue)

cc Damian Edwards (@DamianEdwards) Karol Zadora-Przylecki (@karolz-ms) Mitch Denny (@mitchdenny)

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 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 -- 21986

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the changes removing redundant CLI bundle opt-ins.

No open issues 🎉

What changed in this PR

Removes redundant CLI bundle opt-ins from generated C# AppHosts, allowing current SDK defaults and inherited settings to take effect while preserving compatibility with older SDKs.

Changes:

  • Removes explicit bundle settings from project templates, single-file templates, and aspire init.
  • Retains explicit opt-in directives for versions before 17.0 and all 17.0.0 prereleases.
  • Updates generation, SDK, and end-to-end tests to cover default behavior and inherited disabling.
File Description
tests/​Aspire.Hosting.Sdk.Tests/​AppHostSdkTargetsTests.cs Tests bundle defaults and inherited disabling.
tests/​Aspire.Cli.Tests/​Snapshots/​InitCommandTests.InitCommand_FileBased_SkipsSolutionDiscovery.verified.txt Updates expected output without the opt-in.
tests/​Aspire.Cli.Tests/​Commands/​NewCommandTests.cs Verifies version-dependent generated directives.
tests/​Aspire.Cli.Tests/​Commands/​InitCommandTests.cs Tests version-compatible init skeletons.
tests/​Aspire.Cli.EndToEnd.Tests/​SingleFileAppHostInitDotnetRunTests.cs Checks init output with no environment override.
tests/​Aspire.Cli.EndToEnd.Tests/​BundleSmokeTests.cs Checks project and single-file bundle defaults.
src/​Aspire.ProjectTemplates/​templates/​aspire-ts-cs-starter/​Aspire-StarterApplication.1.AppHost/​Aspire-StarterApplication.1.AppHost.csproj Removes the mixed-language starter opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-starter/​Aspire-StarterApplication.1.AppHost/​Aspire-StarterApplication.1.AppHost.csproj Removes the starter project opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-empty/​AspireApplication.1.AppHost/​AspireApplication.1.AppHost.csproj Removes the empty project opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-apphost/​Aspire.AppHost1.csproj Removes the AppHost project opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-apphost-singlefile/​apphost.cs Removes the single-file template opt-in.
src/​Aspire.Cli/​Templating/​Templates/​empty-apphost/​apphost.cs Delegates bundle directives to version-aware generation.
src/​Aspire.Cli/​Templating/​CliTemplateFactory.EmptyTemplate.cs Emits bundle opt-ins only for older versions.
src/​Aspire.Cli/​Commands/​InitCommand.cs Uses shared version-aware directives without an unconditional opt-in.

Review effort: Balanced

@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@eerhardt

Copy link
Copy Markdown
Member Author

/backport to release/17.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/17.0 (link to workflow run)

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Eric Erhardt (@eerhardt) backporting to release/17.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Remove redundant CLI bundle setting from templates
Using index info to reconstruct a base tree...
M	tests/Aspire.Cli.EndToEnd.Tests/SingleFileAppHostInitDotnetRunTests.cs
M	tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs
Falling back to patching base and 3-way merge...
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/SingleFileAppHostInitDotnetRunTests.cs
Auto-merging tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Remove redundant CLI bundle setting from templates
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

4 / 101 PR test projects · 6 PR jobs, from 14 changed files.

Selected PR test projects (4 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Hosting.Sdk.Tests, Aspire.Templates.Tests

Selected PR jobs (6)

cli-starter-validation, extension-e2e, homebrew-installer, polyglot, typescript-api-compat, winget-installer


How these were chosen — grouped by what changed

🔧 src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/apphost.cs (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

🔧 src/Aspire.ProjectTemplates/templates/aspire-apphost/Aspire.AppHost1.csproj (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

🔧 src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.AppHost/AspireApplication.1.AppHost.csproj (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

🔧 src/Aspire.ProjectTemplates/templates/aspire-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

🔧 src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj (changed source)
→ 3 directly: Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Aspire.Templates.Tests

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/BundleSmokeTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/SingleFileAppHostInitDotnetRunTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Snapshots/InitCommandTests.InitCommand_FileBased_SkipsSolutionDiscovery.verified.txt (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs (changed test)
→ 1 directly: Aspire.Hosting.Sdk.Tests

Job reasons

Job Triggered by
cli-starter-validation • src/Aspire.ProjectTemplates/templates/aspire-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj
• affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Commands/InitCommand.cs, src/Aspire.Cli/Templating/CliTemplateFactory.EmptyTemplate.cs, src/Aspire.Cli/Templating/Templates/empty-apphost/apphost.cs
• affected project Aspire.Cli
homebrew-installer src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/apphost.cs, src/Aspire.ProjectTemplates/templates/aspire-apphost/Aspire.AppHost1.csproj, src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.AppHost/AspireApplication.1.AppHost.csproj, src/Aspire.ProjectTemplates/templates/aspire-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj, src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli
winget-installer src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/apphost.cs, src/Aspire.ProjectTemplates/templates/aspire-apphost/Aspire.AppHost1.csproj, src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.AppHost/AspireApplication.1.AppHost.csproj, src/Aspire.ProjectTemplates/templates/aspire-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj, src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj

Selection computed for commit 4eea94e.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The tests reject valid templates from supported CLI installations, including 17.0.0 prereleases and older distributions, causing failures before the intended dotnet run coverage.

2 open issues

Review effort: Balanced

@eerhardt
Eric Erhardt (eerhardt) merged commit 9a55fd8 into main Nov 12, 2026
252 of 253 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 12, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2137

Generated by PR Documentation Check · copilot · auto · 27.3 AIC · ⌖ 1.26 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2137 targeting release/17.0.

Updated get-started/aspire-sdk.mdx to reflect that templates/aspire init no longer emit AspireUseCliBundle. Signals: project_template_changed (template csproj/apphost.cs files), cli_command_file_changed (InitCommand.cs), pr_body_has_cli_flag_mention. Please confirm the ASPIRE013 wording.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants