Repository navigation
Ship Aspire CLI as a NativeAOT dotnet tool - #16496
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16496Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16496" |
|
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.
|
|
Re-running the failed jobs in the CI workflow for this pull request because 3 jobs were identified as retry-safe transient failures in the CI run attempt.
Matched test failure patterns (2 tests)
|
|
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.
|
Add shared detection for Aspire CLI installations that run from dotnet tool shims, the tool store, or RID-specific NativeAOT tool packages. Co-authored-by: Copilot <[email protected]>
Introduce a shared helper for locating Aspire CLI pointer and RID-specific packages, and link it into deployment end-to-end tests for reuse. Co-authored-by: Copilot <[email protected]>
Update the CLI tool project so clipack can pack one RID-specific tool package at a time from a staged prebuilt NativeAOT binary instead of publishing the managed tool directly. Co-authored-by: Copilot <[email protected]>
Route update notifications and self-update guidance through the shared dotnet tool detection helper so NativeAOT tool installations get the correct messaging. Co-authored-by: Copilot <[email protected]>
Wire clipack and after-signing targets so RID-specific and pointer dotnet tool packages are packed from the signed native CLI archives. Co-authored-by: Copilot <[email protected]>
Preserve interface metadata on CLR type references used by hosting type helpers so the NativeAOT CLI can safely perform resource type checks. Co-authored-by: Copilot <[email protected]>
Add tool package verification scripts, wire native CLI package validation into CI and AzDO pipelines, and update E2E install strategy coverage for RID-specific packages. Co-authored-by: Copilot <[email protected]>
22ca74f to
b85d228
Compare
Ensure CLI dotnet tool packages produced after native archive signing are NuGet-signed before publishing, and require signature verification in the native package validation step. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR updates Aspire’s CLI distribution so the NativeAOT aspire binary is shipped both as the existing signed RID-specific archives and as a dotnet tool (pointer package + RID-specific tool packages), with CI/CD wiring and verification to keep the payload identical between the archive and tool nupkg.
Changes:
- Adds shared CLI tool package discovery/version inference for tests and updates E2E flows to support local nupkg sources without requiring an explicit version.
- Introduces robust “running as a NativeAOT dotnet tool” detection and updates CLI update guidance (
dotnet tool update -g Aspire.Clivsaspire update/ archive self-update behavior). - Adds build/sign/verify automation for the new tool nupkgs (scripts + AzDO/GitHub Actions + clipack packing targets) and adds NativeAOT reflection annotations in the type system path.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Shared/CliPackageDiscovery.cs | New shared helper to locate the Aspire.Cli pointer nupkg and validate extracted versions. |
| tests/Shared/CliInstallStrategy.cs | Uses shared package discovery; supports dotnet-tool local source version inference and sets expected version for dotnet tool installs. |
| tests/Aspire.Deployment.EndToEnd.Tests/Aspire.Deployment.EndToEnd.Tests.csproj | Links new shared CliPackageDiscovery into deployment E2E tests. |
| tests/Aspire.Cli.Tests/Utils/DotNetToolDetectionTests.cs | New unit tests validating dotnet-tool (shim + tool store) path detection. |
| tests/Aspire.Cli.Tests/Utils/CliUpdateNotificationServiceTests.cs | Verifies update notifier emits dotnet tool update guidance when running from tool store. |
| tests/Aspire.Cli.Tests/TestServices/TestInteractionService.cs | Captures last update command + plain text output for assertions in new tests. |
| tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs | Adds coverage for update --self messaging and “no project found” behavior under dotnet-tool installs. |
| tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliInstallStrategyTests.cs | Updates tests for inferred version and pointer-vs-RID nupkg behavior. |
| tests/Aspire.Cli.EndToEnd.Tests/DotnetToolSmokeTests.cs | Adds smoke validation for aspire update --self showing dotnet tool update and simplifies local-source selection. |
| tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj | Links new shared CliPackageDiscovery into CLI E2E tests. |
| src/Aspire.TypeSystem/HostingTypeHelpers.cs | Adds trimming annotations to preserve interface metadata needed under NativeAOT. |
| src/Aspire.TypeSystem/AtsCapabilityInfo.cs | Adds trimming annotations for CLR type references used by the type system. |
| src/Aspire.Cli/Utils/DotNetToolDetection.cs | New implementation for detecting NativeAOT dotnet-tool installs via shim/store paths (testable via override). |
| src/Aspire.Cli/Utils/CliUpdateNotifier.cs | Switches update command selection to DotNetToolDetection. |
| src/Aspire.Cli/Commands/UpdateCommand.cs | Uses DotNetToolDetection; suppresses archive self-update prompting when running as dotnet tool; prints dotnet-tool update guidance for --self. |
| src/Aspire.Cli/Aspire.Cli.csproj | Adjusts tool packing behavior to pack from prebuilt NativeAOT binaries and avoid publishing managed artifacts for tool packing. |
| eng/signing/signCliToolNupkg.proj | New MicroBuild signing project for CLI tool nupkgs. |
| eng/Signing.props | Adds signing inputs for NativeAOT CLI binaries prior to tool packing. |
| eng/scripts/verify-cli-tool-nupkg.ps1 | New script validating tool nupkg layout, contents, archive binary equivalence, and optional nupkg signature presence. |
| eng/scripts/verify-cli-archive.sh | Removes bash-based archive verification (replaced by pwsh-based script usage in pipelines). |
| eng/scripts/verify-cli-archive.ps1 | Improves cross-platform behavior (home directory detection, PATH separator, chmod on non-Windows). |
| eng/pipelines/templates/prepare-log-artifact-directory.yml | New helper to create a log artifact marker for non-MSBuild installer prep jobs. |
| eng/pipelines/templates/build_sign_native.yml | Adds pack/sign/verify steps for CLI tool nupkgs and switches non-Windows archive verification to pwsh script. |
| eng/pipelines/azure-pipelines.yml | Uses prepare-log-artifact template in installer preparation jobs. |
| eng/pipelines/azure-pipelines-unofficial.yml | Uses prepare-log-artifact template in installer preparation jobs (unofficial pipeline). |
| eng/clipack/Common.projitems | Updates native binary staging path assumptions and adds targets to extract signed archive payload and pack RID/pointer tool nupkgs. |
| eng/Build.props | Removes Aspire.Cli.Tool.csproj from normal build graph; clarifies native-only selection conditions. |
| eng/AfterSigning.targets | New target to pack CLI tool packages from native archive outputs after signing. |
| docs/ci/ci-pipeline-optimizations.md | Documents archives as canonical payload and warns against consuming staging dirs for hashing/packing. |
| AGENTS.md | Adds local build guidance (note: contains a problematic -tl:false recommendation). |
| .github/workflows/tests.yml | Adds a Linux job to validate local native build produces correct CLI tool packages. |
| .github/workflows/build-cli-native-archives.yml | Builds CLI packages with -pack, verifies tool nupkg contents, and uploads CLI tool nupkgs alongside other RID-specific nugets. |
Ensure the package directory keeps a trailing slash before composing recursive package globs for MicroBuild signing. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Keep native CLI tool package validation focused on the package layout and archive payload checks already covered by the AzDO native package jobs. Co-authored-by: Copilot <[email protected]>
| <_CliToolPackProperties Condition="'$(TreatWarningsAsErrors)' != ''" Include="TreatWarningsAsErrors=$(TreatWarningsAsErrors)" /> | ||
| </ItemGroup> | ||
|
|
||
| <MSBuild Projects="@(_CliToolPackProject)" |
There was a problem hiding this comment.
Is this route the best way to get the built output into 2 shipping vehicles?
From what I understand - we build the native archives, sign them, then go back and pack the dotnet CLI tool, but inject the archives bits into the project.
This seems complicated.
There was a problem hiding this comment.
We extract the binary from the archive as it would be signed at that point, and we can put that in the nupkg. And the nupkg itself would get signed on the main Windows job. We have explicit verification to ensure that the binaries are the same.
There was a problem hiding this comment.
Which part specifically are you concerned about?
There was a problem hiding this comment.
Mostly the complexity. It feels like the build should happen at the same time.
- Publish -> get a native AOT executable
- That executable goes into 2 containers:
- The .tar.gz / .zip
- The .nupkg
No need for extra complexity. We produce both contianers at the same time.
There was a problem hiding this comment.
The constraint is that the native aspire binary has to be signed/notarized on the OS/arch-specific native jobs. That means on, say, the OSX native job, we can produce a signed/notarized aspire binary and archive, but we cannot produce a signed .nupkg. If we instead produce the .nupkg there and try to sign it later on the main Windows job, NuGet signing will fail because the aspire binary inside the package is not signed.
So this flow treats the signed native archive as the canonical payload: after signing, we extract the signed aspire binary from the archive and pack that into the RID-specific tool nupkg. With this, we get an unsigned nupkg that contains the signed aspire CLI, and the nupkg itself gets signed later on the main Windows job.
Another possible design would be to sign/notarize the raw binary by itself, then create both the archive and nupkg from AfterSigning.targets instead of using Arcade’s archive task as the container. That is probably doable, but it would be a larger rework and I am not convinced it is better than keeping the archive as the canonical signed artifact.
Jose Perez Rodriguez (joperezr)
left a comment
There was a problem hiding this comment.
Approving modulo the comments below — none of these are blocking, but worth a look before merging. Also cc Chet Husk (@baronfel) since this overlaps a lot with dotnet-tool packaging territory and he might have opinions on the RID-specific tool layout / pointer package shape.
| [GeneratedRegex(@"^[0-9A-Za-z.\-]+$")] | ||
| private static partial Regex VersionPattern(); | ||
|
|
||
| [GeneratedRegex(@"^Aspire\.Cli\.(win|linux|linux-musl|osx)-(x64|arm64)\.", RegexOptions.IgnoreCase)] |
There was a problem hiding this comment.
Heads up — we've now got the supported RID list duplicated in three places: this regex, s_toolPackageRuntimeIdentifiers in DotNetToolDetection.cs, and <RuntimeIdentifiers> in Aspire.Cli.csproj. Next time someone adds a RID and forgets one of these, the new RID-specific package will get misclassified as a pointer package (and tool detection breaks for that RID) without any obvious signal. Worth centralizing at some point — even a single shared constant + InternalsVisibleTo would help.
There was a problem hiding this comment.
Agreed — I added this as a follow-up task under #16543: #16543 (comment).
| which depends on those projects being included in the build. --> | ||
| <Target Name="_PackCliDotnetToolAfterPack" | ||
| BeforeTargets="Pack" | ||
| Condition="'$(SkipNativeBuild)' != 'true' and '$(BuildBundleDepsOnly)' != 'true' and '$(SkipBundleDeps)' != 'true'"> |
There was a problem hiding this comment.
Small inconsistency with the comment above: this gates on SkipNativeBuild, BuildBundleDepsOnly, and SkipBundleDeps, but the matching ItemGroup in eng/Build.props only checks the first two. That means with SkipBundleDeps=true the native archive still ships but the dotnet-tool nupkg silently doesn't — would be good to either align them or document why they diverge.
There was a problem hiding this comment.
Good catch. I’ll align the conditions so the archive and dotnet-tool package gates don’t diverge when SkipBundleDeps=true.
|
|
||
| <!-- ArchiveFormat is derived from CliRuntime above: Windows RIDs are zip archives, | ||
| and all supported Linux/macOS RIDs are tar.gz archives. --> | ||
| <Exec Command="powershell -NoProfile -NonInteractive -Command "Expand-Archive -LiteralPath '$(_CliArchivePath)' -DestinationPath '$(_NativeBinaryArchiveExtractionDir)' -Force"" |
There was a problem hiding this comment.
Both this Expand-Archive command and the tar -xzf below interpolate $(_CliArchivePath) and $(_NativeBinaryArchiveExtractionDir) inside single quotes. If either ever resolves to a path with a ' in it, the command silently breaks. Probably fine in practice on our build agents, but worth a <Unzip> task for the zip path or at least escaping for tar.
There was a problem hiding this comment.
Thanks, agreed. I opened #16543 to track hardening the archive extraction path separately. The current CI paths are controlled, but we should avoid composing Expand-Archive / tar commands with single-quoted MSBuild paths long-term.
| <ItemsToSign Include="$(RepoRoot)eng\scripts\get-aspire-cli.ps1" Condition="$([System.OperatingSystem]::IsWindows())" /> | ||
|
|
||
| <!-- Sign the NativeAOT CLI binary before _PackCliTool places it into the dotnet-tool nupkg. --> | ||
| <ItemsToSign Condition="$([System.OperatingSystem]::IsWindows())" Include="$(ArtifactsBinDir)Aspire.Cli.*\**\aspire.exe" /> |
There was a problem hiding this comment.
This glob (Aspire.Cli.*\**\aspire.exe) is broader than the aspire-managed patterns below — it'll also match intermediate AOT linker outputs under bin/Aspire.Cli.<rid>/Release/net10.0/<rid>/native/aspire(.exe), not just the final publish/aspire(.exe). Mostly wasted signing budget, but also a small risk of an unused signed binary leaking elsewhere. Might be worth scoping to **/publish/aspire(.exe) like the managed entries do.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 3 jobs were identified as retry-safe transient failures in the CI run attempt.
Matched test failure patterns (1 test)
|
Co-authored-by: Copilot <[email protected]>
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
Matched test failure patterns (26 tests)
|
Handle Aspire CLI dotnet tool executions from custom tool paths by detecting sibling .store layouts. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Waiting on a fresh build after all the recent changes - https://dev.azure.com/dnceng/internal/_build/results?buildId=2962783 |
Use the detected dotnet tool install location when suggesting CLI update commands so custom --tool-path installs update the running CLI instead of the global tool. Co-authored-by: Copilot <[email protected]>
|
The top commit changes the update command we show for .NET tool installs, and I want to sanity-check the split:
This now applies both to cc Eric Erhardt (@eerhardt) Jose Perez Rodriguez (@joperezr) Maddy Montaquila (@maddymontaquila) Damian Edwards (@DamianEdwards) — does that look correct? |
|
Re-running the failed jobs in the CI workflow for this pull request because 2 jobs were identified as retry-safe transient failures in the CI run attempt.
|
704e829
into
microsoft:main
Documents the new `dotnet tool install -g Aspire.Cli` install path introduced in Aspire 13.3 (microsoft/aspire#16496, backported in microsoft/aspire#16611). - Adds a new "Install as a .NET tool" H2 to install-cli.mdx with the install command, the .NET SDK 10.0.100 prerequisite, and the matching `dotnet tool update -g Aspire.Cli` update command. - Notes that `aspire update --self` is disabled for .NET tool installs (PR 16496 redirects users to `dotnet tool update` in that case). - Updates the page description to drop "global" — the heading and body use ".NET tool" consistently. - Adds the Upgrade Aspire page to See also. Refs: microsoft#837 (item 1) Co-authored-by: Copilot <[email protected]>
Documents the new `dotnet tool install -g Aspire.Cli` install path introduced in Aspire 13.3 (microsoft/aspire#16496, backported in microsoft/aspire#16611). - Adds a new "Install as a .NET tool" H2 to install-cli.mdx with the install command, the .NET SDK 10.0.100 prerequisite, and the matching `dotnet tool update -g Aspire.Cli` update command. - Notes that `aspire update --self` is disabled for .NET tool installs (PR 16496 redirects users to `dotnet tool update` in that case). - Updates the page description to drop "global" — the heading and body use ".NET tool" consistently. - Adds the Upgrade Aspire page to See also. Refs: microsoft#837 (item 1) Co-authored-by: Copilot <[email protected]>
Documents the new `dotnet tool install -g Aspire.Cli` install path introduced in Aspire 13.3 (microsoft/aspire#16496, backported in microsoft/aspire#16611). - Adds a new "Install as a NativeAOT .NET tool" H2 to install-cli.mdx with the install command, the .NET SDK 10.0.100 prerequisite, and the matching `dotnet tool update -g Aspire.Cli` update command. - Notes that `aspire update --self` is disabled for .NET tool installs (PR 16496 redirects users to `dotnet tool update` in that case). - Updates the page description to drop "global" — the heading and body use "NativeAOT .NET tool" consistently. Refs: microsoft#837 (item 1) Co-authored-by: Copilot <[email protected]>
* feat(cli): detect NativeAOT dotnet tool installations Add shared detection for Aspire CLI installations that run from dotnet tool shims, the tool store, or RID-specific NativeAOT tool packages. Co-authored-by: Copilot <[email protected]> * test(cli): add shared CLI package discovery helper Introduce a shared helper for locating Aspire CLI pointer and RID-specific packages, and link it into deployment end-to-end tests for reuse. Co-authored-by: Copilot <[email protected]> * refactor(cli): prepare tool project for prebuilt native binaries Update the CLI tool project so clipack can pack one RID-specific tool package at a time from a staged prebuilt NativeAOT binary instead of publishing the managed tool directly. Co-authored-by: Copilot <[email protected]> * fix(cli): use dotnet tool detection for update messaging Route update notifications and self-update guidance through the shared dotnet tool detection helper so NativeAOT tool installations get the correct messaging. Co-authored-by: Copilot <[email protected]> * build(cli): pack dotnet tool from signed native archives Wire clipack and after-signing targets so RID-specific and pointer dotnet tool packages are packed from the signed native CLI archives. Co-authored-by: Copilot <[email protected]> * fix(typesystem): annotate reflection used by NativeAOT CLI Preserve interface metadata on CLR type references used by hosting type helpers so the NativeAOT CLI can safely perform resource type checks. Co-authored-by: Copilot <[email protected]> * ci(cli): verify CLI tool packages in pipelines Add tool package verification scripts, wire native CLI package validation into CI and AzDO pipelines, and update E2E install strategy coverage for RID-specific packages. Co-authored-by: Copilot <[email protected]> * Sign CLI tool packages after native packing Ensure CLI dotnet tool packages produced after native archive signing are NuGet-signed before publishing, and require signature verification in the native package validation step. Co-authored-by: Copilot <[email protected]> * Fix CLI tool package signing glob Ensure the package directory keeps a trailing slash before composing recursive package globs for MicroBuild signing. Co-authored-by: Copilot <[email protected]> * Update AGENTS.md Co-authored-by: Copilot <[email protected]> * Remove extra CLI tool package signing step Keep native CLI tool package validation focused on the package layout and archive payload checks already covered by the AzDO native package jobs. Co-authored-by: Copilot <[email protected]> * Add CLI dotnet tool bundle extraction coverage Co-authored-by: Copilot <[email protected]> * Address CLI tool PR feedback Co-authored-by: Copilot <[email protected]> * Document native CLI package signing flow Co-authored-by: Copilot <[email protected]> * Add IsAotCompatible to Aspire.TypeSystem. * Remove CLI tool validation job Co-authored-by: Copilot <[email protected]> * Address CLI packaging review feedback Co-authored-by: Copilot <[email protected]> * Detect custom dotnet tool installs Handle Aspire CLI dotnet tool executions from custom tool paths by detecting sibling .store layouts. Co-authored-by: Copilot <[email protected]> * Fix CLI tool-path update command Use the detected dotnet tool install location when suggesting CLI update commands so custom --tool-path installs update the running CLI instead of the global tool. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Eric Erhardt <[email protected]>
Description
Ships the Aspire CLI as a NativeAOT
dotnet toolwhile preserving the existing native archive distribution path.This change:
Aspire.Cli.tool packages from the signed NativeAOT CLI binary.Aspire.Clipointer package used bydotnet tool install.dotnet tool update -g Aspire.Cli.Automated verification added:
Aspire.Clipointer package are produced.tools/net10.0/<rid>/aspirepath..dll,.deps.json, or.runtimeconfig.json.DotnetToolSettings.xmlreferences the expected RID-specific package.Test scenarios added:
Aspire.Cliviadotnet tool install, verifiesdotnet tool list, resolvesaspirefrom the dotnet tools path, checksaspire update --selfrecommendsdotnet tool update, verifies the installed version, creates a starter project, and runs it.dotnet tool update -g Aspire.Clifor tool-store installs while preservingaspire updateguidance for standalone archive installs.Validation broadly covered targeted CLI unit tests, CLI E2E dotnet-tool scenarios, package layout verification, local dotnet-tool install smoke testing, and the relevant GitHub Actions/AzDO native archive and package validation flows.
Follow-up tasks
Follow-up work for the NativeAOT dotnet-tool path is tracked in #16542.
Known follow-ups include:
tests/Shared/Docker/NuGet.DotnetTool.configcannot silently drift from the relevant rootNuGet.configpackage sources.