Skip to content

[release/17.0] Remove redundant CLI bundle opt-ins from templates - #22226

Open
Eric Erhardt (eerhardt) wants to merge 2 commits into
release/17.0from
backport/21986-template-cli-bundle
Open

Eric Erhardt (eerhardt) wants to merge 2 commits into
release/17.0from
backport/21986-template-cli-bundle

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Backport of #21986 to release/17.0.

Description

Current C# AppHost SDKs enable the CLI bundle by default. Remove the redundant AspireUseCliBundle opt-in from the project and single-file templates and from aspire init. An explicitly inherited AspireUseCliBundle=false (environment or Directory.Build.props) now takes effect and the SDK reports ASPIRE013.

The cherry-pick conflicted in tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs; the ASPIRE015 tests that exist only on main were not carried over.

Validation

  • Passed: dotnet test --project tests/Aspire.Hosting.Sdk.Tests/Aspire.Hosting.Sdk.Tests.csproj --no-launch-profile -- --filter-method "*CliBundle*" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true" (42 passed, 1 skipped).
  • Not run: Aspire.Cli.Tests and the CLI E2E tests.

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
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

Backport of #21986

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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 -- 22226

Or

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

@github-actions

This comment has been minimized.

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 updated test expectations and snapshot omit the compatibility directive still emitted by 17.0.0-pr.* CLI builds, causing mismatches in PR CI.

2 open issues
What changed in this PR

Backports #21986 to release/17.0, removing redundant CLI bundle opt-ins so current C# AppHosts use SDK defaults and respect inherited settings.

Changes:

  • Removes explicit bundle settings from project templates, single-file templates, and aspire init.
  • Preserves compatibility directives for versions before 17.0 and all 17.0.0 prereleases.
  • Updates generation, SDK, and end-to-end tests, including coverage for inherited AspireUseCliBundle=false producing ASPIRE013.
File Description
tests/​Aspire.Hosting.Sdk.Tests/​AppHostSdkTargetsTests.cs Tests bundle defaults and inherited opt-outs.
tests/​Aspire.Cli.Tests/​Snapshots/​InitCommandTests.InitCommand_FileBased_SkipsSolutionDiscovery.verified.txt Removes the explicit bundle directive from expected output.
tests/​Aspire.Cli.Tests/​Commands/​NewCommandTests.cs Checks version-dependent generated directives.
tests/​Aspire.Cli.Tests/​Commands/​InitCommandTests.cs Adds version-dependent initialization expectations.
tests/​Aspire.Cli.EndToEnd.Tests/​SingleFileAppHostInitDotnetRunTests.cs Updates generated-source checks and clears the inherited bundle setting.
tests/​Aspire.Cli.EndToEnd.Tests/​BundleSmokeTests.cs Updates project and single-file bundle checks.
src/​Aspire.ProjectTemplates/​templates/​aspire-ts-cs-starter/​Aspire-StarterApplication.1.AppHost/​Aspire-StarterApplication.1.AppHost.csproj Removes the starter’s explicit bundle opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-starter/​Aspire-StarterApplication.1.AppHost/​Aspire-StarterApplication.1.AppHost.csproj Removes the starter’s explicit bundle opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-empty/​AspireApplication.1.AppHost/​AspireApplication.1.AppHost.csproj Removes the empty project’s explicit bundle opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-apphost/​Aspire.AppHost1.csproj Removes the AppHost project’s explicit bundle opt-in.
src/​Aspire.ProjectTemplates/​templates/​aspire-apphost-singlefile/​apphost.cs Removes the single-file template’s bundle directive.
src/​Aspire.Cli/​Templating/​Templates/​empty-apphost/​apphost.cs Delegates bundle directives to version-aware generation.
src/​Aspire.Cli/​Templating/​CliTemplateFactory.EmptyTemplate.cs Retains explicit opt-ins only for compatibility versions.
src/​Aspire.Cli/​Commands/​InitCommand.cs Uses the shared directive generator without an unconditional opt-in.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

…erelease CLI identity

- InitCommandTests: pin the file-based init test's execution context to a
  stable 17.0.0 identity so the snapshot doesn't depend on whether CI's
  assembly version happens to be a 17.0.0-pr.* prerelease (which would
  retain the AspireUseCliBundle=true compatibility directive).
- BundleSmokeTests/SingleFileAppHostInitDotnetRunTests: compute the expected
  AppHost source using the installed CLI's actual version, adding the
  compatibility directive only when the version matches the same
  pre-17/17.0.0-prerelease rule used by GetCSharpAppHostDirectives.

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

Copy link
Copy Markdown
Contributor

Tests selector

4 / 101 PR test projects · 6 PR jobs, from 15 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/Helpers/CliE2ETestHelpers.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 1a518a7.

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 were identified for the CLI bundle-default backport.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants