Skip to content

Make CLI bundle self-extraction conditional based on distribution mode#15941

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/make-cli-self-extraction-conditional
Draft

Make CLI bundle self-extraction conditional based on distribution mode#15941
Copilot wants to merge 8 commits intomainfrom
copilot/make-cli-self-extraction-conditional

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Description

The bundled CLI always self-extracts bundle.tar.gz at runtime via BundleService.EnsureExtractedAsync, even for archive/installer distributions where the layout is already on disk. This forces write permissions to the install directory unnecessarily.

This PR introduces a SelfExtractingBundle MSBuild property baked into the binary as assembly metadata, so BundleService can skip extraction for distributions that don't need it.

MSBuild (Aspire.Cli.csproj):

  • SelfExtractingBundle defaults to false
  • Set to true when IsCliToolProject=true (dotnet-tool via Aspire.Cli.Tool.csproj)
  • Emitted as [assembly: AssemblyMetadata("SelfExtractingBundle", "...")]

Runtime (BundleService):

  • New IsSelfExtracting property reads the metadata at startup
  • EnsureExtractedAsync short-circuits when IsSelfExtracting is false
  • ExtractAsync (used by aspire setup) still checks IsBundle only — explicit extraction remains available regardless of distribution mode

No changes needed in eng/clipack/Common.projitems — it publishes Aspire.Cli.csproj directly (not the Tool project), so SelfExtractingBundle correctly defaults to false.

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
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: /usr/share/dotnet/dotnet dotnet build src/Aspire.Cli/Aspire.Cli.csproj /p:SkipNativeBuild=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Add SelfExtractingBundle MSBuild property (default false, true for dotnet-tool)
that gets baked into the assembly as metadata. BundleService reads the flag
and skips self-extraction when disabled, relying on pre-extracted layouts
for archive/installer distributions.

Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/62830c5d-e5f0-4741-a5f9-5dc8dc84a82a

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI changed the title [WIP] Make CLI bundle self-extraction conditional based on distribution mode Make CLI bundle self-extraction conditional based on distribution mode Apr 7, 2026
Copilot AI requested a review from radical April 7, 2026 19:59
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 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 -- 15941

Or

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

radical and others added 3 commits April 7, 2026 21:46
When IsSelfExtracting=false, EnsureExtractedAsync was unconditionally
short-circuiting, even if no layout existed on disk. This broke archive
distributions where the binary still has an embedded bundle but the
layout wasn't pre-extracted. Now it checks DiscoverLayout first and
falls back to extraction when the layout is missing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The previous CI run had E2E test failures with 'Arithmetic overflow while
reading bundle' in aspire-managed, which is unrelated to our code changes.
The aspire-managed binary is built independently and our extraction code
is unchanged from main. Other PRs pass E2E tests, suggesting this was a
transient artifact corruption.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

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.

…actingBundle

Replace the AssemblyMetadataAttribute + reflection approach with a compile-time
DefineConstants approach. The AssemblyMetadataAttribute was causing 'Arithmetic
overflow while reading bundle' errors in native AOT builds, likely due to how
ILC handles assembly-level attributes alongside large embedded resources.

The new approach defines SELF_EXTRACTING_BUNDLE as a compile-time constant when
SelfExtractingBundle=true, avoiding any reflection or assembly metadata in the
native binary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

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.

Remove the #if SELF_EXTRACTING_BUNDLE compile-time conditional and
DefineConstants MSBuild property. Hardcode IsSelfExtracting => false
to diagnose if the DefineConstants approach was causing the bundle
corruption CI failures.

The SelfExtractingBundle MSBuild property is retained for future use
when the dotnet-tool distribution (Aspire.Cli.Tool.csproj) enables
self-extraction.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

🎬 CLI E2E Test Recordings — 56 recordings uploaded (commit 8f0f6af)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AllPublishMethodsBuildDockerImages ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24158324292

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.

Make CLI bundle self-extraction conditional based on distribution mode

2 participants