Skip to content

feat(cli): co-locate bundle with CLI binary for packager-managed installs - #16817

Merged
Ankit Jain (radical) merged 11 commits into
microsoft:mainfrom
radical:ankj/v3-pr2-route-primitives
May 14, 2026
Merged

Ankit Jain (radical) merged 11 commits into
microsoft:mainfrom
radical:ankj/v3-pr2-route-primitives

Conversation

@radical

@radical Ankit Jain (radical) commented May 6, 2026 •

Copy link
Copy Markdown
Member

The change

This PR introduces two on-disk layout modes for the CLI + bundle, selected by the .aspire-install.json sidecar's source field.

  • Sibling layout — for dotnet-tool / winget / brew. CLI binary and bundle (versions/<id>/) live as siblings inside the same packager-owned directory. This is the new shape packager-managed installs needed.
  • Script layout — for script / pr. CLI binary lives in bin/, bundle lives in the parent of bin/. Same as today; no behavior change for these routes.

Before this PR, BundleService.ComputeDefaultExtractDir always placed the extracted bundle in the parent of the binary's directory. That works for script layout — the binary at <prefix>/bin/aspire lands the bundle at <prefix>/versions/<id>/.

For packager-managed routes (winget, brew, dotnet-tool) the binary sits directly in the packager-owned directory, not under a bin/ sub-folder. Parent-of-binary means the bundle leaks outside that directory — uninstalling or upgrading the package leaves orphaned bundle files behind.

BundleService.ComputeDefaultExtractDir now reads the .aspire-install.json sidecar and, for winget/brew/dotnet-tool, returns binaryDir (beside the binary) instead of its parent. The packager-owned directory therefore contains both the binary and the bundle; a package remove cleans everything up.

Supporting mechanics:

  • Each route writes .aspire-install.json (containing {"source":"<route-name>"}) at install time; shared per-RID archives ship sidecar-free.
  • An MSBuild guard (_AssertNoSidecarInArchiveStaging) fails the build if any per-RID archive stages a sidecar.
  • aspire setup uses a universal, route-independent path; route-aware layout applies to auto-extract-on-init only.
  • docs/specs/install-routes.md documents the full contract.

Before / after

dotnet-tool (dotnet tool install -g Aspire.Cli):

# Before — bundle leaks to parent of packager directory
~/.dotnet/tools/.store/aspire.cli/<version>/.../tools/<tfm>/<rid>/
  aspire                         <- binary (packager-owned dir)
~/.dotnet/tools/.store/aspire.cli/<version>/.../tools/<tfm>/
  versions/<id>/                 <- bundle leaked outside packager dir (wrong)

# After — sibling layout: bundle co-locates with binary
~/.dotnet/tools/.store/aspire.cli/<version>/.../tools/<tfm>/<rid>/
  aspire                          <- binary
  .aspire-install.json            <- {"source":"dotnet-tool"}
  versions/<id>/                  <- bundle inside packager-owned dir (correct)

Why the sidecar

The correct bundle target depends on which packager owns the install — different packagers place the binary in different path shapes. Path-shape detection is fragile: the same per-RID archive feeds brew, winget, and the PR script, so shape alone is insufficient to identify the install origin.

A sidecar written by the installing route is a single source-of-truth label that survives path changes and is owned by the route that wrote it. A single source field is sufficient for layout selection.

How it works

Authorship — one writer per route, at install time:

Route Sidecar writer
brew postflight block in eng/homebrew/aspire.rb.template
winget WingetFirstRunProbe — reads WinGet ARP registry entry on first run, stamps sidecar
script eng/scripts/get-aspire-cli.{sh,ps1} after archive extraction
pr eng/scripts/get-aspire-cli-pr.{sh,ps1} after archive extraction
dotnet-tool Embedded by Aspire.Cli.csproj in the RID-specific nupkg (route-exclusive)

Readership: BundleService.ComputeDefaultExtractDir is the single consumer — a pure function of the source value; no path-shape detection.

Producer-side guards: _AssertNoSidecarInArchiveStaging (MSBuild, build-time) prevents sidecar from entering any per-RID archive. verify-cli-archive.ps1 asserts sidecar absent from the archive; verify-cli-tool-nupkg.ps1 asserts sidecar present in the RID nupkg and absent from the pointer nupkg. Both run in the AzDO pipeline against signed artifacts.

New on-disk layout

winget (portable install, Windows):

%LOCALAPPDATA%\Microsoft\WinGet\Packages  Microsoft.Aspire_<hash>
    aspire.exe
    .aspire-install.json          <- {"source":"winget"}
    versions\<id>\                <- sibling layout: bundle inside packager dir
      <bundle payload>

dotnet-tool (global tool install):

~/.dotnet/tools/.store/aspire.cli/<version>/aspire.cli/<version>/tools/<tfm>/<rid>/
  aspire
  .aspire-install.json            <- {"source":"dotnet-tool"}
  versions/<id>/                  <- sibling layout: bundle inside packager dir
    <bundle payload>

dogfood PR script (script/pr stays parent-of-binary):

~/.aspire/dogfood/pr-<n>/
  bin/
    aspire
    .aspire-install.json          <- {"source":"pr"}
  versions/<id>/                  <- script layout: bundle at parent-of-bin
    <bundle payload>

Out of scope

aspire update --self, channel scoping, and aspire toolchain prune land in a later PR. They will consume the source field from the sidecar established here.

@github-actions

github-actions Bot commented May 6, 2026 •

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 -- 16817

Or

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

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@radical

This comment was marked as outdated.

@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

Ankit Jain (radical) added a commit to radical/aspire that referenced this pull request May 12, 2026
- Merge inbox decision: PR1 bootstrap-wire scope gap documented in decisions.md
- Orchestration logs: Livingston-2 (deep tests), Linus-5 (DI wiring), Livingston-3 (snapshot),
  Ocean-6 (Wave 3 gate approved), Coordinator-action (PR2 shipped)
- Session log: PR2 public draft microsoft#16817, all 12 subtasks approved by Wave 3 gate
- Cross-agent history: updated Linus, Livingston, Basher, Ocean contexts with Wave 4 outcomes
- Livingston history compressed (30364 → manageable size)
- Ready for Ocean's final PR1 gate + PR3 dispatch

Co-authored-by: Copilot <[email protected]>
@radical
Ankit Jain (radical) force-pushed the ankj/v3-pr2-route-primitives branch 2 times, most recently from 9e24a43 to b156da5 Compare May 13, 2026 00:33
Comment thread .squad/agents/basher/history.md Resolved
@joperezr

Copy link
Copy Markdown
Member

Is this ready for review?

@radical
Ankit Jain (radical) force-pushed the ankj/v3-pr2-route-primitives branch from e2c99cc to 3d7f91c Compare May 13, 2026 19:28
@radical

Copy link
Copy Markdown
Member Author

/azp run aspire-tests

1 similar comment
@radical

Copy link
Copy Markdown
Member Author

/azp run aspire-tests

@github-actions

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@radical
Ankit Jain (radical) force-pushed the ankj/v3-pr2-route-primitives branch 2 times, most recently from cf4427d to 081cebf Compare May 14, 2026 07:26
@radical Ankit Jain (radical) changed the title feat(cli): route identity primitives — sidecar, resolver, packaging feat(cli): identify install route via .aspire-install.json sidecar May 14, 2026
@radical
Ankit Jain (radical) marked this pull request as ready for review May 14, 2026 07:31
Copilot AI review requested due to automatic review settings May 14, 2026 07:31
The Homebrew cask now writes {"source":"brew"}\n to the staged
Caskroom path via the cask's postflight block. This is the brew
route's authoritative sidecar author — the shared per-RID tarball
ships sidecar-free so cross-route smuggling is impossible by
construction.

Sidecar content is compact JSON with a trailing LF, matching every
other writer (script / pr / winget / dotnet-tool).

Co-authored-by: Copilot <[email protected]>
@radical
Ankit Jain (radical) force-pushed the ankj/v3-pr2-route-primitives branch 2 times, most recently from 20436b9 to 3c409e8 Compare May 14, 2026 07:47
@github-actions

Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

Ankit Jain (radical) and others added 3 commits May 14, 2026 05:29
…branch safety gate

Replaces the dual-package winget layout (Microsoft.Aspire stable +
Microsoft.Aspire.Prerelease) with a single Microsoft.Aspire identifier
authored from one template directory. Manifests are now generated on
every channel as a CI-only artifact (winget-manifests-<channel> /
homebrew-cask-<channel>) that dogfooders consume via
'winget install --manifest <path>' or 'brew install --cask <local>'.
Public publishing is gated separately by the release-publish pipeline,
which downloads winget-manifests-stable / homebrew-cask-stable by
name — so prerelease artifacts can never reach the public catalog or
the public tap.

Two additional guards:

  * azure-pipelines.{yml,-unofficial.yml} learn a defense-in-depth
    release-branch safety check. On a release/internal-release
    branch with StabilizePackageVersion=true the computed installer
    channel must be 'stable'. The two signals are normally coupled
    via eng/Versions.props (StabilizePackageVersion=true =>
    DotNetFinalVersionKind=release => channel=stable); a mismatch
    indicates someone overrode one property without the other and
    the build refuses to continue. Reading
    StabilizePackageVersion via dotnet msbuild fails the build
    loudly on a non-zero exit so the gate can never silently skip.
  * prepare-winget-manifest.yml emits a
    WinGetIsPrereleaseInStablePackage variable that downstream
    publish steps can branch on if they ever need to differentiate.

Removes:

  * eng/winget/microsoft.aspire.prerelease/ template directory.
  * publish-winget.yml's Microsoft.Aspire.Prerelease packageIdentifier
    branch.
  * eng/winget/README and eng/winget/generate-manifests.ps1 references
    to the prerelease template.

eng/winget/dogfood.ps1 updated to point at the single template
directory.

Co-authored-by: Copilot <[email protected]>
Shared per-RID CLI archives are consumed by brew, winget, the release
script, and the PR script — none of them owns the route label, so the
archive must carry no sidecar. The invariant is enforced at three
points:

  * eng/clipack/Common.projitems gains _AssertNoSidecarInArchiveStaging,
    a build-time check that fails the build with the offending path if
    anything stages .aspire-install.json into the archive output.
  * verify-cli-archive.ps1 extracts the produced archive and asserts no
    .aspire-install.json is present anywhere in the tree (recursive,
    with -Force so hidden dotfiles count).
  * verify-cli-tool-nupkg.ps1 asserts the inverse on the dotnet-tool
    side: the RID-specific nupkg DOES contain the sidecar at the
    expected path (tools/<tfm>/<rid>/.aspire-install.json) with a
    valid 'source' value, while the cross-platform pointer nupkg ships
    sidecar-free.

Both verify scripts use ConvertFrom-Json on the produced artifact —
positive content coverage runs against signed CI archives, not at
the unit-test layer.

Co-authored-by: Copilot <[email protected]>
…ation

The Homebrew cask intentionally does not reach outside the Caskroom
version directory on uninstall — '~/.aspire/' is shared with the
script-route and PR-route installs and a cask-driven recursive delete
would clobber state those installers still own. Document the
one-time manual cleanup ('rm -rf ~/.aspire/installs/brew-stable')
for dogfooders upgrading across the zap-stanza removal.

Co-authored-by: Copilot <[email protected]>
@radical
Ankit Jain (radical) force-pushed the ankj/v3-pr2-route-primitives branch from 3c409e8 to 790d6fa Compare May 14, 2026 09:30
@radical

Copy link
Copy Markdown
Member Author

AzDO internal build is green (2974797 / 20260514.5).

// Path is not a link, does not exist, or cycle detected — fall back to
// the raw path. Sidecar discovery using the raw path is still valid in
// the non-link case.
return path;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as above, does it make sense to fallback to path on any exception?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1652ea9fb0. ResolveSymlinks now catches Exception and falls back to the raw path on any failure, with a debug log so the silent fallback is observable. Same shape as the ReadSidecarSource change above.

Comment on lines +101 to +103
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
_ = ex;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this just for debugging? Feels like individual catch blocks would be cleaner and match the convention in the rest of the file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1652ea9fb0. TryDeleteTemp is now an instance method with separate catch (IOException) / catch (UnauthorizedAccessException) blocks, each logging at debug. Matches the per-exception-type convention used by the rest of the file (the previous _ = ex was just there to silence unused-variable warnings).

Comment on lines +82 to +92
catch (IOException)
{
// Concurrent winner stamped the same literal bytes — install is
// still correctly stamped.
TryDeleteTemp(tempPath);
}
catch (UnauthorizedAccessException ex)
{
_logger.LogDebug(ex, "Winget first-run probe could not rename temp sidecar to {Path}.", sidecarPath);
TryDeleteTemp(tempPath);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make sense to handle these in a single catch block? And should we try to cleanup if some other exception happened (however unlikely)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1652ea9fb0. Collapsed the two File.Move catches into a single catch (Exception) that always invokes TryDeleteTemp. The previous shape only cleaned up on the two expected exception types and would have leaked the .tmp file on anything unexpected — now the cleanup runs unconditionally. Debug log carries the sidecar target path and the inner exception.

{
using var stream = File.OpenRead(sidecarPath);
using var doc = JsonDocument.Parse(stream);
if (doc.RootElement.ValueKind == JsonValueKind.Object &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like we should probably log something if we come across a malformed .aspire-install.json file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1652ea9fb0. ReadSidecarSource now catches Exception and emits a debug log including the sidecar path and the inner exception, so a malformed (or otherwise unreadable) sidecar shows up in --debug output instead of being completely silent.

Comment thread eng/scripts/get-aspire-cli-pr.ps1 Outdated
[int]$PRNumber
)

$sidecarDir = Join-Path $InstallPrefix "dogfood" "pr-$PRNumber" "bin"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot seems to think this particular usage of Join-Path with more than two segments is only compatible with pwsh/PowerShell core. It recommends using [System.IO.Path]::Combine instead for full Windows compatibility.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1652ea9fb0. Converted the three PR-introduced 4-segment Join-Path calls (Write-PRRouteSidecar, Start-InstallFromLocalDir, Start-DownloadAndInstall) to the nested two-argument form. That matches the convention already used by the sibling get-aspire-cli.ps1 (e.g. line 836: Join-Path (Join-Path $homeDirectory ".aspire") "bin") and works under Windows PowerShell 5.1, where -AdditionalChildPath is unavailable.

Left the pre-existing hives/<label>/packages calls (lines 1370, 1486) alone — they predate this PR and are out of scope for this change. Worth a follow-up sweep if we want this script to actually run end-to-end on Windows PowerShell 5.1.


`BundleService.ComputeDefaultExtractDir` maps `source` to extract-dir shape:

- `winget` / `brew` / `dotnet-tool` → `binaryDir` (flat: bundle extracts beside the binary).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My only real concern here is if there's any scenarios where we can't safely extract the bundle without elevation (particularly on Linux/Mac). If we do find any edge cases where it's an issue we'd have to consider switching to pre-extracted installs for some scenarios. But we can burn that bridge when we come to it.

@radical Ankit Jain (radical) May 14, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

copilot:Acknowledged — agreed this is something to keep an eye on. The current routes (winget portable, brew cask postflight, dotnet-tool RID dir, script under $HOME/.aspire, PR script under the same prefix) all extract into directories the install step itself just wrote to, so we shouldn't hit the elevation case in any of today's flows. If we ever add a route that drops the binary into a system-owned location (e.g. /usr/local/bin directly without a Cellar redirect), we'll need the pre-extracted-bundle fallback you describe.

@danegsta David Negstad (danegsta) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few comments, but overall looks good; my only real concern is whether there's any edge cases where we might be forced to ship pre-extracted bundles due to OS/filesystem permissions not allowing us to write to the install location after install.

…hell Join-Path compat

Address review feedback on the install-route sidecar code:

* BundleService.ReadSidecarSource and ResolveSymlinks now catch any
  exception (not just IOException / JsonException) and emit a debug log
  line so an unexpectedly-missing sidecar or unresolved symlink is
  diagnosable rather than silent. Both helpers take an optional ILogger
  parameter (defaulting to NullLogger.Instance) so the static unit-test
  callers stay source-compatible while the instance call sites thread
  the BundleService logger through.

* WingetFirstRunProbe.TryWriteSidecarAtomically collapses the two
  catches around File.Move into a single catch (Exception) that always
  cleans up the temp file. The previous shape only cleaned up on the
  two expected exception types and would leak the .tmp on anything
  unexpected. TryDeleteTemp splits its blanket catch into individual
  IOException / UnauthorizedAccessException blocks that each log at
  debug, matching the convention used elsewhere in the file.

* eng/scripts/get-aspire-cli-pr.ps1: the three Join-Path calls
  introduced by this PR used four positional segments, which require
  PowerShell 6+. The script does not enforce a minimum PSVersion and
  has an explicit IsModernPowerShell capability gate, so it is meant
  to run on Windows PowerShell 5.1 too. Convert the new calls to the
  nested two-argument form already used by the sibling
  get-aspire-cli.ps1 script.

Co-authored-by: Copilot <[email protected]>
@radical
Ankit Jain (radical) enabled auto-merge (squash) May 14, 2026 21:01
@radical
Ankit Jain (radical) merged commit 43abeab into microsoft:main May 14, 2026
584 of 587 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 14, 2026
Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
…alls (microsoft#16817)

* docs(specs): add install-route sidecar contract

Documents the .aspire-install.json sidecar format, the five 'source'
values (script / pr / winget / brew / dotnet-tool), per-route
authorship (each install route writes its own sidecar at install
time; per-RID CLI archives ship sidecar-free), the producer-side
MSBuild + verifier guards, and the BundleService reader-side
contract.

Co-authored-by: Copilot <[email protected]>

* feat(cli): read install-route sidecar to drive bundle extract directory

BundleService now resolves the bundle extract directory by reading the
.aspire-install.json sidecar next to the CLI binary and switching on
its 'source' field:

  * 'winget' / 'brew' / 'dotnet-tool' (packager-managed installs):
    extract beside the binary so versions/<id>/ stays inside the
    packager-owned prefix.
  * 'script' / 'pr' (script-installed): extract one level above bin/
    so versions/<id>/ becomes a sibling of bin/.
  * missing / unreadable / unknown sidecar: parent of binary,
    preserving the legacy ~/.aspire/bin/aspire -> ~/.aspire/ heuristic
    for pre-sidecar installs.

The reader follows symlinks before sidecar discovery so the brew
cellar layout (/opt/homebrew/bin/aspire -> /opt/homebrew/Caskroom/...)
maps onto the cellar's flat install dir rather than /opt/homebrew/.

IBundleService gains GetDefaultExtractDir(string processPath); the
instance method delegates to a static ComputeDefaultExtractDir helper
that drives both the production callers and the unit tests.

Unit coverage:

  * BundleServiceComputeDefaultExtractDirTests pins each source
    value's resolution (including the brew symlink case under a temp
    cellar root) plus the no-sidecar fallback.
  * BundleServiceCrossRouteExtractionTests is a 10-row [Theory] over
    (source x prefix shape) including the cross-route smuggle case,
    invalid JSON, and unknown source.

Co-authored-by: Copilot <[email protected]>

* feat(cli): winget self-stamp on first run via registry probe

The WinGet portable installer drops aspire.exe into a versioned
Microsoft.Aspire_<hash> directory but has no post-install hook to
write the route sidecar. WingetFirstRunProbe closes the gap: on the
first CLI invocation under Windows, it checks the WinGet portable
ARP registry (HKCU\Software\Microsoft\Windows\CurrentVersion\
Uninstall\WinGetPortable\Microsoft.Aspire) for an InstallLocation
matching the running binary's directory. On a match it atomically
writes {"source":"winget"} via temp-file + File.Move(overwrite:false)
so racing first-runs can't tear the sidecar.

  * IWindowsRegistryReader abstracts the registry surface so unit
    tests can drive the match/no-match/race code paths from a fake.
    The production WindowsRegistryReader is Windows-only; a
    NullWindowsRegistryReader is registered everywhere else so the
    BundleService DI graph composes uniformly on every host.
  * Program.cs registers both the reader and the probe.
  * BundleService.EnsureExtractedAsync invokes the probe before
    resolving the extract dir so the sidecar exists by the time the
    sidecar-aware reader runs.

WingetRegistryProbeTests cover write-on-match, no-write-on-absence,
idempotence across a 50 ms sleep (HFS+ second-resolution boundary),
and 16-way parallel race safety.

Co-authored-by: Copilot <[email protected]>

* feat(cli): aspire setup uses route-independent default install path

SetupCommand.GetDefaultInstallPath returns the parent of the current
binary's directory regardless of which install route is in play. The
helper is exposed as 'internal static' so the new test class can pin
the contract for each route's layout (script, PR, managed-flat,
bare-filename, empty, null) with pure path arithmetic — no I/O.

Setup is the user-facing recovery surface; auto-extract-on-init
continues through BundleService.GetDefaultExtractDir which IS
route-aware. Splitting the default-resolution paths keeps the manual
recovery contract predictable and uniform.

Co-authored-by: Copilot <[email protected]>

* feat(acquisition): script + PR-route installers write source sidecar

After extraction, get-aspire-cli.{sh,ps1} writes {"source":"script"}\n
to <prefix>/.aspire-install.json and get-aspire-cli-pr.{sh,ps1} writes
{"source":"pr"}\n to <prefix>/dogfood/pr-<N>/bin/.aspire-install.json.
All four writers emit the identical byte sequence; the bash side uses
printf with a trailing LF, the PowerShell side uses [System.IO.File]::
WriteAllText with an embedded `n.

Under --dry-run / -WhatIf the scripts print the path they would write
to and skip the filesystem mutation so a describe-only pass never
overwrites a real user's sidecar. The bash PR script funnels both call
sites through a single write_pr_route_sidecar helper, matching the
PowerShell sibling's Write-PRRouteSidecar dedupe.

Test infrastructure:

  * PRScriptShellTests / PRScriptPowerShellTests / PRScriptInstallE2ETests
    cover dry-run no-write contract, install-path resolution, real
    download paths via mock-gh, and the local-dir branch.
  * ReleaseScriptShellTests / ReleaseScriptPowerShellTests cover the
    release-route equivalents.
  * FakeArchiveHelper produces minimal aspire-cli-<rid>-*.tar.gz / .zip
    fixtures with SHA-512 checksum files; uses TarWriter manually to
    keep AttributesToSkip = 0 so any dotfile entry would survive
    archive round-trips.
  * TestEnvironment grows MOCK_GH_DOWNLOAD_ARCHIVE_SOURCE so tests can
    feed a real fixture archive into the mock 'gh run download'.

Co-authored-by: Copilot <[email protected]>

* feat(acquisition): dotnet-tool route bakes sidecar inside RID-specific nupkg

The dotnet-tool route is the one install route that payload-embeds
its sidecar — its nupkg is route-exclusive (only 'dotnet tool install'
consumes it), so embedding cannot leak into another route's prefix.

The source-of-truth sidecar lives next to Aspire.Cli.csproj as
dotnet-tool.aspire-install.json. A Copy target inside
_PreparePreBuiltCliBinaryForPackTool renames it to the canonical
.aspire-install.json inside the RID-specific tool nupkg (where
'IsCliToolProject == true' and 'RuntimeIdentifier != ""'); the
cross-platform pointer nupkg ships sidecar-free since it is a routing
stub. The destination path passes through [MSBuild]::
EnsureTrailingSlash on $(PublishDir) so a future caller that
hand-assembles the publish path without a trailing separator cannot
produce a sibling 'bin….aspire-install.json' adjacent to the publish
directory.

Co-authored-by: Copilot <[email protected]>

* feat(homebrew): cask postflight writes source sidecar

The Homebrew cask now writes {"source":"brew"}\n to the staged
Caskroom path via the cask's postflight block. This is the brew
route's authoritative sidecar author — the shared per-RID tarball
ships sidecar-free so cross-route smuggling is impossible by
construction.

Sidecar content is compact JSON with a trailing LF, matching every
other writer (script / pr / winget / dotnet-tool).

Co-authored-by: Copilot <[email protected]>

* build(packaging): channel-aware winget/brew artifact names + release-branch safety gate

Replaces the dual-package winget layout (Microsoft.Aspire stable +
Microsoft.Aspire.Prerelease) with a single Microsoft.Aspire identifier
authored from one template directory. Manifests are now generated on
every channel as a CI-only artifact (winget-manifests-<channel> /
homebrew-cask-<channel>) that dogfooders consume via
'winget install --manifest <path>' or 'brew install --cask <local>'.
Public publishing is gated separately by the release-publish pipeline,
which downloads winget-manifests-stable / homebrew-cask-stable by
name — so prerelease artifacts can never reach the public catalog or
the public tap.

Two additional guards:

  * azure-pipelines.{yml,-unofficial.yml} learn a defense-in-depth
    release-branch safety check. On a release/internal-release
    branch with StabilizePackageVersion=true the computed installer
    channel must be 'stable'. The two signals are normally coupled
    via eng/Versions.props (StabilizePackageVersion=true =>
    DotNetFinalVersionKind=release => channel=stable); a mismatch
    indicates someone overrode one property without the other and
    the build refuses to continue. Reading
    StabilizePackageVersion via dotnet msbuild fails the build
    loudly on a non-zero exit so the gate can never silently skip.
  * prepare-winget-manifest.yml emits a
    WinGetIsPrereleaseInStablePackage variable that downstream
    publish steps can branch on if they ever need to differentiate.

Removes:

  * eng/winget/microsoft.aspire.prerelease/ template directory.
  * publish-winget.yml's Microsoft.Aspire.Prerelease packageIdentifier
    branch.
  * eng/winget/README and eng/winget/generate-manifests.ps1 references
    to the prerelease template.

eng/winget/dogfood.ps1 updated to point at the single template
directory.

Co-authored-by: Copilot <[email protected]>

* build(clipack): assert per-RID archives ship sidecar-free

Shared per-RID CLI archives are consumed by brew, winget, the release
script, and the PR script — none of them owns the route label, so the
archive must carry no sidecar. The invariant is enforced at three
points:

  * eng/clipack/Common.projitems gains _AssertNoSidecarInArchiveStaging,
    a build-time check that fails the build with the offending path if
    anything stages .aspire-install.json into the archive output.
  * verify-cli-archive.ps1 extracts the produced archive and asserts no
    .aspire-install.json is present anywhere in the tree (recursive,
    with -Force so hidden dotfiles count).
  * verify-cli-tool-nupkg.ps1 asserts the inverse on the dotnet-tool
    side: the RID-specific nupkg DOES contain the sidecar at the
    expected path (tools/<tfm>/<rid>/.aspire-install.json) with a
    valid 'source' value, while the cross-platform pointer nupkg ships
    sidecar-free.

Both verify scripts use ConvertFrom-Json on the produced artifact —
positive content coverage runs against signed CI archives, not at
the unit-test layer.

Co-authored-by: Copilot <[email protected]>

* docs(dogfooding): document brew uninstall behavior after sidecar migration

The Homebrew cask intentionally does not reach outside the Caskroom
version directory on uninstall — '~/.aspire/' is shared with the
script-route and PR-route installs and a cask-driven recursive delete
would clobber state those installers still own. Document the
one-time manual cleanup ('rm -rf ~/.aspire/installs/brew-stable')
for dogfooders upgrading across the zap-stanza removal.

Co-authored-by: Copilot <[email protected]>

* fix(cli): broaden sidecar/probe exception handling and Windows PowerShell Join-Path compat

Address review feedback on the install-route sidecar code:

* BundleService.ReadSidecarSource and ResolveSymlinks now catch any
  exception (not just IOException / JsonException) and emit a debug log
  line so an unexpectedly-missing sidecar or unresolved symlink is
  diagnosable rather than silent. Both helpers take an optional ILogger
  parameter (defaulting to NullLogger.Instance) so the static unit-test
  callers stay source-compatible while the instance call sites thread
  the BundleService logger through.

* WingetFirstRunProbe.TryWriteSidecarAtomically collapses the two
  catches around File.Move into a single catch (Exception) that always
  cleans up the temp file. The previous shape only cleaned up on the
  two expected exception types and would leak the .tmp on anything
  unexpected. TryDeleteTemp splits its blanket catch into individual
  IOException / UnauthorizedAccessException blocks that each log at
  debug, matching the convention used elsewhere in the file.

* eng/scripts/get-aspire-cli-pr.ps1: the three Join-Path calls
  introduced by this PR used four positional segments, which require
  PowerShell 6+. The script does not enforce a minimum PSVersion and
  has an explicit IsModernPowerShell capability gate, so it is meant
  to run on Windows PowerShell 5.1 too. Convert the new calls to the
  nested two-argument form already used by the sibling
  get-aspire-cli.ps1 script.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Ankit Jain (radical) added a commit to radical/aspire that referenced this pull request May 21, 2026
verify-cli-archive.ps1 only runs in the post-merge AzDO build+sign
pipeline (never on GitHub PRs), so regressions in its contract surface
days late. The recent microsoft#17274 -> microsoft#17341 -> microsoft#17345 chain is the case in
point: the verifier was broken on main for hours before anyone noticed.

Add a synthetic-archive E2E test that exercises the verifier's current
contract in GitHub CI against a fake `aspire` binary, with no real CLI,
no bundle, and no network access:

- VerifyCliArchive_AcceptsCleanPerRidArchive: per-RID archive with the
  fake `aspire` mock handles `aspire --version` and `aspire new
  aspire-starter`; asserts the verifier exits 0 and emits the expected
  per-step success lines.

- VerifyCliArchive_RejectsArchiveWithStraySidecar: per-RID archive
  containing a stray `.aspire-install.json`; asserts the verifier
  exits non-zero with the user-facing error text from
  Test-ArchiveSidecar. This is the contract from microsoft#16817 that the
  verifier was originally written to enforce.

Adds FakeArchiveHelper.CreateFakeVerifyArchiveAsync to produce these
archives. Pre-existing CreateFakeArchiveAsync stays as-is so the
install-script tests are unaffected. Unix-only because the fake aspire
mock is a bash script.

Co-authored-by: Copilot <[email protected]>
Ankit Jain (radical) added a commit to radical/aspire that referenced this pull request May 21, 2026
Test-ArchiveSidecar was called with $archiveRoot (the directory
Get-ArchiveRoot picks out as the binary's home), not $extractDir (the
true extraction directory). When a per-RID archive nests its binary
under a single sub-directory (e.g. {.aspire-install.json, payload/aspire}),
Get-ArchiveRoot returns the sub-directory, and the sidecar scan only
recurses into that sub-directory -- missing a stray .aspire-install.json
at the actual archive root.

The sidecar contract from microsoft#16817 ("per-RID archives are shared across
install routes; each route authors its own sidecar after extraction")
is about the archive, not whichever directory happens to hold the
binary. Scan the full extraction directory instead.

Latent bug only -- today's signed archives put `aspire` at the
extraction root, so Get-ArchiveRoot returns $extractDir unchanged and
the scope-narrowing didn't matter in practice. A producer-side
refactor that introduced a top-level directory would have silently
hidden a contract violation.

Add VerifyCliArchive_RejectsStraySidecarWhenBinaryIsNestedUnderSubdirectory
to pin the fix: it builds an archive with the binary nested under
`payload/` and a stray sidecar at the archive root, and asserts the
verifier rejects it. Without the script fix the verifier accepts the
archive; with it the test passes. CreateFakeVerifyArchiveAsync gains
a nestAspireUnderSubdir parameter so the same helper covers both the
binary-at-root and binary-in-subdir shapes Get-ArchiveRoot has to
handle.

Co-authored-by: Copilot <[email protected]>
Ankit Jain (radical) added a commit that referenced this pull request May 21, 2026
…erifier checks, add GitHub-CI coverage, fix latent sidecar-scope bug (#17346)

* Remove failing TypeScript starter and bundle-layout checks from CLI archive verifier

The signed build+sign pipeline (microsoft-aspire, definition 1602) is
broken on main since #17274 merged. Two checks added by that PR fail in
the 1ES signed-build agent -- the only environment that actually runs
verify-cli-archive.ps1 against the real signed archive:

1. Test-TypeScriptStarterProject runs `aspire new aspire-ts-starter`,
   whose packager-managed AppHost bootstrap performs a NuGet restore
   that resolves transitive deps (Microsoft.Extensions.*, Grpc.*,
   OpenTelemetry.*, etc.) to https://api.nuget.org/v3/index.json. The
   signed-build agent has no public-internet egress and the restore
   fails with `Permission denied (api.nuget.org:443)`.

2. Test-ExtractedBundleLayout's file assertions only succeed when the
   prior TypeScript starter step has triggered the AppHost server
   bootstrap and extracted ~/.aspire/bundle. The C# starter doesn't
   exercise that path. With the TS starter removed there's no trigger
   for the bundle layout to be populated, and its embedded
   `aspire-managed --help` smoke call returns exit 1 by design (the
   binary's top-level dispatch is dashboard|server|nuget; anything
   else falls through to ShowUsage()).

This is the same class of regression as the earlier `aspire-managed
--help` failure in the same script: the verifier doesn't run on
GitHub PRs and only fires in the post-merge build+sign pipeline, so
the incompatibility wasn't caught pre-merge.

Surgical removal of the failing pieces:

- Drop Test-TypeScriptStarterProject (function + call site).
- Drop Test-ExtractedBundleLayout (function + call site).
- Drop tests/Aspire.Acquisition.Tests/Scripts/VerifyCliArchivePowerShellTests.cs,
  which only covered the removed functions.
- Drop CreateFakeBundleArchiveAsync and CreateFakeCliScript additions
  from FakeArchiveHelper.cs, which had no other consumers.
- Drop the unused ScriptPaths.VerifyCliArchivePowerShell entry.

Keep all the orthogonal infrastructure #17274 added so it can be
reused when the TS check returns:

- Helpers Get-ExecutableFileName, Get-ArchiveRoot, Get-ArchiveRidFamily.
- Refactored Test-CSharpStarterProject function (functionally equivalent
  to the pre-#17274 inline C# starter check).
- Test-ArchiveSidecar's use of Get-ArchiveRidFamily.
- aspireBin discovery via Get-ArchiveRoot.

The script header's step list is updated to match what now runs.

Re-adding the TS coverage will require either an internal NuGet mirror
config the agent can reach (e.g. dropping a NuGet.config that maps
* -> dotnet-public into the temp project root before `aspire new`),
or a way to skip the auto-restore on `aspire new aspire-ts-starter`.
Tracked in #17345.

Co-authored-by: Copilot <[email protected]>

* Add slim GitHub-CI coverage for verify-cli-archive.ps1

verify-cli-archive.ps1 only runs in the post-merge AzDO build+sign
pipeline (never on GitHub PRs), so regressions in its contract surface
days late. The recent #17274 -> #17341 -> #17345 chain is the case in
point: the verifier was broken on main for hours before anyone noticed.

Add a synthetic-archive E2E test that exercises the verifier's current
contract in GitHub CI against a fake `aspire` binary, with no real CLI,
no bundle, and no network access:

- VerifyCliArchive_AcceptsCleanPerRidArchive: per-RID archive with the
  fake `aspire` mock handles `aspire --version` and `aspire new
  aspire-starter`; asserts the verifier exits 0 and emits the expected
  per-step success lines.

- VerifyCliArchive_RejectsArchiveWithStraySidecar: per-RID archive
  containing a stray `.aspire-install.json`; asserts the verifier
  exits non-zero with the user-facing error text from
  Test-ArchiveSidecar. This is the contract from #16817 that the
  verifier was originally written to enforce.

Adds FakeArchiveHelper.CreateFakeVerifyArchiveAsync to produce these
archives. Pre-existing CreateFakeArchiveAsync stays as-is so the
install-script tests are unaffected. Unix-only because the fake aspire
mock is a bash script.

Co-authored-by: Copilot <[email protected]>

* Fix Test-ArchiveSidecar scope and pin the regression with a test

Test-ArchiveSidecar was called with $archiveRoot (the directory
Get-ArchiveRoot picks out as the binary's home), not $extractDir (the
true extraction directory). When a per-RID archive nests its binary
under a single sub-directory (e.g. {.aspire-install.json, payload/aspire}),
Get-ArchiveRoot returns the sub-directory, and the sidecar scan only
recurses into that sub-directory -- missing a stray .aspire-install.json
at the actual archive root.

The sidecar contract from #16817 ("per-RID archives are shared across
install routes; each route authors its own sidecar after extraction")
is about the archive, not whichever directory happens to hold the
binary. Scan the full extraction directory instead.

Latent bug only -- today's signed archives put `aspire` at the
extraction root, so Get-ArchiveRoot returns $extractDir unchanged and
the scope-narrowing didn't matter in practice. A producer-side
refactor that introduced a top-level directory would have silently
hidden a contract violation.

Add VerifyCliArchive_RejectsStraySidecarWhenBinaryIsNestedUnderSubdirectory
to pin the fix: it builds an archive with the binary nested under
`payload/` and a stray sidecar at the archive root, and asserts the
verifier rejects it. Without the script fix the verifier accepts the
archive; with it the test passes. CreateFakeVerifyArchiveAsync gains
a nestAspireUnderSubdir parameter so the same helper covers both the
binary-at-root and binary-in-subdir shapes Get-ArchiveRoot has to
handle.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Jose Perez Rodriguez (joperezr) pushed a commit that referenced this pull request May 22, 2026
A user who has both a Homebrew-installed Aspire CLI and any other Aspire
install on the same machine (the get-aspire-cli script install,
`dotnet tool install -g Aspire.Cli`, or a second route) loses all shared
CLI state if they run `brew uninstall --zap aspire`:

    $ brew uninstall --cask --zap aspire
    ==> Uninstalling Cask aspire
    ==> Purging files for version 13.3.5 of Cask aspire
    ==> Removing all files associated with cask aspire
    Removing trash: ~/.aspire    # also used by every other Aspire install

`~/.aspire` is the user's shared Aspire home: CLI runtime state, NuGet
hives, per-project AppHost model paths under apps/, backchannel state,
sockets, and other state written by every install route. Listing it under
`zap trash:` on a single route's cask makes `brew uninstall --zap` a
multi-route data-loss command.

Plain `brew uninstall --cask aspire` is unaffected -- zap only runs under
explicit `--zap`. The blast radius is users who use `--zap` as a "clean
uninstall" habit, but it is silent and unrecoverable when it does fire.

The legacy 13.3.x brew install writes no user-level state outside the
Caskroom (which Homebrew already cleans up on uninstall), so the right
fix is the canonical comment documented by the Homebrew Cask Cookbook:

    # No zap stanza required

This pattern is used by 1,284+ merged casks upstream, including pure CLI
binary casks like aws-vault-binary and p4. `brew audit` does not require
a zap stanza (zap is in `rejected_artifacts` in audit.rb's
`audit_required_stanzas`). The comment satisfies homebrew-cask's
triage.yml regex `zap .+\n` (matches the substring "zap stanza required\n"),
so the missing-zap label is not applied.

The full sidecar / co-located-bundle rework that moves brew-owned CLI
state out of `~/.aspire` entirely is part of the 13.4 work in #16817;
this is the minimum safe servicing patch for 13.3.x users without that
rework. Lands before the first 13.3.x cask is submitted to
Homebrew/homebrew-cask, so no already-published cask carries the data-loss
path.
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants