Skip to content

fix(cli): use matching PR packages for PR-acquired aspire new#17280

Merged
radical merged 5 commits into
microsoft:mainfrom
radical:radical/fix-pr-cli-restore-source
May 20, 2026
Merged

fix(cli): use matching PR packages for PR-acquired aspire new#17280
radical merged 5 commits into
microsoft:mainfrom
radical:radical/fix-pr-cli-restore-source

Conversation

@radical
Copy link
Copy Markdown
Member

@radical radical commented May 19, 2026

Description

A PR-acquired Aspire CLI should scaffold aspire new projects from the matching PR packages without requiring users to pass --source. This affects dogfood flows such as:

aspire new aspire-empty --language csharp
aspire new aspire-empty --language typescript
aspire new aspire-starter

Before this change, those scenarios could mix the PR CLI/runtime/codegen assemblies with packages from normal configured sources. The observed TypeScript empty AppHost failure was:

RPC server exception:
System.TypeLoadException: Could not load type 'Aspire.TypeSystem.AtsJsonCodeWriter'

The root cause was that channel discovery only looked under the default Aspire hives directory. A CLI installed with get-aspire-cli-pr can run from a dogfood install prefix where the matching pr-<N> package hive lives beside the installed CLI, so implicit template/restore paths could miss that source.

This change discovers the matching co-installed PR hive for pr-<N> CLI identities when the running CLI path matches the PR dogfood archive layout. That discovered hive is added as the PR channel and preferred over a same-named stale default hive, so aspire new uses the package source that matches the running PR CLI.

The scenario-level behavior changes are:

  • C# empty AppHost creation writes apphost.cs and nuget.config from the matching PR hive.
  • Guest AppHost templates for TypeScript, Python, Go, Java, and Rust persist the matching pr-<N> channel for SDK restore/codegen.
  • Dotnet-template-backed aspire new templates, including starter/service-defaults templates, install and scaffold from the discovered PR hive when no explicit source or channel is supplied.
  • Non-PR identities, explicit --source, explicit/configured channels, and malformed or mismatched install layouts keep the existing behavior.

Fixes #17225

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

github-actions Bot commented May 19, 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 -- 17280

Or

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

@radical radical changed the title fix(cli): use PR dogfood hive for PR-acquired CLI restores fix(cli): use PR dogfood hive for PR-acquired AppHost templates May 19, 2026
@radical radical force-pushed the radical/fix-pr-cli-restore-source branch from b6666fa to 8f89514 Compare May 20, 2026 03:43
radical and others added 4 commits May 20, 2026 01:06
A PR-acquired CLI installed under a custom dogfood prefix did not
materialize its matching local package hive unless that hive also lived
under the default Aspire home. Empty AppHost creation could then resolve
Aspire packages from the normal channels or from a stale same-named hive,
which breaks the version/source coherence expected for PR dogfood builds.

Discover the co-installed package hive from the running PR CLI layout and
prefer it over a same-named default hive. Invalid, missing, mismatched, or
non-PR layouts fall back to the existing channel list instead of failing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover the real new-command path for empty AppHost creation with a
PR-acquired CLI layout. The matrix verifies that C# uses the PR hive for
template generation and NuGet.config, while guest languages persist the
matching PR channel and SDK version before prebuilt AppHost preparation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR-acquired CLI installs place their matching package hive under the
install prefix, outside the default Aspire hives directory. Dotnet-backed
`aspire new` templates still used the default hive count as the only local
build signal, so they could ignore the co-installed PR hive and resolve
from the implicit channel instead.

Treat a discovered explicit local-build channel as a hive signal when
resolving template packages. Expand the PR dogfood regression coverage to
account for every registered `aspire new` template, with an explicit
exclusion for the interactive `aspire-test` wrapper.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The template package resolver should not treat every registered `pr-*`
channel as an installed hive. That made the hive-gate test select the PR
channel even when no local hive/source existed on disk.

Keep the dogfood install-prefix behavior, but only count a local-build
channel as a hive signal when its Aspire package source is a local path
that exists. Arbitrary registered channels without installed packages keep
falling back to the implicit channel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@radical radical force-pushed the radical/fix-pr-cli-restore-source branch from ac646ff to aa600cf Compare May 20, 2026 05:10
@radical radical changed the title fix(cli): use PR dogfood hive for PR-acquired AppHost templates fix(cli): use matching PR packages for PR-acquired aspire new May 20, 2026
@radical
Copy link
Copy Markdown
Member Author

radical commented May 20, 2026

PR Testing Report

PR Information

CLI Version Verification

  • Expected Commit: aa600cf
  • Installed Version: 13.4.0-pr.17280.gaa600cf8
  • Status: ✅ Verified

Changes Analyzed

Files Changed

  • src/Aspire.Cli/Packaging/PackagingService.cs
  • src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs
  • tests/Aspire.Cli.Tests/Commands/NewCommandTemplateConfigPersistenceTests.cs
  • tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs

Change Categories

  • CLI changes detected — packaging and template NuGet configuration behavior.
  • Hosting integration changes
  • Dashboard changes
  • Client/Component changes
  • Template file changes
  • Test changes detected — CLI packaging and new-command template config tests.

Test Scenarios Executed

Scenario 1: Version verification

Objective: Install the PR CLI and verify aspire --version contains aa600cf8.
Status: ✅ Verified

Steps:

  1. Ran the Dogfood PR install command from the PR comment with --install-path /Users/ankj/.copilot/p17280-053413 --skip-path --skip-extension.
  2. Located installed binary at /Users/ankj/.copilot/p17280-053413/dogfood/pr-17280/bin/aspire.
  3. Ran the installed binary directly with --version.

Evidence:

  • Install log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/install.log
  • Version log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/version.log

Observations:
Installed version: 13.4.0-pr.17280.gaa600cf8.


Scenario 2: C# empty AppHost without source

Objective: Verify no-explicit-source C# template creation uses the matching PR hive.
Status: ✅ Passed

Steps:

  1. Ran installed PR CLI directly.\n2. Used a fresh output path.\n3. Ran aspire new aspire-empty --language csharp without --source or --version.\n4. Checked generated nuget.config.

Evidence:

  • Log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/csharp-empty.log\n- Generated config checked before cleanup: /Users/ankj/.copilot/p17280-053413/s/cs/CsEmptyNoSource/nuget.config

Observations:
Generated nuget.config references /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages.


Scenario 3: TypeScript empty AppHost without source

Objective: Verify TypeScript template creation succeeds without the AtsJsonCodeWriter mismatch and pins pr-17280.
Status: ✅ Passed

Steps:

  1. Ran aspire new aspire-empty --language typescript without --source or --version.\n2. Searched output for pr-17280.\n3. Checked the command log for absence of AtsJsonCodeWriter.

Evidence:

  • Log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/typescript-empty.log\n- Output searched before cleanup: /Users/ankj/.copilot/p17280-053413/s/ts/TsEmptyNoSource

Observations:
Template succeeded, output pins pr-17280, and no AtsJsonCodeWriter mismatch appeared.


Scenario 4: Starter template without source

Objective: Verify aspire-starter scaffolds from the discovered PR hive without explicit source/version.
Status: ✅ Passed

Steps:

  1. Ran aspire new aspire-starter without --source or --version.\n2. Passed non-interactive starter flags.\n3. Checked generated nuget.config.

Evidence:

  • Log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/starter.log\n- Generated config checked before cleanup: /Users/ankj/.copilot/p17280-053413/s/st/StarterNoSource/nuget.config

Observations:
Starter scaffold succeeded and references /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages.


Scenario 5: Stale default hive precedence

Objective: Verify an isolated stale default hive does not override the install-prefix hive.
Status: ✅ Passed

Steps:

  1. Created isolated HOME with /Users/ankj/.copilot/p17280-053413/sh/.aspire/hives/pr-17280/packages.\n2. Ran aspire new aspire-empty with that HOME and no source/version.\n3. Checked generated nuget.config uses install-prefix hive and not stale HOME.

Evidence:

  • Log: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs/stale-default-hive.log\n- Generated config checked before cleanup: /Users/ankj/.copilot/p17280-053413/s/sh/StaleHiveNoSource/nuget.config

Observations:
Generated nuget.config used /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages, not the stale default hive.


Summary

Scenario Status Notes
Version verification ✅ Verified Installed version: 13.4.0-pr.17280.gaa600cf8
C# empty AppHost without source ✅ Passed Generated nuget.config references /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages.
TypeScript empty AppHost without source ✅ Passed Template succeeded, output pins pr-17280, and no AtsJsonCodeWriter mismatch appeared.
Starter template without source ✅ Passed Starter scaffold succeeded and references /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages.
Stale default hive precedence ✅ Passed Generated nuget.config used /Users/ankj/.copilot/p17280-053413/hives/pr-17280/packages, not the stale default hive.

Overall Result

✅ PR VERIFIED

Recommendations

No issues found in the approved no-explicit-source scenarios.

Artifacts

  • PR metadata: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/pr-info.json
  • PR diff: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/pr-diff.patch
  • Logs directory: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/logs
  • Report file: /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z/pr-testing-report.md

Cleanup Status

Scenario/install workspace cleanup attempted after report generation. Logs and report retained in /Users/ankj/.copilot/workspaces/aa460f3c-501a-4673-a157-f9fad675cae5/artifacts/pr-testing-17280-20260520T053413Z.

@radical radical marked this pull request as ready for review May 20, 2026 05:36
Copilot AI review requested due to automatic review settings May 20, 2026 05:36
@radical radical requested a review from joperezr May 20, 2026 05:36
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

This PR fixes a dogfood/PR acquisition coherence issue in the Aspire CLI so that when the running CLI identity is pr-<N> and the CLI was installed via the PR “dogfood install prefix” layout, aspire new implicitly uses the matching co-installed PR package hive (without requiring --source). This prevents mixing PR CLI binaries with non-matching template/runtime/codegen packages from normal feeds.

Changes:

  • Extend channel discovery to detect a pr-<N> hive located beside a PR-installed CLI binary (dogfood install prefix layout) and prefer it over a same-named stale default hive.
  • Treat a discovered installed local-build package source as a “hive signal” during template package resolution when PR hives are included.
  • Add targeted unit/integration tests covering the PR-dogfood hive discovery and ensuring aspire new templates scaffold using the discovered PR channel/source.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/Aspire.Cli.Tests/Packaging/PackagingServiceTests.cs Adds tests for discovering/prioritizing the PR dogfood install-prefix hive and edge cases (missing/mismatched/malformed).
tests/Aspire.Cli.Tests/Commands/NewCommandTemplateConfigPersistenceTests.cs Adds scenario-level regression coverage to ensure registered aspire new templates use the discovered PR channel/source during scaffolding.
src/Aspire.Cli/Templating/TemplateNuGetConfigService.cs Expands “has PR hives” detection to include discovered local-build sources so template resolution considers the appropriate channels.
src/Aspire.Cli/Packaging/PackagingService.cs Implements PR dogfood install-prefix hive discovery based on the running process path, and prefers that hive over same-named default hives.

Comment thread src/Aspire.Cli/Packaging/PackagingService.cs Outdated
Centralize the NuGet.org v3 index URL used by CLI package source
mapping paths so channel construction and source override handling do
not each carry their own literal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@radical radical enabled auto-merge (squash) May 20, 2026 20:11
@radical radical merged commit 9c9f861 into microsoft:main May 20, 2026
303 checks passed
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.

PR-acquired Aspire CLI should use matching PR package source for empty AppHost templates

3 participants