diff --git a/.agents/skills/pr-testing/ci-infra-testing.md b/.agents/skills/pr-testing/ci-infra-testing.md index 7962937f5c1..452cca8d277 100644 --- a/.agents/skills/pr-testing/ci-infra-testing.md +++ b/.agents/skills/pr-testing/ci-infra-testing.md @@ -562,9 +562,10 @@ eyeballing — e.g. `eng/scripts/verify-cli-tool-nupkg.ps1`, `verify-cli-archive itself a finding. **Build behavior changed → read the binlog, not just the console.** CI build jobs emit -MSBuild binlogs via `/bl:` — e.g. `BuildAndArchive.binlog`, `BuildCli.binlog`, -`BundlePayload.binlog` under `artifacts/log/...` (`run-tests.yml`, -`build-cli-native-archives.yml`) and `SendToHelix.binlog` on the AzDO Helix path. Download +MSBuild binlogs via `/bl:` — e.g. `BuildAndArchive.binlog` from `run-tests.yml`, +`BuildNativeBundle.binlog` from `build-cli-native-archives.yml`, and child-build +`PublishAndPackageCli.binlog` from `eng/Bundle.proj`, under `artifacts/log/...`. +The AzDO Helix path emits `SendToHelix.binlog`. Download the binlog and confirm the change took effect: the target/task ran, the property/condition evaluated as intended, and the right items were (or were not) included. diff --git a/.github/workflows/auto-rerun/rerun-pull-request.js b/.github/workflows/auto-rerun/rerun-pull-request.js index 6f5a3126f3a..bb273670def 100644 --- a/.github/workflows/auto-rerun/rerun-pull-request.js +++ b/.github/workflows/auto-rerun/rerun-pull-request.js @@ -56,6 +56,9 @@ const ignoredFailureStepPatterns = [ /^Run nuget dependent tests\b/i, /^Build test project$/i, /^Build and archive test project$/i, + /^Build native bundle and CLI packages$/i, + // Keep previous step names for reruns of older workflow revisions. + /^Build bundle payload archive$/i, /^Build RID-specific packages\b/i, /^Build Python validation image$/i, /^Build with packages$/i, diff --git a/.github/workflows/build-cli-native-archives.yml b/.github/workflows/build-cli-native-archives.yml index 4342037501d..9aac575976b 100644 --- a/.github/workflows/build-cli-native-archives.yml +++ b/.github/workflows/build-cli-native-archives.yml @@ -76,63 +76,35 @@ jobs: with: node-version: 22.x - # Build RID-specific NuGet packages (DCP + Dashboard) locally instead of - # downloading them from the build_packages job. This allows the CLI archive - # build to run in parallel with build_packages. - # - # Capture the complete build output so the expected framework-owned IL2026 - # can remain visible while verification rejects any additional IL2026 warnings. - - name: Build RID-specific packages + # Bundle.proj owns publish, warning validation, signing, payload assembly, + # and the clipack build/sign/pack flow in both CI systems. + - name: Build native bundle and CLI packages shell: pwsh run: | - $ErrorActionPreference = 'Stop' - $buildLog = "$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BuildBundleDeps.log" - # Repository cleanup can remove artifacts/log while the build is streaming output. - $temporaryLog = Join-Path '${{ runner.temp }}' 'BuildBundleDeps.log' - # Overrides contain multiple MSBuild switches; split them into arguments without evaluating them as code. - $versionOverrideArgs = @($env:VERSION_OVERRIDE_ARG -split '\s+' | Where-Object { $_ }) - & '${{ runner.os == 'Windows' && './build.cmd' || './build.sh' }}' ` - -ci ` - -restore ` - -build ` - -pack ` - -configuration $env:BUILD_CONFIGURATION ` - "/bl:$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BuildBundleDeps.binlog" ` - /p:ContinuousIntegrationBuild=true ` - /p:BuildBundleDepsOnly=true ` - "/p:TargetRids=$env:TARGET_RIDS" ` - "/p:AspireCliChannel=$env:ASPIRE_CLI_CHANNEL" ` - @versionOverrideArgs 2>&1 | Tee-Object -FilePath $temporaryLog - $buildExitCode = $LASTEXITCODE - New-Item -ItemType Directory -Force -Path (Split-Path $buildLog -Parent) | Out-Null - Copy-Item -LiteralPath $temporaryLog -Destination $buildLog - exit $buildExitCode - - - name: Verify Native AOT Dashboard warnings - shell: pwsh - run: > - ./eng/scripts/verify-native-dashboard-warnings.ps1 - -BuildLog "$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BuildBundleDeps.log" - - - name: Build bundle payload archive - # SkipNativeBuild skips only the outer CLI. Bundle.proj still publishes - # native desktop tray payloads and verifies the actual archive. - shell: pwsh - # Overrides contain multiple MSBuild switches; split them into arguments without evaluating them as code. - run: > - $versionOverrideArgs = @($env:VERSION_OVERRIDE_ARG -split '\s+' | Where-Object { $_ }) + $dotnetScript = if ($IsWindows) { "./dotnet.cmd" } else { "./dotnet.sh" } + $arguments = @( + "msbuild", + "eng/Bundle.proj", + "/t:Build", + "/p:BuildDistributionPackages=true", + "/p:Configuration=$env:BUILD_CONFIGURATION", + "/p:TargetRid=$env:TARGET_RIDS", + "/p:BundleVersion=ci-bundlepayload", + "/p:PackDcpPackage=true", + "/p:ContinuousIntegrationBuild=true", + "/p:AspireCliChannel=$env:ASPIRE_CLI_CHANNEL", + "/bl:$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BuildNativeBundle.binlog" + ) + if (-not [string]::IsNullOrWhiteSpace($env:VERSION_OVERRIDE_ARG)) { + # The caller supplies whitespace-separated switches without spaces in values, + # e.g. /p:VersionSuffix=pr.123.gabcdef12 /p:DotNetFinalVersionKind=prerelease. + $arguments += $env:VERSION_OVERRIDE_ARG.Trim() -split '\s+' + } - ${{ runner.os == 'Windows' && './dotnet.cmd' || './dotnet.sh' }} - msbuild - eng/Bundle.proj - /restore - "/p:Configuration=$env:BUILD_CONFIGURATION" - "/p:TargetRid=$env:TARGET_RIDS" - /p:BundleVersion=ci-bundlepayload - /p:SkipNativeBuild=true - /p:ContinuousIntegrationBuild=true - "/bl:$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BundlePayload.binlog" - @versionOverrideArgs + & $dotnetScript @arguments + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } - name: Smoke test packaged native tray shell: pwsh @@ -158,26 +130,6 @@ jobs: ./eng/scripts/test-native-terminalhost.ps1 -TerminalHostPath "$env:GITHUB_WORKSPACE/artifacts/bundle/$env:TARGET_RIDS/terminalhost/Aspire.TerminalHost${{ runner.os == 'Windows' && '.exe' || '' }}" - - name: Build CLI packages - shell: pwsh - # Overrides contain multiple MSBuild switches; split them into arguments without evaluating them as code. - run: > - $versionOverrideArgs = @($env:VERSION_OVERRIDE_ARG -split '\s+' | Where-Object { $_ }) - - ${{ runner.os == 'Windows' && './build.cmd' || './build.sh' }} - -ci - -build - -pack - -restore - -configuration $env:BUILD_CONFIGURATION - "/bl:$env:GITHUB_WORKSPACE/artifacts/log/$env:BUILD_CONFIGURATION/BuildCli.binlog" - /p:ContinuousIntegrationBuild=true - /p:SkipManagedBuild=true - "/p:TargetRids=$env:TARGET_RIDS" - "/p:BundlePayloadPath=$env:GITHUB_WORKSPACE/artifacts/bundle/aspire-ci-bundlepayload-$env:TARGET_RIDS.tar.gz" - "/p:AspireCliChannel=$env:ASPIRE_CLI_CHANNEL" - @versionOverrideArgs - - name: Verify CLI tool nupkg shell: pwsh run: | diff --git a/docs/ci/native-cli-packaging.md b/docs/ci/native-cli-packaging.md index ddf70a00199..e5c27ba86ea 100644 --- a/docs/ci/native-cli-packaging.md +++ b/docs/ci/native-cli-packaging.md @@ -19,6 +19,22 @@ The GitHub Actions test workflow builds native CLI archives per OS/RID and uploa These PR artifacts are useful for validation and dogfooding, but they are not the final official signed release artifacts. +## Shared bundle validation + +Validate packaging and signing against the outputs of the producing build, +not replacement projects or private MSBuild targets in `Infrastructure.Tests`. +The native jobs verify packaged Dashboard and TerminalHost behavior and compare +the CLI archive with its tool and npm packages. Official builds additionally +exercise real signing and notarization; unsigned GitHub artifacts cannot +establish those contracts. + +The deployment workflow consumes a different build mode: it invokes +`eng/Bundle.proj` with `BuildDistributionPackages` omitted, producing a +standalone CLI rather than distribution packages. Validate that path with a +Linux build and inspect the resulting CLI and extracted bundle. A successful +distribution-mode build alone does not establish this contract, and validating +the build does not require deploying to Azure. + ## Internal signed builds The internal Azure DevOps `build_sign_native` stage is responsible for producing signed native CLI artifacts. Windows and macOS native jobs run with code signing enabled so each OS/arch-specific native executable can be signed or notarized on the appropriate platform. @@ -57,11 +73,26 @@ Linux native jobs do not sign ELF binaries in `build_sign_native`. For Linux, ex ## Native AOT Dashboard package signing -All seven Dashboard SDK NuGet packages follow the CLI package-signing path: `assemble` stages them together in `Shipping` before its Windows signing pass. There is no second Dashboard staging pass after signing. When NuGet signing is enabled, this ensures Linux packages receive NuGet signatures even though Linux native jobs skip ELF signing. - -NuGet signing follows `PostBuildSign` in `eng/pipelines/common-variables.yml`: release-branch and manually queued official builds set it to `false`, enabling Arcade's default package-signing inputs. Automatic main builds set it to `true`, excluding NuGet packages from in-build signing; native executable and npm signing are selected separately. - -Assembly verifies every staged NuGet release package's signature before publishing build artifacts only when real signing is enabled and `PostBuildSign` is not `true`. This matches package-signing selection rather than assuming that a real-signed build signs every artifact. The unsigned `*.symbols.nupkg` files also staged in `Shipping` are excluded because they are symbol-server inputs, not NuGet release packages. +The official Assemble job stages the three Linux Dashboard SDK NuGet packages +before its Windows signing pass because Linux native jobs skip signing. +Windows/macOS Dashboard packages are staged afterward so their signed producer +outputs are preserved. + +NuGet signing follows `PostBuildSign` in +[`common-variables.yml`](../../eng/pipelines/common-variables.yml): +release-branch and manually queued official builds set it to `false`, enabling +Arcade's default package-signing inputs. Automatic main builds set it to `true`, +excluding NuGet packages from in-build signing; native executable and npm +signing are selected separately. + +Assembly checks that all seven Dashboard packages reached `Shipping`. When real +signing is enabled and `PostBuildSign` is not `true`, it also verifies every final +NuGet release package's signature before publishing, including Dashboard, CLI, +and managed packages. This matches package-signing selection +rather than assuming that a real-signed build signs every artifact. The unsigned +`*.symbols.nupkg` files are excluded because they are symbol-server inputs, not +NuGet release packages. See the Assemble job in +[`azure-pipelines.yml`](../../eng/pipelines/azure-pipelines.yml). ## Nix flake packaging diff --git a/docs/ci/test-trigger-selector-design.md b/docs/ci/test-trigger-selector-design.md index 6e384770d3f..b5a435cbbaf 100644 --- a/docs/ci/test-trigger-selector-design.md +++ b/docs/ci/test-trigger-selector-design.md @@ -197,7 +197,7 @@ the graph root does not produce the repository project graph. Evaluating `eng/Build.props`'s `ProjectToBuild` items would also make selection depend on build flags and the current RID. Flags such as `SkipNativeBuild`, -`BuildBundleDepsOnly`, and `SkipTestProjects` differ across CI jobs. +`SkipManagedBuild`, and `SkipTestProjects` differ across CI jobs. That project set is also a net loss for test selection: diff --git a/docs/specs/bundle.md b/docs/specs/bundle.md index aff6059d5e5..1c2f1de33fb 100644 --- a/docs/specs/bundle.md +++ b/docs/specs/bundle.md @@ -366,6 +366,21 @@ The repository-development path uses project references and local artifacts wher [eng/Bundle.proj](../../eng/Bundle.proj) orchestrates local bundle creation. Restore the repository toolchain first and install the target platform's Native AOT prerequisites. +The bundling process is: + +1. Validate the requested configuration and acquire DCP for the target platform. +2. Publish the managed helper, Dashboard, TerminalHost, AppHost Server, and + platform tray, or reuse their prepared outputs when requested. +3. For signed distributions, sign the component binaries. The macOS tray app + also requires whole-app signing and notarization. +4. Create any requested Dashboard and DCP distribution packages, then assemble + the payload archive from the prepared components. +5. Publish the CLI with the payload embedded and sign it when requested. + Distribution builds also create CLI archives, .NET tool packages, and npm packages. + +Signing precedes payload assembly so the embedded components retain their +signatures. Assembly and packaging do not republish components. + ```powershell # Windows example, from the repository root .\restore.cmd @@ -378,18 +393,25 @@ dotnet msbuild eng/Bundle.proj /t:Build /p:TargetRid=win-x64 /p:Configuration=Re dotnet msbuild eng/Bundle.proj /t:Build /p:TargetRid=osx-arm64 /p:Configuration=Release ``` -The build sequence is: +`Build` is the default entry point. A default build creates the payload archive +and self-extracting CLI without distribution packages. Dashboard distribution +outputs include a NuGet package and runtime ZIP. -1. Publish `Aspire.Managed` as a self-contained single-file executable. -2. Publish `Aspire.Dashboard` and `Aspire.TerminalHost` with Native AOT for the same RID and configuration. -3. Publish the native tray payload on macOS, Windows, or glibc Linux, before signing bundle components. -4. Restore the matching DCP package, using the target OS/architecture rather than the build machine's defaults. -5. Run `CreateLayout` to assemble the payload and create its `.tar.gz` archive. -6. Publish the Native AOT CLI with `BundlePayloadPath` pointing to that archive. +The assembled directories are under `artifacts/bundle/{rid}/`; the payload +archive is `artifacts/bundle/aspire-{version}-{rid}.tar.gz`. The self-extracting +CLI is in the CLI project's publish output, not in the payload directory. -The assembled directories are under `artifacts/bundle/{rid}/`; the payload archive is `artifacts/bundle/aspire-{version}-{rid}.tar.gz`. The self-extracting CLI is in the CLI project's publish output, not in the payload directory. +See the [project's options](../../eng/Bundle.proj) for distribution packaging, +signing, output paths, and component-reuse controls. Skipping component +publishing requires prepared inputs; `SkipCliArtifacts` instead omits the CLI +and its packages. Repository build wrappers translate the legacy +`/p:SkipNativeBuild=true` argument into CLI omission; use the direct MSBuild +entry point above for advanced bundle controls. -`Configuration` defaults to Debug for local bundle builds. The GitHub Actions native-archive workflow defaults to Release and passes it explicitly; CI bundle creation rejects non-Release configurations so distributed payloads use Native AOT optimizations. `SkipManagedBuild=true` reuses existing Managed, Dashboard, and TerminalHost publishes; `SkipNativeBuild=true` skips the final CLI publish. They do not make missing payload components optional. +Windows, macOS, and glibc Linux archive checks validate tray payloads before CLI embedding. +Official macOS tray signing includes notarization. CLI symbols are staged +independently; see +[CLI native symbols](../ci/cli-native-symbols.md). ### CreateLayout @@ -401,15 +423,25 @@ dotnet run --project tools/CreateLayout -- \ --artifacts artifacts \ --rid linux-x64 \ --configuration Release \ - --tray-linux artifacts/bin/Aspire.Tray.Linux/Release/net10.0/linux-x64/publish \ + --tray-dir artifacts/bin/Aspire.Tray.Linux/Release/net10.0/linux-x64/publish \ --bundle-version local-test \ --archive ``` `--output`, `--artifacts`, `--rid`, and `--configuration` are required. `--bundle-version`, `--archive`, and `--verbose` are optional. The output directory is cleaned before assembly. There is no `--embed-in-cli`, `--runtime`, or runtime-download option; embedding happens in the subsequent CLI publish. -Desktop layouts also require their native tray input: `--tray-app` on macOS, -`--tray-windows` on Windows, or `--tray-linux` on glibc Linux. +Use `--dashboard "/path/to/prepared/publish"` to select a Dashboard publish directory instead of discovering one under the artifacts directory. Invalid or incomplete input fails without falling back to discovery. + +Desktop layouts require `--tray-dir ` for their prepared tray input. +Use the complete `.app` directory on macOS and the executable/icon publish +directory on Windows or glibc Linux. The target RID selects the payload format; +musl layouts have no tray input. + +`TrayDirectory` overrides the matching tray directory in `eng/Bundle.proj`. +Publishing requires a matching host OS, validated before any component restore +or publish. Cross-architecture builds on that OS remain supported. +`SkipTrayPublish=true` reuses a prepared directory without requiring the +publishing host OS; payload validation still applies before packaging. For the complete tool contract, see [CreateLayout](../../tools/CreateLayout/README.md). CI packaging additionally uses [dashboardpack](../../eng/dashboardpack/Common.projitems), [clipack](../../eng/clipack/Common.projitems), signing targets, and the native-archive workflows. @@ -417,11 +449,10 @@ For the complete tool contract, see [CreateLayout](../../tools/CreateLayout/READ `aspire tray start` starts or restores the native companion from the invoking CLI's leased bundle; `aspire tray stop` shuts down the companion without stopping AppHosts. The companion uses the CLI's versioned discovery and exact-instance stop contracts. Linux musl, headless sessions, and standalone CLI binaries without a bundled payload are unsupported. -macOS bundles contain the complete `Aspire Tray.app`, including its executable, plist, artwork, and signature. Windows x64 and ARM64 bundles contain `tray/aspire-tray.exe` and the shared `tray/Aspire.ico`. `CreateLayout` copies the already-published payload and rejects missing or incompatible files. The native archive verification targets check the actual packaged payload before it is embedded in the CLI. +macOS bundles contain the complete `Aspire Tray.app`, including its executable, plist, artwork, and signature. Windows x64 and ARM64 bundles contain `tray/aspire-tray.exe` and the shared `tray/Aspire.ico`. `CreateLayout` copies the already-published payload and rejects missing or incompatible files. Archive verification checks the actual packaged payload before it is embedded in the CLI. Linux x64 and ARM64 bundles contain `tray/aspire-tray` and `tray/Aspire.png`. The Linux archive verifier rejects extra entries and requires both files to be regular, non-symlink files. -`LinuxTrayDirectory` overrides the pre-built Linux tray directory used by `eng/Bundle.proj`. Layout assembly validates ELF architecture and executable permissions. GTK 3 and an Ayatana/compatible AppIndicator library are dynamically loaded host diff --git a/eng/AfterSigning.targets b/eng/AfterSigning.targets index aad0003874d..e5bfe26bcd0 100644 --- a/eng/AfterSigning.targets +++ b/eng/AfterSigning.targets @@ -4,12 +4,12 @@ $([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) - + Condition="'$(SkipNativeBuild)' != 'true'"> <_CliToolPackRid Include="$(TargetRids.Split(':'))" /> <_CliToolPackProject Include="@(_CliToolPackRid -> '$(RepoRoot)eng\clipack\Aspire.Cli.%(Identity).csproj')" /> diff --git a/eng/Build.props b/eng/Build.props index cc2852392c9..8bcc7ce2c5a 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -8,7 +8,6 @@ SkipTestProjects - if 'true', skips building test projects, defaults to 'false' SkipPlaygroundProjects - if 'true', skips building playground projects, defaults to 'false' SkipBundleDeps - if 'true', skips building eng/dcppack, eng/dashboardpack, Aspire.Dashboard, Aspire.TerminalHost, and Aspire.Cli projects during the main managed build, defaults to 'false' - BuildBundleDepsOnly - if 'true', builds only the RID-specific eng/dcppack and eng/dashboardpack projects for $(TargetRids), plus Aspire.Dashboard and Aspire.TerminalHost for restore, defaults to 'false' TargetRids - colon separated list of RIDs to build native projects for --> @@ -23,25 +22,10 @@ $(BuildRid) - - - <_BundleDependencyTargetRid Include="$(TargetRids.Split(':'))" /> - <_BundleDependencyProject Include="@(_BundleDependencyTargetRid -> '$(RepoRoot)eng\dcppack\Aspire.Hosting.Orchestration.%(Identity).csproj')" /> - <_BundleDependencyProject Include="@(_BundleDependencyTargetRid -> '$(RepoRoot)eng\dashboardpack\Aspire.Dashboard.Sdk.%(Identity).csproj')" /> - - - - - - - - + @@ -75,7 +59,7 @@ - + @@ -84,13 +68,13 @@ - + - + diff --git a/eng/Bundle.proj b/eng/Bundle.proj index 61887c18a61..e50359e463d 100644 --- a/eng/Bundle.proj +++ b/eng/Bundle.proj @@ -1,31 +1,44 @@ - + + + false + + Debug @@ -37,199 +50,541 @@ linux-x64 - $([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..')) - $(RepoRoot)artifacts\ - $(ArtifactsDir)log\$(Configuration)\ - $(ArtifactsDir)bundle\$(TargetRid)\ - - - $(RepoRoot)src\Aspire.Cli\Aspire.Cli.csproj - $(RepoRoot)src\Aspire.Managed\Aspire.Managed.csproj - $(RepoRoot)src\Aspire.Hosting.Native.Server\Aspire.Hosting.Native.Server.csproj - $(RepoRoot)src\Aspire.Dashboard\Aspire.Dashboard.csproj - $(RepoRoot)src\Aspire.TerminalHost\Aspire.TerminalHost.csproj - $(RepoRoot)src\Aspire.Hosting.AppHost\Aspire.Hosting.AppHost.csproj - $(RepoRoot)tools\CreateLayout\CreateLayout.csproj - $(RepoRoot)src\Aspire.Tray\Mac\Aspire.Tray.Mac.csproj - $(ArtifactsDir)bin\Aspire.Tray.Mac\$(Configuration)\net10.0\$(TargetRid)\app\Aspire Tray.app - $(RepoRoot)src\Aspire.Tray\Windows\Aspire.Tray.Windows.csproj - $(ArtifactsDir)bin\Aspire.Tray.Windows\$(Configuration)\net10.0\$(TargetRid)\publish - $(RepoRoot)src\Aspire.Tray\Linux\Aspire.Tray.Linux.csproj - $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin', 'Aspire.Tray.Linux', '$(Configuration)', 'net10.0', '$(TargetRid)', 'publish')) - false - false + <_RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..')) + <_BundleEngineeringDir>$(MSBuildThisFileDirectory) + <_ArtifactsDir>$(_RepoRoot)artifacts\ + <_ArtifactsLogDir>$(_ArtifactsDir)log\$(Configuration)\ + <_BundleLayoutDir>$(_ArtifactsDir)bundle\$(TargetRid)\ + + + <_ManagedProjectPath>$(_RepoRoot)src\Aspire.Managed\Aspire.Managed.csproj + <_TrayProjectPath Condition="$(TargetRid.StartsWith('osx-'))">$(_RepoRoot)src\Aspire.Tray\Mac\Aspire.Tray.Mac.csproj + <_TrayProjectPath Condition="$(TargetRid.StartsWith('win-'))">$(_RepoRoot)src\Aspire.Tray\Windows\Aspire.Tray.Windows.csproj + <_TrayProjectPath Condition="'$(TargetRid)' == 'linux-x64' or '$(TargetRid)' == 'linux-arm64'">$(_RepoRoot)src\Aspire.Tray\Linux\Aspire.Tray.Linux.csproj + + $([MSBuild]::NormalizePath('$(_ArtifactsDir)', 'bin', 'Aspire.Tray.Mac', '$(Configuration)', '$(DefaultTargetFramework)', '$(TargetRid)', 'app', 'Aspire Tray.app')) + $([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.Tray.Windows', '$(Configuration)', '$(DefaultTargetFramework)', '$(TargetRid)', 'publish')) + $([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.Tray.Linux', '$(Configuration)', '$(DefaultTargetFramework)', '$(TargetRid)', 'publish')) $(VersionPrefix)-$(VersionSuffix) $(VersionPrefix)-dev - - <_VersionSuffixArg Condition="'$(VersionSuffix)' != ''">/p:VersionSuffix=$(VersionSuffix) - <_OfficialBuildIdArg Condition="'$(OfficialBuildId)' != ''">/p:OfficialBuildId=$(OfficialBuildId) + false + false + + <_BuildScriptPath Condition="'$(_BuildScriptPath)' == '' and $([MSBuild]::IsOSPlatform('Windows'))">$([MSBuild]::NormalizePath('$(_RepoRoot)', 'build.cmd')) + <_BuildScriptPath Condition="'$(_BuildScriptPath)' == ''">$([MSBuild]::NormalizePath('$(_RepoRoot)', 'build.sh')) + + <_ManagedPublishDir>$([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.Managed', '$(Configuration)', '$(DefaultTargetFramework)', '$(TargetRid)', 'publish')) + <_DashboardPublishDir>$([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.Dashboard', '$(TargetRid)', '$(Configuration)', '$(AspireDashboardTargetFramework)', '$(TargetRid)', 'publish')) + <_TerminalHostPublishDir>$([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.TerminalHost', '$(Configuration)', '$(AspireTerminalHostTargetFramework)', '$(TargetRid)', 'publish')) + <_AppHostServerPublishDir>$([MSBuild]::NormalizeDirectory('$(_ArtifactsDir)', 'bin', 'Aspire.Hosting.Native.Server', '$(Configuration)', '$(AspireNativeServerTargetFramework)', '$(TargetRid)', 'publish')) + + + <_BundleChildArgs>/p:Configuration=$(Configuration) /p:TargetRid=$(TargetRid) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild) /p:VersionPrefix=$(VersionPrefix) + + <_BundleNuGetCache Condition="'$(RestorePackagesPath)' != ''">$([MSBuild]::EnsureTrailingSlash('$(RestorePackagesPath)')) + <_BundleNuGetCache Condition="'$(_BundleNuGetCache)' == '' and '$(NUGET_PACKAGES)' != ''">$([MSBuild]::EnsureTrailingSlash('$(NUGET_PACKAGES)')) + <_BundleNuGetCache Condition="'$(_BundleNuGetCache)' == '' and '$(ContinuousIntegrationBuild)' == 'true' and '$(NUGET_PACKAGES)' == ''">$([MSBuild]::NormalizeDirectory('$(_RepoRoot)', '.packages')) - - <_BinlogArg Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir) + + + <_BundleChildArgs Condition="'$(_BundleNuGetCache)' != ''">$(_BundleChildArgs) "/p:RestorePackagesPath=$(_BundleNuGetCache.TrimEnd('\').TrimEnd('/'))/" "/p:NuGetPackageRoot=$(_BundleNuGetCache.TrimEnd('\').TrimEnd('/'))/" + + <_NuGetCacheEnvironmentVariables Condition="'$(_BundleNuGetCache)' != ''">NUGET_PACKAGES=$(_BundleNuGetCache) + + <_BundleChildArgs Condition="'$(VersionSuffix)' != ''">$(_BundleChildArgs) /p:VersionSuffix=$(VersionSuffix) + <_BundleChildArgs Condition="'$(DotNetFinalVersionKind)' != ''">$(_BundleChildArgs) /p:DotNetFinalVersionKind=$(DotNetFinalVersionKind) + <_BundleChildArgs Condition="'$(StabilizePackageVersion)' != ''">$(_BundleChildArgs) /p:StabilizePackageVersion=$(StabilizePackageVersion) + + + <_BundleChildArgs Condition="'$(OfficialBuildId)' != ''">$(_BundleChildArgs) /p:OfficialBuildId=$(OfficialBuildId) + <_BundleChildArgs Condition="'$(IsOfficialBuild)' != ''">$(_BundleChildArgs) /p:IsOfficialBuild=$(IsOfficialBuild) + <_BundleChildArgs Condition="'$(OfficialBuild)' != ''">$(_BundleChildArgs) /p:OfficialBuild=$(OfficialBuild) + + <_BundleChildArgs Condition="'$(AspireCliChannel)' != ''">$(_BundleChildArgs) /p:AspireCliChannel=$(AspireCliChannel) - - + + <_SupportedBundleRid Include="win-x64;win-arm64;osx-x64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64" /> + + + - + - + + + + + + + + + + + + + + <_MatchingBundleRid Include="@(_SupportedBundleRid)" + Condition="$([System.String]::Equals('%(_SupportedBundleRid.Identity)', '$(TargetRid)'))" /> + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + <_BundleSigningArgs Condition="'$(DotNetSignType)' != ''">/p:DotNetSignType=$(DotNetSignType) + <_BundleSigningArgs>$(_BundleSigningArgs) "/p:ArtifactsDir=$(_ArtifactsDir.TrimEnd('\').TrimEnd('/'))/" + <_BundleSigningArgs Condition="'$(TeamName)' != ''">$(_BundleSigningArgs) "/p:TeamName=$(TeamName)" + <_BundleSigningArgs Condition="'$(DotNetPublishUsingPipelines)' != ''">$(_BundleSigningArgs) /p:DotNetPublishUsingPipelines=$(DotNetPublishUsingPipelines) + <_BundleSigningArgs Condition="$(TargetRid.StartsWith('win-'))">$(_BundleSigningArgs) "/p:TrayDirectory=$(TrayDirectory.TrimEnd('\').TrimEnd('/'))/" + + <_ComponentSigningResponseFile>$(_ArtifactsLogDir)SignBundleComponents.rsp + + + + <_BundleMSBuildArgument Include="$([System.Text.RegularExpressions.Regex]::Replace('$(_BundleChildArgs) $(_BundleSigningArgs)', '("[^"]*"|\S+)\s*', '$1 '))" /> + + + + <_ExecutableExtension> + <_ExecutableExtension Condition="$(TargetRid.StartsWith('win-'))">.exe + <_ManagedExecutablePath>$([MSBuild]::NormalizePath('$(_ManagedPublishDir)', 'aspire-managed$(_ExecutableExtension)')) + <_DashboardExecutablePath>$([MSBuild]::NormalizePath('$(_DashboardPublishDir)', 'Aspire.Dashboard$(_ExecutableExtension)')) + <_TerminalHostExecutablePath>$([MSBuild]::NormalizePath('$(_TerminalHostPublishDir)', 'Aspire.TerminalHost$(_ExecutableExtension)')) + <_AppHostServerExecutablePath>$([MSBuild]::NormalizePath('$(_AppHostServerPublishDir)', 'Aspire.Hosting.Native.Server$(_ExecutableExtension)')) + <_BundleArchivePath>$([MSBuild]::NormalizePath('$(_ArtifactsDir)', 'bundle', 'aspire-$(BundleVersion)-$(TargetRid).tar.gz')) + + + + + <_BundleBuildOs Condition="$(TargetRid.StartsWith('win-'))">windows + <_BundleBuildOs Condition="$(TargetRid.StartsWith('osx-'))">darwin + <_BundleBuildOs Condition="$(TargetRid.StartsWith('linux-'))">linux + <_BundleBuildOs Condition="$(TargetRid.StartsWith('linux-musl-'))">linux-musl + <_BundleBuildArch Condition="$(TargetRid.EndsWith('-x64'))">amd64 + <_BundleBuildArch Condition="$(TargetRid.EndsWith('-arm64'))">arm64 + + + + + + + + - + - + - + - + - <_CliBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)PublishCli.binlog - - <_BundleArchivePath>$(ArtifactsDir)bundle\aspire-$(BundleVersion)-$(TargetRid).tar.gz - <_CliPublishOutputArg Condition="'$(CliPublishDir)' != ''">--output "$(CliPublishDir)" + <_AppHostProjectPath Condition="'$(_AppHostProjectPath)' == ''">$(_RepoRoot)src\Aspire.Hosting.AppHost\Aspire.Hosting.AppHost.csproj - - + + + - - - <_ManagedBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)PublishManaged.binlog - <_DashboardBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)PublishDashboard.binlog - <_TerminalHostBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)PublishTerminalHost.binlog - + + + + - - - - - + - - + + + - <_AppHostServerBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:"$(ArtifactsLogDir)PublishAppHostServer.binlog" + <_DashboardProjectPath Condition="'$(_DashboardProjectPath)' == ''">$(_RepoRoot)src\Aspire.Dashboard\Aspire.Dashboard.csproj + <_DashboardPublishLogPath>$([MSBuild]::NormalizePath('$(_ArtifactsLogDir)', 'PublishNativeDashboard.log')) - + + + + - - + - <_TrayBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)PublishTray.binlog + <_TerminalHostProjectPath Condition="'$(_TerminalHostProjectPath)' == ''">$(_RepoRoot)src\Aspire.TerminalHost\Aspire.TerminalHost.csproj - - - - <_TrayPublish Include="$(TrayProjectPath)" Condition="$(TargetRid.StartsWith('osx-'))"> - /p:TrayAppPath="$(TrayAppPath)" - - <_TrayPublish Include="$(WindowsTrayProjectPath)" Condition="$(TargetRid.StartsWith('win-'))"> - --self-contained --output "$(WindowsTrayPath)" - - <_TrayPublish Include="$(LinuxTrayProjectPath)" Condition="'$(TargetRid)' == 'linux-x64' or '$(TargetRid)' == 'linux-arm64'"> - --self-contained --output "$(LinuxTrayDirectory)" - - + + + + + + + + <_AppHostServerProjectPath Condition="'$(_AppHostServerProjectPath)' == ''">$(_RepoRoot)src\Aspire.Hosting.Native.Server\Aspire.Hosting.Native.Server.csproj + + + + + + + + + + + + + + + - + + + - + + - <_DcpBinlog Condition="'$(ContinuousIntegrationBuild)' == 'true'">-bl:$(ArtifactsLogDir)RestoreDcp.binlog - - - <_BundleBuildOs Condition="$(TargetRid.StartsWith('win-'))">windows - <_BundleBuildOs Condition="$(TargetRid.StartsWith('osx-'))">darwin - <_BundleBuildOs Condition="$(TargetRid.StartsWith('linux-musl-'))">linux-musl - <_BundleBuildOs Condition="'$(_BundleBuildOs)' == '' and $(TargetRid.StartsWith('linux-'))">linux + <_TraySigningArchivePath Condition="'$(_TraySigningArchivePath)' == ''">$([MSBuild]::NormalizePath('$(_ArtifactsDir)', 'bin', 'Aspire.Tray.Mac', '$(Configuration)', '$(DefaultTargetFramework)', '$(TargetRid)', 'signing', 'AspireTray.zip')) + <_TrayBuildProperties>Configuration=$(Configuration);TargetRid=$(TargetRid);RuntimeIdentifier=$(TargetRid);ContinuousIntegrationBuild=$(ContinuousIntegrationBuild);VersionPrefix=$(VersionPrefix);TrayAppPath=$(TrayDirectory);TraySigningArchive=$(_TraySigningArchivePath) + <_TrayBuildProperties Condition="'$(_BundleNuGetCache)' != ''" >$(_TrayBuildProperties);RestorePackagesPath=$(_BundleNuGetCache);NuGetPackageRoot=$(_BundleNuGetCache) + <_TrayBuildProperties Condition="'$(VersionSuffix)' != ''" >$(_TrayBuildProperties);VersionSuffix=$(VersionSuffix) + <_TrayBuildProperties Condition="'$(DotNetFinalVersionKind)' != ''" >$(_TrayBuildProperties);DotNetFinalVersionKind=$(DotNetFinalVersionKind) + <_TrayBuildProperties Condition="'$(StabilizePackageVersion)' != ''">$(_TrayBuildProperties);StabilizePackageVersion=$(StabilizePackageVersion) + <_TrayBuildProperties Condition="'$(OfficialBuildId)' != ''" >$(_TrayBuildProperties);OfficialBuildId=$(OfficialBuildId) + <_TrayBuildProperties Condition="'$(IsOfficialBuild)' != ''" >$(_TrayBuildProperties);IsOfficialBuild=$(IsOfficialBuild) + <_TrayBuildProperties Condition="'$(OfficialBuild)' != ''" >$(_TrayBuildProperties);OfficialBuild=$(OfficialBuild) + <_TrayBuildProperties Condition="'$(AspireCliChannel)' != ''" >$(_TrayBuildProperties);AspireCliChannel=$(AspireCliChannel) + + - <_BundleBuildArch Condition="$(TargetRid.EndsWith('-x64'))">amd64 - <_BundleBuildArch Condition="$(TargetRid.EndsWith('-arm64'))">arm64 - <_BundleBuildArch Condition="$(TargetRid.EndsWith('-x86'))">386 + + + + <_DashboardSymbolsPath>$([MSBuild]::NormalizePath('$(_DashboardPublishDir)', 'Aspire.Dashboard.dSYM')) + <_TerminalHostSymbolsPath>$([MSBuild]::NormalizePath('$(_TerminalHostPublishDir)', 'Aspire.TerminalHost.dSYM')) + <_AppHostServerSymbolsPath>$([MSBuild]::NormalizePath('$(_AppHostServerPublishDir)', 'Aspire.Hosting.Native.Server.dSYM')) - - - + + + + + - + + + + + <_ComponentSigningArgument Include="@(_BundleMSBuildArgument)" /> + <_ComponentSigningArgument Include=""/p:Projects=$(_ManagedProjectPath)"" /> + <_ComponentSigningArgument Include=""/bl:$(_ArtifactsLogDir)SignBundleComponents.binlog"" /> + + - - <_BundleOutputDirArg>$(BundleOutputDir.TrimEnd('\').TrimEnd('/')) - <_ArtifactsDirArg>$(ArtifactsDir.TrimEnd('\').TrimEnd('/')) + <_ComponentSigningResponseArgument>"@$(_ComponentSigningResponseFile)" + + <_ComponentSigningResponseArgument Condition="$([MSBuild]::IsOSPlatform('Windows'))">"'@$(_ComponentSigningResponseFile.Replace("'", "''"))'" + + + - <_CreateLayoutArgs>--output "$(_BundleOutputDirArg)" --artifacts "$(_ArtifactsDirArg)" --rid $(TargetRid) --configuration $(Configuration) --bundle-version $(BundleVersion) --verbose --archive - <_CreateLayoutArgs Condition="$(TargetRid.StartsWith('osx-'))">$(_CreateLayoutArgs) --tray-app "$(TrayAppPath)" - <_CreateLayoutArgs Condition="$(TargetRid.StartsWith('win-'))">$(_CreateLayoutArgs) --tray-windows "$(WindowsTrayPath)" - <_CreateLayoutArgs Condition="'$(TargetRid)' == 'linux-x64' or '$(TargetRid)' == 'linux-arm64'">$(_CreateLayoutArgs) --tray-linux "$(LinuxTrayDirectory)" + + + + + + + + + <_TraySigningProjectPath Condition="'$(_TraySigningProjectPath)' == ''">$([MSBuild]::NormalizePath('$(_BundleEngineeringDir)', 'pipelines', 'SignTray.proj')) - - + + + + - - + - <_TrayArchivePath>$(ArtifactsDir)bundle/aspire-$(BundleVersion)-$(TargetRid).tar.gz + <_PreparedSqliteLibrary>libe_sqlite3.so + <_PreparedSqliteLibrary Condition="$(TargetRid.StartsWith('win-'))">e_sqlite3.dll + <_PreparedSqliteLibrary Condition="$(TargetRid.StartsWith('osx-'))">libe_sqlite3.dylib + - <_TrayVerifier Include="$(RepoRoot)tools/CreateLayout/verify-tray-payload.sh" Condition="$(TargetRid.StartsWith('osx-'))"> - bash - "$(_TrayArchivePath)" "$(TargetRid)" "$(RequireMacTraySignature)" - - <_TrayVerifier Include="$(RepoRoot)tools/CreateLayout/verify-windows-tray-payload.ps1" Condition="$(TargetRid.StartsWith('win-'))"> - pwsh -NoProfile -File - -Archive "$(_TrayArchivePath)" -Rid "$(TargetRid)" -RequireSignature $(RequireWindowsTraySignature) - - <_TrayVerifier Include="$(RepoRoot)tools/CreateLayout/verify-linux-tray-payload.sh" Condition="'$(TargetRid)' == 'linux-x64' or '$(TargetRid)' == 'linux-arm64'"> - bash - "$(_TrayArchivePath)" "$(TargetRid)" - + <_RequiredPreparedBundleFile Include="$(_ManagedExecutablePath)" /> + <_RequiredPreparedBundleFile Include="$(_TerminalHostExecutablePath)" /> + <_RequiredPreparedBundleFile Include="$(_AppHostServerExecutablePath);$([MSBuild]::NormalizePath('$(_AppHostServerPublishDir)', 'ats-contract.json'))" /> + <_RequiredPreparedBundleFile Include="$(_DashboardExecutablePath);$([MSBuild]::NormalizePath('$(_DashboardPublishDir)', 'wwwroot', '_framework', 'blazor.web.js'));$([MSBuild]::NormalizePath('$(_DashboardPublishDir)', '$(_PreparedSqliteLibrary)'))" /> + <_RequiredPreparedBundleFile Include="$([MSBuild]::NormalizePath('$(TrayDirectory)', 'aspire-tray.exe'));$([MSBuild]::NormalizePath('$(TrayDirectory)', 'Aspire.ico'))" + Condition="$(TargetRid.StartsWith('win-'))" /> + <_RequiredPreparedBundleFile Include="$([MSBuild]::NormalizePath('$(TrayDirectory)', 'Contents', 'MacOS', 'aspire-tray'));$([MSBuild]::NormalizePath('$(TrayDirectory)', 'Contents', 'Info.plist'));$([MSBuild]::NormalizePath('$(TrayDirectory)', 'Contents', 'Resources', 'Aspire.icns'))" + Condition="$(TargetRid.StartsWith('osx-'))" /> + <_RequiredPreparedBundleFile Include="$([MSBuild]::NormalizePath('$(TrayDirectory)', 'aspire-tray'));$([MSBuild]::NormalizePath('$(TrayDirectory)', 'Aspire.png'))" + Condition="'$(TargetRid)' == 'linux-x64' or '$(TargetRid)' == 'linux-arm64'" /> - + + + + + + + + <_DashboardPackProjectPath Condition="'$(_DashboardPackProjectPath)' == ''">$([MSBuild]::NormalizePath('$(_BundleEngineeringDir)', 'dashboardpack', 'Aspire.Dashboard.Sdk.$(TargetRid).csproj')) + <_DcpPackProjectPath Condition="'$(_DcpPackProjectPath)' == ''">$([MSBuild]::NormalizePath('$(_BundleEngineeringDir)', 'dcppack', 'Aspire.Hosting.Orchestration.$(TargetRid).csproj')) + + + + + + + + + <_RequireWindowsTraySignature>false + <_RequireMacTraySignature>false + <_RequireWindowsTraySignature Condition="$(TargetRid.StartsWith('win-')) and '$(Sign)' == 'true' and '$(DotNetSignType)' == 'real'">true + <_RequireMacTraySignature Condition="$(TargetRid.StartsWith('osx-')) and '$(Sign)' == 'true' and '$(DotNetSignType)' == 'real'">true + <_CreateLayoutProjectPath Condition="'$(_CreateLayoutProjectPath)' == ''">$(_RepoRoot)tools\CreateLayout\CreateLayout.csproj + + <_BundleLayoutDirArg>$(_BundleLayoutDir.TrimEnd('\').TrimEnd('/')) + <_ArtifactsDirArg>$(_ArtifactsDir.TrimEnd('\').TrimEnd('/')) + <_DashboardPublishDirArg>$(_DashboardPublishDir.TrimEnd('\').TrimEnd('/')) + <_ManagedPublishDirArg>$(_ManagedPublishDir.TrimEnd('\').TrimEnd('/')) + <_TerminalHostPublishDirArg>$(_TerminalHostPublishDir.TrimEnd('\').TrimEnd('/')) + <_AppHostServerPublishDirArg>$(_AppHostServerPublishDir.TrimEnd('\').TrimEnd('/')) + + <_CreateLayoutArgs>--output "$(_BundleLayoutDirArg)" --artifacts "$(_ArtifactsDirArg)" --managed "$(_ManagedPublishDirArg)" --dashboard "$(_DashboardPublishDirArg)" --terminal-host "$(_TerminalHostPublishDirArg)" --apphost-server "$(_AppHostServerPublishDirArg)" --rid $(TargetRid) --configuration $(Configuration) --bundle-version $(BundleVersion) --verbose --archive + <_CreateLayoutArgs Condition="'$(TargetRid)' != 'linux-musl-x64'">$(_CreateLayoutArgs) --tray-dir "$(TrayDirectory.TrimEnd('\').TrimEnd('/'))/" + + + + + + + + + + + + + + + <_CliProjectPath Condition="'$(_CliProjectPath)' == ''">$(_RepoRoot)src\Aspire.Cli\Aspire.Cli.csproj + <_CliPublishOutputArg Condition="'$(CliPublishDir)' != ''">--output "$(CliPublishDir)" + + + + + + + + + <_BundleSignSwitch Condition="'$(Sign)' == 'true'">-sign + + + + <_CliDistributionResponseFile>$(_ArtifactsLogDir)PublishAndPackageCli.rsp + <_StandaloneSigningResponseFile>$(_ArtifactsLogDir)SignNonCliDistributionPackages.rsp + <_CliDistributionResponseArgument>"@$(_CliDistributionResponseFile)" + <_StandaloneSigningResponseArgument>"@$(_StandaloneSigningResponseFile)" + <_CliDistributionResponseArgument Condition="$([MSBuild]::IsOSPlatform('Windows'))">"'@$(_CliDistributionResponseFile.Replace("'", "''"))'" + <_StandaloneSigningResponseArgument Condition="$([MSBuild]::IsOSPlatform('Windows'))">"'@$(_StandaloneSigningResponseFile.Replace("'", "''"))'" + + + <_CliDistributionArgument Include="@(_BundleMSBuildArgument)" /> + <_CliDistributionArgument Include="/p:SkipManagedBuild=true;/p:TargetRids=$(TargetRid)" /> + <_CliDistributionArgument Include=""/p:BundlePayloadPath=$(_BundleArchivePath)"" /> + <_CliDistributionArgument Include=""/bl:$(_ArtifactsLogDir)PublishAndPackageCli.binlog"" /> + + + + + + + + + diff --git a/eng/Signing.props b/eng/Signing.props index 2d3daaec229..5df75d80f29 100644 --- a/eng/Signing.props +++ b/eng/Signing.props @@ -125,6 +125,10 @@ + + diff --git a/eng/Versions.props b/eng/Versions.props index 254befed945..1023f072a83 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -10,6 +10,9 @@ 17.0 net10.0 + net11.0 + net11.0 + net11.0 $(DefaultTargetFramework);net11.0 10.0.14 diff --git a/eng/build.ps1 b/eng/build.ps1 index 8daa4cbaa53..16b42e9003d 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -235,9 +235,10 @@ if ($bundle) { "/p:TargetRid=$rid" ) - # Pass through SkipNativeBuild if set - if ($remainingArguments -contains "/p:SkipNativeBuild=true") { - $bundleArgs += "/p:SkipNativeBuild=true" + # Preserve the legacy wrapper switch; advanced controls use Bundle.proj directly. + if ($remainingArguments -contains "/p:SkipNativeBuild=true" -or + $remainingArguments -contains "-p:SkipNativeBuild=true") { + $bundleArgs += "/p:SkipCliArtifacts=true" } # CI flag is passed to Bundle.proj which handles version computation via Versions.props diff --git a/eng/build.sh b/eng/build.sh index 350c219817b..2c9b8573a4b 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -334,12 +334,14 @@ if [ "$build_bundle" = true ]; then "/p:TargetRid=$rid" ) - # Pass through SkipNativeBuild if set - for arg in "$@"; do - if [[ "$arg" == *"SkipNativeBuild=true"* ]]; then - bundle_args+=("/p:SkipNativeBuild=true") - break - fi + # Use saved arguments: positional arguments were consumed by option parsing. + # Advanced bundle controls use Bundle.proj directly. + for arg in ${extraargs[@]+"${extraargs[@]}"}; do + case "$arg" in + /p:SkipNativeBuild=true|-p:SkipNativeBuild=true) + bundle_args+=("/p:SkipCliArtifacts=true") + break ;; + esac done # CI flag is passed to Bundle.proj which handles version computation via Versions.props diff --git a/eng/dashboardpack/Common.projitems b/eng/dashboardpack/Common.projitems index 2dff2380abf..c282193a50c 100644 --- a/eng/dashboardpack/Common.projitems +++ b/eng/dashboardpack/Common.projitems @@ -4,7 +4,7 @@ - net11.0 + $(AspireDashboardTargetFramework) true true true diff --git a/eng/github-ci/test-trigger-map.yml b/eng/github-ci/test-trigger-map.yml index 6935c670ead..68f4c9274aa 100644 --- a/eng/github-ci/test-trigger-map.yml +++ b/eng/github-ci/test-trigger-map.yml @@ -105,8 +105,6 @@ ignore: - eng/scripts/test-native-terminalhost.ps1 # unconditional native CLI archive smoke # SDK registration diagnostics run with the unconditional native Windows archive smoke. - eng/scripts/tray-registration-control/** - # The stabilization job invokes this script independently of the tests selector. - - eng/scripts/stabilization-smoke-init-restore.sh # Dev/AzDO-only eng/scripts with NO test consumer and no GH-CI build/test path: local debug-channel # helpers and the AzDO native-symbol validator. Listed so they do not show as unattributed audit noise. # (verify-cli-archive.ps1 and validate-npm-release-aliases.ps1 are NOT here -- they have test consumers @@ -371,8 +369,9 @@ path_rules: reason: native Dashboard archive production and packaged runtime validation - paths: - eng/scripts/verify-native-dashboard-warnings.ps1 - targets: [test:Infrastructure.Tests, job:native-dashboard-validation] - reason: validates the Native AOT Dashboard publish warning policy + - eng/aspire-managed-entitlements.plist + targets: [CLI_ARCHIVE_CONSUMERS, test:Infrastructure.Tests] + reason: native bundle warning validation and macOS JIT signing inputs - paths: - eng/scripts/test-native-tray.ps1 targets: [test:Infrastructure.Tests] @@ -528,6 +527,10 @@ path_rules: - src/Aspire.Tray/Windows/publish.ps1 targets: [CLI_BUNDLE, test:Infrastructure.Tests] reason: native CLI bundle assembly and publishing inputs + - paths: + - eng/Bundle.proj + targets: [test:Aspire.Templates.Tests, job:native-dashboard-validation, job:polyglot] + reason: shared bundle phases produce RID runtime packages and the standalone Dashboard archive - paths: - tools/AnalyzeCiFailure/** @@ -560,6 +563,7 @@ path_rules: # Script behavior and packaging fixtures. - eng/scripts/download-native-archives.ps1 - eng/scripts/stage-native-cli-tool-packages.ps1 + - eng/scripts/stabilization-smoke-init-restore.sh - eng/scripts/validate-npm-package-signatures.ps1 - eng/scripts/validate-npm-release-aliases.ps1 - eng/scripts/aspire-skills-bundle.common.ps1 diff --git a/eng/pipelines/azure-pipelines.yml b/eng/pipelines/azure-pipelines.yml index 52290371ca8..8a2e09b9f2d 100644 --- a/eng/pipelines/azure-pipelines.yml +++ b/eng/pipelines/azure-pipelines.yml @@ -358,8 +358,7 @@ extends: - template: /eng/common/templates-official/jobs/jobs.yml@self parameters: # Enable MicroBuild signing on the Assemble pool so we can sign the - # npm tgz files staged from per-RID native artifacts (see "Sign npm - # package tarballs" step below). The per-RID native jobs cannot sign + # npm tgz files staged from per-RID native artifacts. The per-RID native jobs cannot sign # them because PackDotnetTool (eng/AfterSigning.targets) runs AFTER # Arcade's Sign target — by name and design, the npm tgz files only # exist after Sign has already completed. Upstream signs them in the @@ -445,7 +444,7 @@ extends: # signed upstream — including # Aspire.Hosting.Orchestration..nupkg whose nested # manifest.cat would be re-submitted to ESRP. Keeping Shipping - # limited to native CLI and Dashboard packages at + # limited to native CLI and Linux Dashboard packages at # sign time avoids that. - pwsh: | $ErrorActionPreference = 'Stop' @@ -455,32 +454,23 @@ extends: -RequireNpmPackages displayName: 🟣Stage Native CLI Packages - # Stage every Dashboard RID alongside the CLI packages before signing. - # Linux native jobs skip ELF signing, but their nupkgs still need signing. + # Linux jobs do not sign their NuGet containers. Stage these + # before signing; Windows/macOS packages stay out so their signed + # nested executables are not reprocessed. - pwsh: | $ErrorActionPreference = 'Stop' $sourceRoot = "$(Build.SourcesDirectory)/artifacts/native-cli-packages/$(_BuildConfig)" $shipping = "$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping" - $packages = @(Get-ChildItem -Path $sourceRoot -Filter "Aspire.Dashboard.Sdk.*.nupkg" -File -Recurse) - if ($packages.Count -ne 7) { - throw "Expected 7 Native AOT Dashboard RID packages, found $($packages.Count): $($packages.FullName -join ', ')" + $packages = @(Get-ChildItem -Path $sourceRoot -Filter "Aspire.Dashboard.Sdk.linux-*.nupkg" -File -Recurse) + if ($packages.Count -ne 3) { + throw "Expected 3 Linux Dashboard RID packages, found $($packages.Count): $($packages.FullName -join ', ')" } foreach ($package in $packages) { Copy-Item -LiteralPath $package.FullName -Destination $shipping -Force } + displayName: 🟣Stage Linux Dashboard packages for signing - $stagedPackages = @(Get-ChildItem -Path $shipping -Filter "Aspire.Dashboard.Sdk.*.nupkg" -File) - if ($stagedPackages.Count -ne 7) { - throw "Expected 7 staged Native AOT Dashboard RID packages, found $($stagedPackages.Count)." - } - - $dashboardArchives = @(Get-ChildItem -Path "$(Build.SourcesDirectory)/artifacts/DashboardArtifacts/$(_BuildConfig)" -Filter "aspire-dashboard-*.zip" -File -Recurse) - if ($dashboardArchives.Count -ne 7) { - throw "Expected 7 Native AOT Dashboard runtime archives, found $($dashboardArchives.Count): $($dashboardArchives.FullName -join ', ')" - } - displayName: 🟣Stage Native AOT Dashboard packages - - # Sign the npm tgz and Dashboard NuGet packages staged in Shipping. + # Sign the npm tgz files now that they are staged in Shipping. # PackDotnetTool runs in eng/AfterSigning.targets — after Arcade's # Sign target — so the per-RID native jobs cannot sign the tgz # files themselves. Upstream signs them on the Windows @@ -501,7 +491,7 @@ extends: /p:SkipManagedBuild=true /p:SkipTestProjects=true -projects $(Build.SourcesDirectory)/src/Aspire.Hosting/Aspire.Hosting.csproj - displayName: 🟣Sign npm package tarballs + displayName: 🟣Sign CLI and Linux Dashboard packages condition: and(succeeded(), eq(variables['_SignType'], 'real')) env: SYSTEM_ACCESSTOKEN: $(System.AccessToken) # Needed for the signing task @@ -546,6 +536,33 @@ extends: artifact: aspire-vscode-extension targetPath: '$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/vscode' + # Linux packages are already staged and signed above. Copy only + # Windows/macOS packages now, preserving both sets' signatures. + - pwsh: | + $ErrorActionPreference = 'Stop' + $sourceRoot = "$(Build.SourcesDirectory)/artifacts/native-cli-packages/$(_BuildConfig)" + $shipping = "$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping" + $packages = @(Get-ChildItem -Path $sourceRoot -Filter "Aspire.Dashboard.Sdk.*.nupkg" -File -Recurse) + if ($packages.Count -ne 7) { + throw "Expected 7 Native AOT Dashboard RID packages, found $($packages.Count): $($packages.FullName -join ', ')" + } + foreach ($package in $packages) { + if (-not $package.Name.StartsWith('Aspire.Dashboard.Sdk.linux-')) { + Copy-Item -LiteralPath $package.FullName -Destination $shipping -Force + } + } + + $stagedPackages = @(Get-ChildItem -Path $shipping -Filter "Aspire.Dashboard.Sdk.*.nupkg" -File) + if ($stagedPackages.Count -ne 7) { + throw "Expected 7 staged Native AOT Dashboard RID packages, found $($stagedPackages.Count)." + } + + $dashboardArchives = @(Get-ChildItem -Path "$(Build.SourcesDirectory)/artifacts/DashboardArtifacts/$(_BuildConfig)" -Filter "aspire-dashboard-*.zip" -File -Recurse) + if ($dashboardArchives.Count -ne 7) { + throw "Expected 7 Native AOT Dashboard runtime archives, found $($dashboardArchives.Count): $($dashboardArchives.FullName -join ', ')" + } + displayName: 🟣Stage Native AOT Dashboard packages + - pwsh: | $ErrorActionPreference = 'Stop' $shipping = "$(Build.SourcesDirectory)/artifacts/packages/$(_BuildConfig)/Shipping" diff --git a/eng/pipelines/templates/build_sign_native.yml b/eng/pipelines/templates/build_sign_native.yml index 29effa925a4..e4c48ce634c 100644 --- a/eng/pipelines/templates/build_sign_native.yml +++ b/eng/pipelines/templates/build_sign_native.yml @@ -47,17 +47,13 @@ jobs: displayName: ${{ replace(targetRid, '-', '_') }} # Signing and notarization can push successful macOS jobs close to an hour. ${{ if eq(parameters.agentOs, 'macos') }}: - timeoutInMinutes: 90 + # The unified signed build also signs/notarizes the component payload. + timeoutInMinutes: ${{ iif(eq(parameters.codeSign, true), 120, 90) }} ${{ else }}: timeoutInMinutes: 60 variables: - TeamName: ${{ parameters.teamName }} - - ${{ if eq(parameters.codeSign, true) }}: - - _buildArgs: '-sign' - - ${{ else }}: - - _buildArgs: '' - - ${{ if eq(parameters.agentOs, 'windows') }}: - scriptName: build.cmd - dotnetScript: dotnet.cmd @@ -188,189 +184,35 @@ jobs: name: computeCliChannel displayName: 🟣Determine Aspire CLI channel - # Build, publish, and sign aspire-managed before creating the bundle layout. - # This ensures aspire-managed is signed before CreateLayout packs it into the bundle archive. - # Step 1: dotnet publish produces the self-contained single-file binary. - # Step 2: build.sh -sign runs Arcade's signing (only when codeSign is enabled). - # Step 3: Bundle.proj creates the bundle layout and archive using the signed binary. - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - publish - $(Build.SourcesDirectory)/src/Aspire.Managed/Aspire.Managed.csproj - -c $(_BuildConfig) - -r ${{ targetRid }} - --self-contained - /p:GenerateDocumentationFile=false - /p:EnforceCodeStyleInBuild=false - ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)PublishManaged.binlog - displayName: 🟣Prepare aspire-managed + - task: NodeTool@0 + displayName: 🟣Install node.js + inputs: + versionSpec: '22.x' + # Keep signing credentials/plugin setup in the pipeline; Bundle.proj + # owns ordering and invokes fresh Arcade build/sign/pack processes. - script: >- $(Build.SourcesDirectory)/$(dotnetScript) msbuild $(Build.SourcesDirectory)/eng/Bundle.proj - /t:_PublishAppHostServer + /t:Build + /p:BuildDistributionPackages=true /p:Configuration=$(_BuildConfig) /p:TargetRid=${{ targetRid }} + /p:BundleVersion=ci-bundlepayload + /p:ContinuousIntegrationBuild=true + /p:AspireCliChannel=$(aspireCliChannel) ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)PublishAppHostServer.binlog - displayName: Prepare AppHost Server v2 - - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - publish - $(Build.SourcesDirectory)/src/Aspire.TerminalHost/Aspire.TerminalHost.csproj - -c $(_BuildConfig) - -r ${{ targetRid }} - /p:GenerateDocumentationFile=false - /p:EnforceCodeStyleInBuild=false - ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)PublishTerminalHost.binlog - displayName: 🟣Prepare Native AOT TerminalHost - - - pwsh: | - $ErrorActionPreference = 'Stop' - $buildLog = "$(Build.Arcade.LogsPath)PublishNativeDashboard.log" - & "$(Build.SourcesDirectory)/$(dotnetScript)" ` - publish ` - "$(Build.SourcesDirectory)/src/Aspire.Dashboard/Aspire.Dashboard.csproj" ` - -c "$(_BuildConfig)" ` - -r "${{ targetRid }}" ` - /p:PlatformName=${{ targetRid }} ` - /p:GenerateDocumentationFile=false ` - /p:EnforceCodeStyleInBuild=false ` - ${{ parameters.extraBuildArgs }} ` - /bl:$(Build.Arcade.LogsPath)PublishDashboard.binlog 2>&1 | Tee-Object -FilePath $buildLog - if ($LASTEXITCODE -ne 0) { - exit $LASTEXITCODE - } - displayName: 🟣Prepare Native AOT Dashboard - - - pwsh: >- - & "$(Build.SourcesDirectory)/eng/scripts/verify-native-dashboard-warnings.ps1" - -BuildLog "$(Build.Arcade.LogsPath)PublishNativeDashboard.log" - displayName: 🟣Verify Native AOT Dashboard warnings - - # On macOS, ad-hoc codesign aspire-managed with JIT entitlements BEFORE Arcade signing. - # MicroBuild (MacDeveloperHardenWithNotarization) preserves entitlements from the prior - # ad-hoc signature when re-signing with the real certificate. Without this step, - # hardened runtime blocks CoreCLR JIT (W^X memory mapping) causing HRESULT: 0x80070008. - # This follows the same pattern used by dotnet/sdk for managed binaries (roslyn-entitlements.plist). - - ${{ if eq(parameters.agentOs, 'macos') }}: - - script: >- - codesign --sign - --force - --entitlements $(Build.SourcesDirectory)/eng/aspire-managed-entitlements.plist - $(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed - displayName: 🟣Ad-hoc codesign aspire-managed with JIT entitlements - - # Publish native tray payloads before signing and never republish afterward. - - ${{ if or(in(parameters.agentOs, 'macos', 'windows'), in(targetRid, 'linux-x64', 'linux-arm64')) }}: - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - msbuild - $(Build.SourcesDirectory)/eng/Bundle.proj - /t:_PublishNativeTray - /p:Configuration=$(_BuildConfig) - /p:TargetRid=${{ targetRid }} - ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)PublishTray.binlog - displayName: 🟣Prepare native tray app - - ${{ if and(eq(parameters.codeSign, true), eq(parameters.agentOs, 'macos')) }}: - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - msbuild - $(Build.SourcesDirectory)/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj - /t:PrepareTraySigning - /p:Configuration=$(_BuildConfig) - /p:RuntimeIdentifier=${{ targetRid }} - displayName: 🟣Prepare tray app signing input - - # ESRP treats executable paths as discovery patterns and otherwise finds adjacent - # .dSYM DWARF binaries with the same names. Native bundle components do not ship - # symbols, so remove them before any signing pass evaluates inputs. - - ${{ if and(eq(parameters.codeSign, true), eq(parameters.agentOs, 'macos')) }}: - - pwsh: | - Remove-Item -LiteralPath "$(Build.SourcesDirectory)/artifacts/bin/Aspire.Dashboard/${{ targetRid }}/Release/net11.0/${{ targetRid }}/publish/Aspire.Dashboard.dSYM" -Recurse -Force - $optionalSymbols = @( - "$(Build.SourcesDirectory)/artifacts/bin/Aspire.TerminalHost/Release/net11.0/${{ targetRid }}/publish/Aspire.TerminalHost.dSYM" - "$(Build.SourcesDirectory)/artifacts/bin/Aspire.Hosting.Native.Server/Release/net11.0/${{ targetRid }}/publish/Aspire.Hosting.Native.Server.dSYM" - ) - foreach ($symbols in $optionalSymbols) { - if (Test-Path -LiteralPath $symbols) { - Remove-Item -LiteralPath $symbols -Recurse -Force - } - } - displayName: 🟣Remove Native AOT bundle debug symbols - - - ${{ if eq(parameters.codeSign, true) }}: - - script: >- - $(Build.SourcesDirectory)/$(scriptName) - -restore -sign - ${{ parameters.extraBuildArgs }} - -projects "$(Build.SourcesDirectory)/src/Aspire.Managed/Aspire.Managed.csproj" - /bl:$(Build.Arcade.LogsPath)SignManaged.binlog - # eng/Signing.props includes the Windows and Linux tray publish outputs. - displayName: 🟣Sign bundle components - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - - ${{ if and(eq(parameters.codeSign, true), eq(parameters.agentOs, 'macos')) }}: - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - msbuild - $(Build.SourcesDirectory)/eng/pipelines/SignTray.proj - -restore - /t:SignTray - /p:Configuration=$(_BuildConfig) - /p:RuntimeIdentifier=${{ targetRid }} - /p:SignType=real - /bl:$(Build.Arcade.LogsPath)SignTray.binlog - displayName: 🟣Sign and notarize whole tray app - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - msbuild - $(Build.SourcesDirectory)/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj - /t:RestoreSignedTray - /p:Configuration=$(_BuildConfig) - /p:RuntimeIdentifier=${{ targetRid }} - displayName: 🟣Restore and verify signed tray app - - # On macOS/Linux, restore the execute bit after Arcade signing. - # MicroBuild rewrites the binary file during signing, which resets permissions - # to the default umask (typically 644). The execute bit must be restored before - # CreateLayout packs the binary into the bundle archive. - - ${{ if and(eq(parameters.codeSign, true), ne(parameters.agentOs, 'windows')) }}: - - script: | - chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed - chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Dashboard/${{ targetRid }}/Release/net11.0/${{ targetRid }}/publish/Aspire.Dashboard - chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Hosting.Native.Server/Release/net11.0/${{ targetRid }}/publish/Aspire.Hosting.Native.Server - chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.TerminalHost/Release/net11.0/${{ targetRid }}/publish/Aspire.TerminalHost - displayName: 🟣Restore execute permissions on managed executables - # Linux tray signing uses the same Arcade pass and also resets its mode. - # Musl has no tray payload; macOS restores its signed app separately above. - - ${{ if in(targetRid, 'linux-x64', 'linux-arm64') }}: - - script: chmod +x "$(Build.SourcesDirectory)/artifacts/bin/Aspire.Tray.Linux/$(_BuildConfig)/net10.0/${{ targetRid }}/publish/aspire-tray" - displayName: 🟣Restore execute permissions on Linux tray - - # Repack the already-published/signed Dashboard without republishing it, - # which would replace the signed executable. Common.projitems recreates - # the runtime ZIP with Overwrite=true, replacing the pre-signing archive. - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - build - $(Build.SourcesDirectory)/eng/dashboardpack/Aspire.Dashboard.Sdk.${{ targetRid }}.csproj - -c $(_BuildConfig) - /p:SkipDashboardPublish=true - ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)PackDashboard.binlog - displayName: 🟣Pack Native AOT Dashboard + /p:Sign=${{ iif(eq(parameters.codeSign, true), '$(_Sign)', 'false') }} + /p:DotNetSignType=${{ iif(eq(parameters.codeSign, true), '$(_SignType)', 'test') }} + /bl:$(Build.Arcade.LogsPath)BuildNativeBundle.binlog + displayName: 🟣Build native bundle and CLI packages + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) - # The native_archives artifact publishes only artifacts/packages. Stage - # the Dashboard runtime zip there so Assemble can recover it alongside - # the RID-specific Dashboard nupkg. + # Bundle.proj builds the Dashboard ZIP under artifacts/DashboardArtifacts, + # but native_archives publishes only artifacts/packages. This copy stages + # the existing ZIP for upload and Assemble; it does not rebuild or repack it. - pwsh: | $ErrorActionPreference = 'Stop' $source = "$(Build.SourcesDirectory)/artifacts/DashboardArtifacts/$(_BuildConfig)/${{ targetRid }}/aspire-dashboard-${{ targetRid }}.zip" @@ -405,26 +247,6 @@ jobs: displayName: 🟣Smoke test packaged Native AOT Dashboard (${{ targetRid }}) condition: and(succeeded(), eq(variables['Agent.OSArchitecture'], variables['_ridAgentArch']), not(contains('${{ targetRid }}', 'musl'))) - - task: NodeTool@0 - displayName: 🟣Install node.js - inputs: - versionSpec: '22.x' - - - script: >- - $(Build.SourcesDirectory)/$(dotnetScript) - msbuild - $(Build.SourcesDirectory)/eng/Bundle.proj - "/t:_RestoreDcpPackage;_RunCreateLayout" - /p:Configuration=$(_BuildConfig) - /p:TargetRid=${{ targetRid }} - /p:BundleVersion=ci-bundlepayload - /p:SkipTrayBuild=true - /p:RequireWindowsTraySignature=${{ parameters.codeSign }} - /p:RequireMacTraySignature=${{ parameters.codeSign }} - /p:ContinuousIntegrationBuild=true - /bl:$(Build.Arcade.LogsPath)BundleLayout.binlog - displayName: 🟣Create bundle layout - - pwsh: >- & "$(Build.SourcesDirectory)/eng/scripts/test-native-tray.ps1" -ArchivePath "$(Build.SourcesDirectory)/artifacts/bundle/aspire-ci-bundlepayload-${{ targetRid }}.tar.gz" @@ -438,24 +260,6 @@ jobs: displayName: 🟣Smoke test bundled Native AOT TerminalHost condition: and(succeeded(), eq(variables['Agent.OSArchitecture'], variables['_ridAgentArch']), not(contains('${{ targetRid }}', 'musl'))) - - script: >- - $(Build.SourcesDirectory)/$(scriptName) - -ci - -build - -pack - -restore - /p:SkipManagedBuild=true - /p:TargetRids=${{ targetRid }} - /p:SkipAppHostServerBuild=true - /p:BundlePayloadPath=$(Build.SourcesDirectory)/artifacts/bundle/aspire-ci-bundlepayload-${{ targetRid }}.tar.gz - /p:AspireCliChannel=$(aspireCliChannel) - $(_buildArgs) - ${{ parameters.extraBuildArgs }} - /bl:$(Build.Arcade.LogsPath)Build.binlog - displayName: 🟣Build native packages - env: - SYSTEM_ACCESSTOKEN: $(System.AccessToken) # Needed for the signing task - - pwsh: | $ErrorActionPreference = 'Stop' $verifyParams = @{ diff --git a/eng/scripts/stabilization-smoke-init-restore.sh b/eng/scripts/stabilization-smoke-init-restore.sh index 42c14cbb891..e8aa491a8d5 100755 --- a/eng/scripts/stabilization-smoke-init-restore.sh +++ b/eng/scripts/stabilization-smoke-init-restore.sh @@ -159,7 +159,7 @@ echo "→ Building a stabilized Release CLI bundle for use as the smoke driver" -p:StabilizePackageVersion=true \ "-p:BundleVersion=$APPHOST_SDK_VERSION" \ "-p:TargetRid=$RUNTIME_IDENTIFIER" \ - -p:SkipNativeBuild=true \ + -p:SkipCliArtifacts=true \ --nologo -v quiet "$DOTNET" publish "$ASPIRE_CLI_PROJECT" \ -c Release -r "$RUNTIME_IDENTIFIER" --self-contained \ diff --git a/localhive.ps1 b/localhive.ps1 index 25af2de85dc..6fdcc180538 100644 --- a/localhive.ps1 +++ b/localhive.ps1 @@ -403,7 +403,6 @@ else { # Build the bundle payload (aspire-managed + DCP tar.gz archive, and optionally native AOT CLI) if (-not $SkipBundle) { $bundleProjPath = Join-Path $RepoRoot "eng" "Bundle.proj" - $skipNativeArg = if ($NativeAot) { '' } else { '/p:SkipNativeBuild=true' } # Clean stale managed publish output so dotnet publish doesn't skip due to incremental builds $staleManagedDir = Join-Path $RepoRoot "artifacts" "bundle" $bundleRid "managed" @@ -415,7 +414,7 @@ if (-not $SkipBundle) { Write-Log "Building bundle (aspire-managed + DCP$(if ($NativeAot) { ' + native AOT CLI' }))..." $buildArgs = @($bundleProjPath, '-c', $effectiveConfig) + $packVersionArgs + @("/p:TargetRid=$bundleRid") if (-not $NativeAot) { - $buildArgs += '/p:SkipNativeBuild=true' + $buildArgs += '/p:SkipCliArtifacts=true' } & dotnet build @buildArgs if ($LASTEXITCODE -ne 0) { @@ -440,7 +439,7 @@ if (-not $SkipCli) { $cliExeName = if ($bundleRid -like 'win-*') { 'aspire.exe' } else { 'aspire' } if ($NativeAot) { - # Native AOT CLI is produced by Bundle.proj's _PublishNativeCli target + # Native AOT CLI is produced by Bundle.proj's final CLI packaging phase. # (already has embedded bundle payload) $cliPublishDir = Join-Path $RepoRoot "artifacts" "bin" "Aspire.Cli" $effectiveConfig "net11.0" $bundleRid "native" if (-not (Test-Path -LiteralPath $cliPublishDir)) { diff --git a/localhive.sh b/localhive.sh index 3dc7d21be67..68964b45483 100755 --- a/localhive.sh +++ b/localhive.sh @@ -414,7 +414,7 @@ if [[ $SKIP_BUNDLE -eq 0 ]]; then else log "Building bundle (aspire-managed + DCP)..." set +e - dotnet build "$BUNDLE_PROJ" -c "$EFFECTIVE_CONFIG" /p:SkipNativeBuild=true "${PACK_VERSION_ARGS[@]}" "/p:TargetRid=$BUNDLE_RID" + dotnet build "$BUNDLE_PROJ" -c "$EFFECTIVE_CONFIG" /p:SkipCliArtifacts=true "${PACK_VERSION_ARGS[@]}" "/p:TargetRid=$BUNDLE_RID" rc=$? set -e fi diff --git a/src/Aspire.Dashboard/Aspire.Dashboard.csproj b/src/Aspire.Dashboard/Aspire.Dashboard.csproj index 3ab192a6b58..12722acd710 100644 --- a/src/Aspire.Dashboard/Aspire.Dashboard.csproj +++ b/src/Aspire.Dashboard/Aspire.Dashboard.csproj @@ -2,7 +2,7 @@ win-x64;win-arm64;linux-x64;linux-arm64;linux-musl-x64;osx-x64;osx-arm64 - net11.0 + $(AspireDashboardTargetFramework) PublicResXFileCodeGenerator $(MSBuildThisFileDirectory)..\Shared\Aspire.ico true diff --git a/src/Aspire.Hosting.Native.Server/Aspire.Hosting.Native.Server.csproj b/src/Aspire.Hosting.Native.Server/Aspire.Hosting.Native.Server.csproj index d85cc363c0e..03d3f6d7c44 100644 --- a/src/Aspire.Hosting.Native.Server/Aspire.Hosting.Native.Server.csproj +++ b/src/Aspire.Hosting.Native.Server/Aspire.Hosting.Native.Server.csproj @@ -1,6 +1,6 @@ - net11.0 + $(AspireNativeServerTargetFramework) Exe false true diff --git a/src/Aspire.Managed/Aspire.Managed.csproj b/src/Aspire.Managed/Aspire.Managed.csproj index 32ad2d7c5f5..97620694712 100644 --- a/src/Aspire.Managed/Aspire.Managed.csproj +++ b/src/Aspire.Managed/Aspire.Managed.csproj @@ -2,7 +2,7 @@ Exe - net10.0 + $(DefaultTargetFramework) enable enable true diff --git a/src/Aspire.TerminalHost/Aspire.TerminalHost.csproj b/src/Aspire.TerminalHost/Aspire.TerminalHost.csproj index 1b1b87e0e31..8c425b6089a 100644 --- a/src/Aspire.TerminalHost/Aspire.TerminalHost.csproj +++ b/src/Aspire.TerminalHost/Aspire.TerminalHost.csproj @@ -2,7 +2,7 @@ Exe - net11.0 + $(AspireTerminalHostTargetFramework) win-x64;win-arm64;linux-x64;linux-arm64;linux-musl-x64;osx-x64;osx-arm64 enable diff --git a/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj b/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj index 2040821b43f..007e17d37e3 100644 --- a/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj +++ b/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj @@ -54,14 +54,17 @@ ZipMacFiles would wrap a ZIP named .app again, hiding its executable from the signing service. Preserve the bundle directory in the ZIP. https://github.com/dotnet/arcade/blob/main/src/Microsoft.DotNet.SignTool/src/SignTool.cs --> - + - + + diff --git a/src/Aspire.Tray/Mac/publish.sh b/src/Aspire.Tray/Mac/publish.sh index 2a17b9a6a5c..f2a71bc9266 100644 --- a/src/Aspire.Tray/Mac/publish.sh +++ b/src/Aspire.Tray/Mac/publish.sh @@ -9,7 +9,7 @@ case "${1:-$(uname -m)}" in esac cd "$root" -./dotnet.sh msbuild eng/Bundle.proj -t:_PublishNativeTray \ +./dotnet.sh msbuild eng/Bundle.proj -t:PublishTray \ -p:Configuration=Release -p:TargetRid="$rid" --nologo app="$root/artifacts/bin/Aspire.Tray.Mac/Release/net10.0/$rid/app/Aspire Tray.app" diff --git a/src/Aspire.Tray/README.md b/src/Aspire.Tray/README.md index 9b3901ede74..0f9d660abb9 100644 --- a/src/Aspire.Tray/README.md +++ b/src/Aspire.Tray/README.md @@ -361,6 +361,16 @@ template image and the dot is a small view over it, colored with the system gree orange; the dimmed state is AppKit's own disabled status-item rendering. The tooltip and accessibility label state the status in words, so the dot's color is never the only cue. +## Publish the standalone tray + +The public `PublishTray` target in `eng/Bundle.proj` publishes only the tray, +without assembling a CLI bundle. The macOS `publish.sh` helper below uses this +target; it can also be called directly: + +```sh +dotnet msbuild eng/Bundle.proj -t:PublishTray -p:TargetRid=osx-arm64 -p:Configuration=Release +``` + ## Build and run on macOS Building requires a compatible .NET SDK and Xcode Command Line Tools. From the @@ -376,19 +386,13 @@ Publish for the current machine, or pass `osx-arm64` or `osx-x64` explicitly: bash src/Aspire.Tray/Mac/publish.sh ``` -This uses the same publish/package target as the CLI bundle. To build a complete -Apple Silicon CLI into an isolated output directory: - -```sh -./dotnet.sh msbuild eng/Bundle.proj \ - -p:Configuration=Release -p:TargetRid=osx-arm64 \ - -p:CliPublishDir="$PWD/artifacts/tray-cli-validation" -``` +The helper publishes the tray without rebuilding unrelated bundle components. +A complete CLI bundle embeds the prepared app alongside the other components. +The app is verified from the actual payload archive so a valid source app alone +is not mistaken for a correctly packaged app. -The resulting `artifacts/tray-cli-validation/aspire` embeds the app together with -the existing managed and DCP payloads. `SkipNativeBuild=true` skips only the -outer CLI build, not the NativeAOT tray. The app is verified from the actual -payload archive before embedding. +See [the bundle build overview](../../docs/specs/bundle.md#build-process) for +bundle configuration and component-reuse options. Quit the running tray before replacing its `.app` or republishing the CLI executable it uses. A running NativeAOT executable must not be overwritten. diff --git a/tests/Infrastructure.Tests/CreateLayout/CreateLayoutTests.cs b/tests/Infrastructure.Tests/CreateLayout/CreateLayoutTests.cs index c6a9d12e3a2..a24c87e0084 100644 --- a/tests/Infrastructure.Tests/CreateLayout/CreateLayoutTests.cs +++ b/tests/Infrastructure.Tests/CreateLayout/CreateLayoutTests.cs @@ -8,6 +8,110 @@ namespace Infrastructure.Tests.CreateLayout; public class CreateLayoutTests(ITestOutputHelper testOutputHelper) { + [Fact] + public void GetComponentTargetFramework_MissingMetadataIdentifiesProject() + { + var exception = Assert.Throws(() => + LayoutBuilder.GetComponentTargetFramework("Missing.Project")); + + Assert.Equal("Missing target framework metadata for Missing.Project.", exception.Message); + } + + [Theory] + [InlineData("Aspire.Managed", "managed", "aspire-managed")] + [InlineData("Aspire.Dashboard", "dashboard", "Aspire.Dashboard")] + [InlineData("Aspire.TerminalHost", "terminalhost", "Aspire.TerminalHost")] + [InlineData("Aspire.Hosting.Native.Server", "apphost-server", "aspire-apphost-server")] + public void CopyComponent_ExplicitDirectoryNeverFallsBack(string project, string destination, string executable) + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + var stale = Path.Combine(workspace.Path, "bin", project, "Debug", "net11.0", "linux-x64", "publish"); + CreateComponentPublishOutput(stale, project, "stale"); + var discovered = Path.Combine(workspace.Path, "bin", project, "Debug", + LayoutBuilder.GetComponentTargetFramework(project), "linux-x64", "publish"); + CreateComponentPublishOutput(discovered, project, "discovered"); + var selected = Path.Combine(workspace.Path, "selected payload"); + CreateComponentPublishOutput(selected, project, "selected"); + var output = Path.Combine(workspace.Path, "layout"); + using var builder = new LayoutBuilder(output, workspace.Path, "linux-x64", "Debug", "1.0", false, + trayDirectory: null, + dashboardPath: project == "Aspire.Dashboard" ? selected : null, + managedPath: project == "Aspire.Managed" ? selected : null, + terminalHostPath: project == "Aspire.TerminalHost" ? selected : null, + appHostServerPath: project == "Aspire.Hosting.Native.Server" ? selected : null); + Action copy = project switch + { + "Aspire.Managed" => builder.CopyManaged, + "Aspire.Dashboard" => builder.CopyDashboard, + "Aspire.TerminalHost" => builder.CopyTerminalHost, + _ => builder.CopyAppHostServer + }; + + copy(); + + Assert.Equal("selected", File.ReadAllText(Path.Combine(output, destination, executable))); + var sourceExecutable = project == "Aspire.Managed" ? "aspire-managed" : project; + File.Delete(Path.Combine(selected, sourceExecutable)); + + var missingPayload = Assert.Throws(copy); + Assert.Contains(Path.Combine(selected, sourceExecutable), missingPayload.Message, StringComparison.Ordinal); + + Directory.Delete(selected, recursive: true); + + var missingDirectory = Assert.Throws(copy); + Assert.Contains($"publish directory not found at {selected}", missingDirectory.Message, StringComparison.Ordinal); + Assert.True(File.Exists(Path.Combine(discovered, sourceExecutable))); + Assert.True(File.Exists(Path.Combine(stale, sourceExecutable))); + } + + [Theory] + [InlineData("Aspire.Managed", "--managed", "")] + [InlineData("Aspire.Managed", "--managed", " ")] + [InlineData("Aspire.TerminalHost", "--terminal-host", "")] + [InlineData("Aspire.TerminalHost", "--terminal-host", " ")] + [InlineData("Aspire.Hosting.Native.Server", "--apphost-server", "")] + [InlineData("Aspire.Hosting.Native.Server", "--apphost-server", " ")] + public void CopyComponent_EmptyExplicitDirectoryIsRejected(string project, string option, string selected) + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + var discovered = Path.Combine(workspace.Path, "bin", project, "Debug", + LayoutBuilder.GetComponentTargetFramework(project), "linux-x64", "publish"); + CreateComponentPublishOutput(discovered, project, "discovered"); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "linux-x64", "Debug", "1.0", false, + trayDirectory: null, dashboardPath: null, + managedPath: project == "Aspire.Managed" ? selected : null, + terminalHostPath: project == "Aspire.TerminalHost" ? selected : null, + appHostServerPath: project == "Aspire.Hosting.Native.Server" ? selected : null); + Action copy = project switch + { + "Aspire.Managed" => builder.CopyManaged, + "Aspire.TerminalHost" => builder.CopyTerminalHost, + _ => builder.CopyAppHostServer + }; + + var exception = Assert.Throws(copy); + + Assert.Equal($"{option} requires a nonempty publish directory.", exception.Message); + } + + [Theory] + [InlineData("publish")] + [InlineData("linux-x64/publish")] + public void CopyManaged_DiscoveryUsesDefaultTargetFramework(string directory) + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + var source = Path.Combine(workspace.Path, "bin", "Aspire.Managed", "Debug", + LayoutBuilder.GetComponentTargetFramework("Aspire.Managed"), directory); + CreateComponentPublishOutput(source, "Aspire.Managed", "managed"); + var output = Path.Combine(workspace.Path, "layout"); + using var builder = new LayoutBuilder(output, workspace.Path, "linux-x64", "Debug", "1.0", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + builder.CopyManaged(); + + Assert.Equal("managed", File.ReadAllText(Path.Combine(output, "managed", "aspire-managed"))); + } + [Theory] [InlineData("win-x64", ".exe")] [InlineData("linux-x64", "")] @@ -15,7 +119,8 @@ public class CreateLayoutTests(ITestOutputHelper testOutputHelper) public void CopyAppHostServer_PreservesPayloadAndProductNameWithoutSymbols(string rid, string extension) { using var workspace = TemporaryWorkspace.Create(testOutputHelper); - var source = Path.Combine(workspace.Path, "bin", "Aspire.Hosting.Native.Server", "Debug", "net11.0", rid, "publish"); + var source = Path.Combine(workspace.Path, "bin", "Aspire.Hosting.Native.Server", "Debug", + LayoutBuilder.GetComponentTargetFramework("Aspire.Hosting.Native.Server"), rid, "publish"); var symbolDirectory = Path.Combine(source, "Aspire.Hosting.Native.Server.dSYM"); Directory.CreateDirectory(symbolDirectory); File.WriteAllText(Path.Combine(source, "Aspire.Hosting.Native.Server" + extension), "server"); @@ -25,7 +130,7 @@ public void CopyAppHostServer_PreservesPayloadAndProductNameWithoutSymbols(strin File.WriteAllText(Path.Combine(symbolDirectory, "symbols"), "symbols"); var output = Path.Combine(workspace.Path, "layout"); using var builder = new LayoutBuilder(output, workspace.Path, rid, "Debug", "1.0.0", verbose: false, - trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyAppHostServer(); @@ -45,7 +150,8 @@ public void CopyAppHostServer_PreservesPayloadAndProductNameWithoutSymbols(strin public void CopyAppHostServer_RejectsMissingOrEmptyContract(string directory, string? contract) { using var workspace = TemporaryWorkspace.Create(testOutputHelper); - var source = Path.Combine(workspace.Path, "bin", "Aspire.Hosting.Native.Server", "Debug", "net11.0", "linux-x64", directory); + var source = Path.Combine(workspace.Path, "bin", "Aspire.Hosting.Native.Server", "Debug", + LayoutBuilder.GetComponentTargetFramework("Aspire.Hosting.Native.Server"), "linux-x64", directory); Directory.CreateDirectory(source); File.WriteAllText(Path.Combine(source, "Aspire.Hosting.Native.Server"), "server"); if (contract is not null) @@ -53,7 +159,8 @@ public void CopyAppHostServer_RejectsMissingOrEmptyContract(string directory, st File.WriteAllText(Path.Combine(source, "ats-contract.json"), contract); } var output = Path.Combine(workspace.Path, "layout"); - using var builder = new LayoutBuilder(output, workspace.Path, "linux-x64", "Debug", "1.0.0", false, null, null, null); + using var builder = new LayoutBuilder(output, workspace.Path, "linux-x64", "Debug", "1.0.0", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var failure = Assert.Throws(builder.CopyAppHostServer); @@ -72,7 +179,8 @@ public void CopyAppHostServer_RejectsMissingOrEmptyContract(string directory, st public void CopyTerminalHostRequiresNativeDependenciesAndExcludesSymbols(string rid) { using var workspace = TemporaryWorkspace.Create(testOutputHelper); - var publish = Path.Combine(workspace.Path, "bin", "Aspire.TerminalHost", "Debug", "net11.0", rid, "publish"); + var publish = Path.Combine(workspace.Path, "bin", "Aspire.TerminalHost", "Debug", + LayoutBuilder.GetComponentTargetFramework("Aspire.TerminalHost"), rid, "publish"); var files = Aspire.Shared.TerminalHostPayload.GetRequiredFiles(rid); foreach (var file in files) { @@ -81,7 +189,8 @@ public void CopyTerminalHostRequiresNativeDependenciesAndExcludesSymbols(string File.WriteAllText(path, file); } File.WriteAllText(Path.Combine(publish, "Aspire.TerminalHost.pdb"), "symbols"); - using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, rid, "Debug", "1.0", false, null, null, null); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, rid, "Debug", "1.0", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTerminalHost(); var target = Path.Combine(workspace.Path, "layout", "terminalhost"); Assert.Equal(files.Order(StringComparer.Ordinal), Directory.GetFiles(target, "*", SearchOption.AllDirectories) @@ -122,7 +231,8 @@ public void TerminalHostPayloadValidationUsesCurrentRidAndRequiresNonEmptyFiles( public void FindPublishPath_UsesOnlyRequestedConfiguration(string configuration, string otherConfiguration) { using var workspace = TemporaryWorkspace.Create(testOutputHelper); - using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "win-x64", configuration, "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "win-x64", configuration, "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var expectedPaths = GetPublishPaths(workspace.Path, configuration); foreach (var path in expectedPaths.Concat(GetPublishPaths(workspace.Path, otherConfiguration))) @@ -132,23 +242,24 @@ public void FindPublishPath_UsesOnlyRequestedConfiguration(string configuration, foreach (var expectedPath in expectedPaths) { - Assert.Equal(expectedPath, builder.FindPublishPath("Aspire.Dashboard", "net11.0")); + Assert.Equal(expectedPath, builder.FindPublishPath("Aspire.Dashboard", LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"))); Directory.Delete(expectedPath); } - Assert.Null(builder.FindPublishPath("Aspire.Dashboard", "net11.0")); + Assert.Null(builder.FindPublishPath("Aspire.Dashboard", LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"))); } [Fact] public void FindPublishPath_RequireRidSpecific_IgnoresNonRidPublish() { using var workspace = TemporaryWorkspace.Create(testOutputHelper); - using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var nonRidPath = GetPublishPaths(workspace.Path, "Debug")[^1]; Directory.CreateDirectory(nonRidPath); - Assert.Null(builder.FindPublishPath("Aspire.Dashboard", "net11.0", requireRidSpecific: true)); - Assert.Equal(nonRidPath, builder.FindPublishPath("Aspire.Dashboard", "net11.0")); + Assert.Null(builder.FindPublishPath("Aspire.Dashboard", LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), requireRidSpecific: true)); + Assert.Equal(nonRidPath, builder.FindPublishPath("Aspire.Dashboard", LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"))); } [Fact] @@ -168,6 +279,24 @@ public async Task Main_RequiresConfiguration() Assert.False(Directory.Exists(outputPath)); } + [Fact] + public void CopyDashboard_MissingExplicitDirectoryDoesNotFallBackToDiscoverablePayload() + { + const string rid = "linux-x64"; + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + var discoveredPath = CreateDashboardPublishOutput(workspace.Path, rid, "libe_sqlite3.so"); + var explicitPath = Path.Combine(workspace.Path, "missing prepared Dashboard"); + var outputPath = Path.Combine(workspace.Path, "layout"); + using var builder = new LayoutBuilder(outputPath, workspace.Path, rid, "Debug", "1.0.0", + verbose: false, trayDirectory: null, dashboardPath: explicitPath, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + var exception = Assert.Throws(builder.CopyDashboard); + + Assert.Equal($"Dashboard publish directory not found at {explicitPath}", exception.Message); + Assert.Equal(discoveredPath, builder.FindPublishPath("Aspire.Dashboard", LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), requireRidSpecific: true)); + Assert.False(Directory.Exists(Path.Combine(outputPath, "dashboard"))); + } + [Theory] [InlineData("win-x64", "e_sqlite3.dll")] [InlineData("win-arm64", "e_sqlite3.dll")] @@ -207,7 +336,8 @@ public void CopyDashboard_CopiesCompletePublishPayloadWithoutSymbols(string rid, } var outputPath = Path.Combine(workspace.Path, "layout"); - using var builder = new LayoutBuilder(outputPath, workspace.Path, rid, "Debug", "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(outputPath, workspace.Path, rid, "Debug", "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyDashboard(); @@ -229,7 +359,8 @@ public void CopyDashboard_MissingStaticAssets_Throws() var wwwrootPath = Path.Combine(publishPath, "wwwroot"); Directory.Delete(wwwrootPath, recursive: true); var outputPath = Path.Combine(workspace.Path, "layout"); - using var builder = new LayoutBuilder(outputPath, workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(outputPath, workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var exception = Assert.Throws(builder.CopyDashboard); @@ -255,7 +386,8 @@ public void CopyDashboard_MissingOrEmptyBlazorScript_Throws(bool empty) } var outputPath = Path.Combine(workspace.Path, "layout"); - using var builder = new LayoutBuilder(outputPath, workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(outputPath, workspace.Path, "win-x64", "Debug", "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var exception = Assert.Throws(builder.CopyDashboard); @@ -285,7 +417,8 @@ public void CopyDashboard_MissingOrEmptySqliteLibrary_Throws(string rid, string } var outputPath = Path.Combine(workspace.Path, "layout"); - using var builder = new LayoutBuilder(outputPath, workspace.Path, rid, "Debug", "1.0.0", verbose: false, trayAppPath: null, windowsTrayPath: null, linuxTrayPath: null); + using var builder = new LayoutBuilder(outputPath, workspace.Path, rid, "Debug", "1.0.0", verbose: false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var exception = Assert.Throws(builder.CopyDashboard); @@ -293,9 +426,88 @@ public void CopyDashboard_MissingOrEmptySqliteLibrary_Throws(string rid, string Assert.False(Directory.Exists(Path.Combine(outputPath, "dashboard"))); } + [Fact] + public void CopyDashboard_ExplicitDirectoryPreservesPayloadFiltering() + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + var publish = CreateDashboardPublishOutput(workspace.Path, "win-x64", "e_sqlite3.dll"); + var explicitPath = Path.Combine(workspace.Path, "prepared dashboard outside artifacts"); + Directory.Move(publish, explicitPath); + File.WriteAllText(Path.Combine(explicitPath, "Aspire.Dashboard.exe"), "explicit executable"); + File.WriteAllText(Path.Combine(explicitPath, "Aspire.Dashboard.pdb"), "symbols"); + Directory.CreateDirectory(Path.Combine(explicitPath, "nested.dSYM")); + File.WriteAllText(Path.Combine(explicitPath, "nested.dSYM", "symbols"), "symbols"); + File.WriteAllText(Path.Combine(explicitPath, "Aspire.Dashboard.dbg"), "symbols"); + var output = Path.Combine(workspace.Path, "layout"); + using var builder = new LayoutBuilder(output, workspace.Path, "win-x64", "Debug", "1.0", false, + trayDirectory: null, dashboardPath: explicitPath, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + builder.CopyDashboard(); + + var dashboard = Path.Combine(output, "dashboard"); + Assert.Equal(["Aspire.Dashboard.exe", "e_sqlite3.dll", "wwwroot/_framework/blazor.web.js"], + Directory.GetFiles(dashboard, "*", SearchOption.AllDirectories) + .Select(path => Path.GetRelativePath(dashboard, path).Replace('\\', '/')).Order(StringComparer.Ordinal)); + Assert.Equal("explicit executable", File.ReadAllText(Path.Combine(dashboard, "Aspire.Dashboard.exe"))); + } + + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData("\t")] + public void CopyDashboard_EmptyExplicitDirectoryIsRejected(string path) + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + CreateDashboardPublishOutput(workspace.Path, "win-x64", "e_sqlite3.dll"); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, + "win-x64", "Debug", "1.0", false, + trayDirectory: null, dashboardPath: path, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + var exception = Assert.Throws(builder.CopyDashboard); + + Assert.Equal("--dashboard requires a nonempty publish directory.", exception.Message); + } + + [Fact] + public void CopyDashboard_DiscoveryFailureIdentifiesSearchLocations() + { + using var workspace = TemporaryWorkspace.Create(testOutputHelper); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, + "win-x64", "Debug", "1.0", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + var exception = Assert.Throws(builder.CopyDashboard); + + Assert.Contains("win-x64", exception.Message); + Assert.Contains("Debug", exception.Message); + foreach (var path in GetPublishPaths(workspace.Path, "Debug")[..^1]) + { + Assert.Contains(path, exception.Message); + } + } + + private static void CreateComponentPublishOutput(string path, string project, string content) + { + string[] files = project switch + { + "Aspire.Managed" => ["aspire-managed"], + "Aspire.Dashboard" => ["Aspire.Dashboard", "libe_sqlite3.so", "wwwroot/_framework/blazor.web.js"], + "Aspire.TerminalHost" => Aspire.Shared.TerminalHostPayload.GetRequiredFiles("linux-x64"), + "Aspire.Hosting.Native.Server" => ["Aspire.Hosting.Native.Server", "ats-contract.json"], + _ => throw new ArgumentOutOfRangeException(nameof(project)) + }; + foreach (var file in files) + { + var filePath = Path.Combine(path, file); + Directory.CreateDirectory(Path.GetDirectoryName(filePath)!); + File.WriteAllText(filePath, content); + } + } + private static string CreateDashboardPublishOutput(string artifactsPath, string rid, string sqliteLibraryName) { - var publishPath = Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", rid, "Debug", "net11.0", rid, "publish"); + var publishPath = Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", rid, "Debug", + LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), rid, "publish"); var frameworkPath = Path.Combine(publishPath, "wwwroot", "_framework"); Directory.CreateDirectory(frameworkPath); var executableName = rid.StartsWith("win-", StringComparison.Ordinal) ? "Aspire.Dashboard.exe" : "Aspire.Dashboard"; @@ -308,9 +520,9 @@ private static string CreateDashboardPublishOutput(string artifactsPath, string private static string[] GetPublishPaths(string artifactsPath, string configuration) => [ - Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", "win-x64", configuration, "net11.0", "win-x64", "publish"), - Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, "net11.0", "win-x64", "publish"), - Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, "net11.0", "win-x64", "native"), - Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, "net11.0", "publish") + Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", "win-x64", configuration, LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), "win-x64", "publish"), + Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), "win-x64", "publish"), + Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), "win-x64", "native"), + Path.Combine(artifactsPath, "bin", "Aspire.Dashboard", configuration, LayoutBuilder.GetComponentTargetFramework("Aspire.Dashboard"), "publish") ]; } \ No newline at end of file diff --git a/tests/Infrastructure.Tests/Hex1bNativePublishingTests.cs b/tests/Infrastructure.Tests/Hex1bNativePublishingTests.cs index 983f8c4d07d..5c93ef0dcd6 100644 --- a/tests/Infrastructure.Tests/Hex1bNativePublishingTests.cs +++ b/tests/Infrastructure.Tests/Hex1bNativePublishingTests.cs @@ -96,7 +96,7 @@ public async Task CiBundlesRequireRelease(string configuration, bool ci, bool su var result = await RunDotNetAsync( ["msbuild", Path.Combine(RepoRoot.Path, "eng", "Bundle.proj"), "-nologo", "-t:_ShowBanner", $"-p:Configuration={configuration}", $"-p:ContinuousIntegrationBuild={ci}", - $"-p:ArtifactsLogDir={Path.Combine(_workspace.Path, "logs")}"]); + $"-p:_ArtifactsLogDir={Path.Combine(_workspace.Path, "logs")}"]); Assert.Equal(succeeds, result.ExitCode == 0); if (!succeeds) @@ -275,23 +275,23 @@ public async Task BundlePreservesPtyLayoutAndRejectsMissingSidecars(string rid, "--depsfile", Path.ChangeExtension(testAssembly, ".deps.json"), typeof(Aspire.Tools.CreateLayout.Program).Assembly.Location, "--output", layout, "--artifacts", artifacts, "--rid", rid, "--configuration", "Release"]; - // Layout assembly now requires the native tray payload for desktop RIDs, even + // Layout assembly requires the native tray payload for desktop RIDs, even // when the scenario focuses on the managed bundle's PTY sidecars. if (rid.StartsWith("win-", StringComparison.Ordinal)) { var tray = Path.Combine(_workspace.Path, "windows-tray"); WindowsTrayTestPayload.Create(tray, rid); - arguments.AddRange(["--tray-windows", tray]); + arguments.AddRange(["--tray-dir", tray]); } else if (rid.StartsWith("osx-", StringComparison.Ordinal)) { - arguments.AddRange(["--tray-app", MacTrayTestPayload.Create(_workspace.Path)]); + arguments.AddRange(["--tray-dir", MacTrayTestPayload.Create(_workspace.Path)]); } else if (rid is "linux-x64" or "linux-arm64") { var tray = Path.Combine(_workspace.Path, "linux-tray"); LinuxTrayTestPayload.Create(tray, rid); - arguments.AddRange(["--tray-linux", tray]); + arguments.AddRange(["--tray-dir", tray]); } var result = await RunDotNetAsync( diff --git a/tests/Infrastructure.Tests/Pipelines/BundleBuildWrapperTests.cs b/tests/Infrastructure.Tests/Pipelines/BundleBuildWrapperTests.cs new file mode 100644 index 00000000000..a970db54712 --- /dev/null +++ b/tests/Infrastructure.Tests/Pipelines/BundleBuildWrapperTests.cs @@ -0,0 +1,153 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; +using Aspire.TestUtilities; +using Xunit; + +namespace Infrastructure.Tests; + +public sealed class BundleBuildWrapperTests(ITestOutputHelper output) +{ + [Theory] + [InlineData("bash", "/p:", "true")] + [InlineData("bash", "-p:", "true")] + [InlineData("bash", "/p:", "false")] + [InlineData("pwsh", "/p:", "true")] + [InlineData("pwsh", "-p:", "true")] + [InlineData("pwsh", "/p:", "false")] + [RequiresTools(["pwsh", "bash"])] + public async Task BundleWrappersTranslateLegacyNativeSkip(string shell, string prefix, string value) + { + using var workspace = TemporaryWorkspace.Create(output); + string[] arguments = [prefix + "SkipNativeBuild=" + value]; + + await ExecuteAsync(workspace, shell, arguments); + + Assert.Equal(value == "true" ? ["ARG|/p:SkipCliArtifacts=true"] : [], + PropertyArguments(workspace, "bundle")); + Assert.Equal(arguments.Select(argument => "ARG|" + argument), PropertyArguments(workspace, "repository")); + } + + [Theory] + [InlineData("bash")] + [InlineData("pwsh")] + [RequiresTools(["pwsh", "bash"])] + public async Task BundleWrappersLeaveAdvancedControlsToDirectMsbuild(string shell) + { + using var workspace = TemporaryWorkspace.Create(output); + string[] arguments = ["/p:SkipDashboardPublish=true", "/p:SkipCliArtifacts=true"]; + + await ExecuteAsync(workspace, shell, arguments); + + Assert.Empty(PropertyArguments(workspace, "bundle")); + Assert.Equal(arguments.Select(argument => "ARG|" + argument), PropertyArguments(workspace, "repository")); + } + + [Fact] + [RequiresTools(["bash"])] + public async Task StabilizationSmokeSkipsCliArtifactsWhenBuildingItsPayload() + { + Assert.SkipWhen(OperatingSystem.IsWindows(), "The stabilization smoke requires a Unix host."); + using var workspace = TemporaryWorkspace.Create(output); + var root = workspace.CreateDirectory("repository with spaces").FullName; + var scripts = Directory.CreateDirectory(Path.Combine(root, "eng", "scripts")).FullName; + var script = Path.Combine(scripts, "stabilization-smoke-init-restore.sh"); + File.Copy(Path.Combine(RepoRoot.Path, "eng", "scripts", "stabilization-smoke-init-restore.sh"), script); + var feed = workspace.CreateDirectory("stable feed").FullName; + foreach (var package in new[] { "Aspire.Hosting", "Aspire.ProjectTemplates", "Aspire.AppHost.Sdk" }) + { + await File.WriteAllTextAsync(Path.Combine(feed, $"{package}.17.0.0.nupkg"), ""); + } + + var dotnet = Path.Combine(root, "dotnet.sh"); + // Stop at the separate driver publish: this exercises the complete smoke + // entry point's bundle invocation without rebuilding product binaries. + await File.WriteAllTextAsync(dotnet, """ + #!/usr/bin/env bash + case "$1" in + --info) printf ' RID: linux-x64\n' ;; + build) for arg in "$@"; do printf 'ARG|%s\n' "$arg"; done > "$TEST_ROOT/bundle" ;; + publish) exit 73 ;; + *) exit 74 ;; + esac + """); + if (!OperatingSystem.IsWindows()) + { + File.SetUnixFileMode(dotnet, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); + } + + var result = await TestProcessRunner.RunAsync( + output, "bash", [script], root, + new Dictionary + { + ["TEST_ROOT"] = workspace.Path, + ["STABILIZATION_SMOKE_FEED"] = feed + }); + + Assert.Equal(73, result.ExitCode); + Assert.Equal(["ARG|-p:SkipCliArtifacts=true"], PropertyArguments(workspace, "bundle")); + } + + private async Task ExecuteAsync(TemporaryWorkspace workspace, string shell, string[] arguments) + { + Assert.SkipWhen(shell == "bash" && OperatingSystem.IsWindows(), "The Bash wrapper requires a Unix host."); + var root = workspace.CreateDirectory("repository with spaces").FullName; + var common = Directory.CreateDirectory(Path.Combine(root, "eng", "common")).FullName; + var sdk = Directory.CreateDirectory(Path.Combine(root, ".dotnet")).FullName; + // Run complete production entry points; replace only the external build + // driver and dotnet command with argument recorders. + foreach (var name in new[] { "build.sh", "build.ps1" }) + { + File.Copy(Path.Combine(RepoRoot.Path, "eng", name), Path.Combine(root, "eng", name)); + } + await File.WriteAllTextAsync(Path.Combine(common, "build.sh"), """ + #!/usr/bin/env bash + for arg in "$@"; do printf 'ARG|%s\n' "$arg"; done > "$TEST_ROOT/repository" + """); + await File.WriteAllTextAsync(Path.Combine(common, "build.ps1"), """ + [IO.File]::WriteAllLines("$env:TEST_ROOT/repository", @($args | ForEach-Object { "ARG|$_" })) + $global:LASTEXITCODE = 0 + """); + await File.WriteAllTextAsync(Path.Combine(sdk, "dotnet"), """ + #!/usr/bin/env bash + for arg in "$@"; do printf 'ARG|%s\n' "$arg"; done > "$TEST_ROOT/bundle" + """); + if (!OperatingSystem.IsWindows()) + { + foreach (var path in new[] { Path.Combine(common, "build.sh"), Path.Combine(sdk, "dotnet") }) + { + File.SetUnixFileMode(path, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); + } + } + var launcher = Path.Combine(root, "launch.ps1"); + await File.WriteAllTextAsync(Path.Combine(root, "arguments.json"), JsonSerializer.Serialize(arguments)); + await File.WriteAllTextAsync(launcher, """ + $ErrorActionPreference = 'Stop' + $buildArguments = @(Get-Content "$PSScriptRoot/arguments.json" -Raw | ConvertFrom-Json) + function global:dotnet { + [IO.File]::WriteAllLines("$env:TEST_ROOT/bundle", @($args | ForEach-Object { "ARG|$_" })) + $global:LASTEXITCODE = 0 + } + if ($env:TEST_SHELL -eq 'bash') { + & bash "$PSScriptRoot/eng/build.sh" --bundle --warnAsError false @buildArguments + } else { + & "$PSScriptRoot/eng/build.ps1" -bundle -warnAsError false @buildArguments + } + exit $LASTEXITCODE + """); + using var command = new PowerShellCommand(launcher, output) + .WithWorkingDirectory(root) + .WithTimeout(TimeSpan.FromMinutes(1)) + .WithEnvironmentVariable("TEST_ROOT", workspace.Path) + .WithEnvironmentVariable("TEST_SHELL", shell) + .WithEnvironmentVariable("CI", "false"); + var result = await command.ExecuteAsync(); + result.EnsureSuccessful(); + } + + private static IEnumerable PropertyArguments(TemporaryWorkspace workspace, string name) => + File.ReadAllLines(Path.Combine(workspace.Path, name)) + .Where(line => line.StartsWith("ARG|/p:Skip", StringComparison.OrdinalIgnoreCase) || + line.StartsWith("ARG|-p:Skip", StringComparison.OrdinalIgnoreCase)); +} diff --git a/tests/Infrastructure.Tests/Pipelines/TrayBundleTests.cs b/tests/Infrastructure.Tests/Pipelines/TrayBundleTests.cs index 3ad13b0208c..d7efe5ab2d7 100644 --- a/tests/Infrastructure.Tests/Pipelines/TrayBundleTests.cs +++ b/tests/Infrastructure.Tests/Pipelines/TrayBundleTests.cs @@ -13,14 +13,40 @@ namespace Infrastructure.Tests; public sealed class TrayBundleTests(ITestOutputHelper output) { + [Theory] + [InlineData("win-x64", "")] + [InlineData("win-x64", " ")] + [InlineData("win-arm64", "")] + [InlineData("win-arm64", " ")] + [InlineData("osx-x64", "")] + [InlineData("osx-x64", " ")] + [InlineData("osx-arm64", "")] + [InlineData("osx-arm64", " ")] + [InlineData("linux-x64", "")] + [InlineData("linux-x64", " ")] + [InlineData("linux-arm64", "")] + [InlineData("linux-arm64", " ")] + public void DesktopLayoutsRejectEmptyTrayDirectory(string rid, string directory) + { + using var workspace = TemporaryWorkspace.Create(output); + using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, + trayDirectory: directory, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); + + var error = Assert.Throws(builder.CopyTray); + + Assert.Equal($"The {rid} bundle requires --tray-dir pointing to the prepared native tray directory (.app directory on macOS).", error.Message); + Assert.Empty(Directory.EnumerateFileSystemEntries(workspace.Path)); + } + [Theory] [InlineData("linux-x64")] [InlineData("linux-arm64")] public void LinuxLayoutsRequireExplicitNativePayload(string rid) { using var workspace = TemporaryWorkspace.Create(output); - using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, null, null, null); - Assert.Equal("The Linux bundle requires --tray-linux pointing to the pre-built native tray publish directory.", + using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); + Assert.Equal($"The {rid} bundle requires --tray-dir pointing to the prepared native tray directory (.app directory on macOS).", Assert.Throws(builder.CopyTray).Message); } @@ -36,7 +62,8 @@ public async Task LinuxPayloadCopyAndArchivePreserveOnlyNativeRuntimeFiles(strin LinuxTrayTestPayload.Create(source, rid); File.WriteAllText(Path.Combine(source, "aspire-tray.dbg"), "symbols"); var layout = Path.Combine(workspace.Path, rid); - using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, null, null, source); + using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); var archivePath = await builder.CreateArchiveAsync(); await using var archive = File.OpenRead(archivePath); @@ -64,7 +91,8 @@ public async Task LinuxPayloadCopyAndArchivePreserveOnlyNativeRuntimeFiles(strin public void MuslLayoutsDoNotPackageTray(string rid) { using var workspace = TemporaryWorkspace.Create(output); - using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, "missing.app", "missing-windows", "missing-linux"); + using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, + trayDirectory: "missing-tray", dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); @@ -77,11 +105,12 @@ public void MuslLayoutsDoNotPackageTray(string rid) public void MacLayoutRequiresExplicitTrayInput(string rid) { using var workspace = TemporaryWorkspace.Create(output); - using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, null, null, null); + using var builder = new LayoutBuilder(workspace.Path, workspace.Path, rid, "Debug", "test", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var error = Assert.Throws(builder.CopyTray); - Assert.Contains("--tray-app", error.Message); + Assert.Equal($"The {rid} bundle requires --tray-dir pointing to the prepared native tray directory (.app directory on macOS).", error.Message); } [Theory] @@ -94,7 +123,8 @@ public void MacLayoutRejectsIncompleteTray(string missingFile) using var workspace = TemporaryWorkspace.Create(output); var source = MacTrayTestPayload.Create(workspace.Path); File.Delete(Path.Combine(source, missingFile)); - using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "osx-arm64", "Debug", "test", false, source, null, null); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "osx-arm64", "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var error = Assert.Throws(builder.CopyTray); @@ -109,7 +139,8 @@ public void MacLayoutRejectsNonExecutableTray() using var workspace = TemporaryWorkspace.Create(output); var source = MacTrayTestPayload.Create(workspace.Path); File.SetUnixFileMode(Path.Combine(source, "Contents/MacOS/aspire-tray"), UnixFileMode.UserRead); - using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "osx-arm64", "Debug", "test", false, source, null, null); + using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, "osx-arm64", "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var error = Assert.Throws(builder.CopyTray); @@ -125,7 +156,8 @@ public async Task AppResourcesSignaturesAndExecutableModesSurviveCopyAndArchive( var source = MacTrayTestPayload.Create(workspace.Path); var layout = Path.Combine(workspace.Path, "osx-arm64"); var destination = Path.Combine(layout, "tray", "Aspire Tray.app"); - using var builder = new LayoutBuilder(layout, workspace.Path, "osx-arm64", "Debug", "test", false, source, null, null); + using var builder = new LayoutBuilder(layout, workspace.Path, "osx-arm64", "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); @@ -176,7 +208,7 @@ public async Task MacSigningTransportContainsAppDirectoryAndPreservesExecutableM File.WriteAllText(scriptPath, """ param([string]$RepositoryRoot, [string]$AppPath, [string]$ArchivePath) & "$RepositoryRoot/dotnet.sh" msbuild "$RepositoryRoot/src/Aspire.Tray/Mac/Aspire.Tray.Mac.csproj" ` - /t:PrepareTraySigning /p:RuntimeIdentifier=osx-arm64 ` + /t:CreateTrayAppSigningArchive /p:RuntimeIdentifier=osx-arm64 ` "/p:TrayAppPath=$AppPath" "/p:TraySigningArchive=$ArchivePath" /nologo exit $LASTEXITCODE """); @@ -241,7 +273,8 @@ public async Task WindowsLayoutCopiesOnlyNativePayloadAndPreservesArchiveBytes(s WindowsTrayTestPayload.Create(source, rid); File.WriteAllText(Path.Combine(source, "smoke.stdout.log"), "not runtime content"); var layout = Path.Combine(workspace.Path, rid); - using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, null, source, null); + using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); @@ -289,12 +322,12 @@ public void WindowsLayoutRejectsInvalidPublishOutput(string scenario) File.Copy(typeof(TrayBundleTests).Assembly.Location, Path.Combine(source, "aspire-tray.exe"), overwrite: true); } using var builder = new LayoutBuilder(Path.Combine(workspace.Path, "layout"), workspace.Path, - scenario == "unsupported-rid" ? "win-x86" : "win-x64", "Debug", "test", false, null, - scenario == "missing-input" ? null : source, null); + scenario == "unsupported-rid" ? "win-x86" : "win-x64", "Debug", "test", false, + trayDirectory: scenario == "missing-input" ? null : source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); if (scenario == "missing-input") { - Assert.Equal("The Windows bundle requires --tray-windows pointing to the pre-built native tray publish directory.", + Assert.Equal("The win-x64 bundle requires --tray-dir pointing to the prepared native tray directory (.app directory on macOS).", Assert.Throws(builder.CopyTray).Message); } else @@ -319,7 +352,8 @@ public async Task WindowsArchiveVerifierChecksActualPayload(string rid, string s WindowsTrayTestPayload.Create(source, rid); File.Copy(Path.Combine(RepoRoot.Path, "src/Shared/Aspire.ico"), Path.Combine(source, "Aspire.ico"), overwrite: true); var layout = Path.Combine(workspace.Path, rid); - using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, null, source, null); + using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); var tray = Path.Combine(layout, "tray"); switch (scenario) @@ -374,7 +408,8 @@ public async Task LinuxArchiveVerifierChecksActualPayload(string rid, string sce var source = Path.Combine(workspace.Path, "publish with spaces"); LinuxTrayTestPayload.Create(source, rid); var layout = Path.Combine(workspace.Path, rid); - using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, null, null, source); + using var builder = new LayoutBuilder(layout, workspace.Path, rid, "Debug", "test", false, + trayDirectory: source, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); builder.CopyTray(); var tray = Path.Combine(layout, "tray"); switch (scenario) @@ -465,7 +500,8 @@ public async Task NativeTrayLaunchCheckReportsFailuresWithoutRepairingPayload(st { File.Delete(executable); } - using var builder = new LayoutBuilder(layout, workspace.Path, "linux-x64", "Debug", "test", false, null, null, null); + using var builder = new LayoutBuilder(layout, workspace.Path, "linux-x64", "Debug", "test", false, + trayDirectory: null, dashboardPath: null, managedPath: null, terminalHostPath: null, appHostServerPath: null); var archive = await builder.CreateArchiveAsync(); if (scenario == "invalid-archive") { diff --git a/tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs b/tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs index 2a66ce45959..c6088e70b9c 100644 --- a/tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs +++ b/tests/Infrastructure.Tests/TestTriggerMap/TestTriggerMapTests.cs @@ -367,7 +367,7 @@ private static IReadOnlySet LoadSolutionProjectPaths() }, { "eng/scripts/verify-native-dashboard-warnings.ps1", - ["test:Infrastructure.Tests", "job:native-dashboard-validation"] + ["test:Aspire.Cli.EndToEnd.Tests", "test:Aspire.Templates.Tests", "test:Infrastructure.Tests", "job:cli-starter-validation", "job:native-dashboard-validation", "job:extension-e2e", "job:homebrew-installer", "job:polyglot", "job:winget-installer"] }, { ".github/workflows/native-dashboard-validation.yml", @@ -430,7 +430,7 @@ private static IReadOnlySet LoadSolutionProjectPaths() }, { "eng/Bundle.proj", - ["test:Aspire.Cli.EndToEnd.Tests", "test:Infrastructure.Tests", "job:cli-starter-validation", "job:extension-e2e", "job:winget-installer", "job:homebrew-installer"] + ["test:Aspire.Cli.EndToEnd.Tests", "test:Aspire.Templates.Tests", "test:Infrastructure.Tests", "job:cli-starter-validation", "job:native-dashboard-validation", "job:extension-e2e", "job:homebrew-installer", "job:polyglot", "job:winget-installer"] }, { "tools/CreateLayout/verify-tray-payload.sh", @@ -649,7 +649,6 @@ public void EngCommonPipelineTemplatesAlsoRunTheFullMatrix(string path) [Theory] [InlineData("eng/scripts/verify-cli-npm-package.ps1")] [InlineData("eng/scripts/verify-cli-tool-nupkg.ps1")] - [InlineData("eng/scripts/stabilization-smoke-init-restore.sh")] [InlineData("eng/generate-catalog.ps1")] public void PathHandledOutsideSelectorDoesNotForceTestSelection(string path) { @@ -661,6 +660,17 @@ public void PathHandledOutsideSelectorDoesNotForceTestSelection(string path) Assert.Empty(result.Jobs); } + [Fact] + public void StabilizationSmokeScriptSelectsItsWrapperCoverage() + { + var result = SelectWithRealMap("eng/scripts/stabilization-smoke-init-restore.sh"); + + Assert.False(result.SelectsAll); + Assert.Empty(result.UnmatchedFiles); + Assert.Equal(["Infrastructure.Tests"], result.TestProjects); + Assert.Empty(result.Jobs); + } + [Theory] [InlineData("src/Aspire.Hosting.Dotnet/Aspire.Hosting.Dotnet.csproj", "Aspire.Hosting.Dotnet")] [InlineData("src/Aspire.Hosting.Foundry/Aspire.Hosting.Foundry.csproj", "Aspire.Hosting.Foundry")] @@ -759,6 +769,26 @@ public void CliBundleConsumersRunWhenCreateLayoutIsAffected() result.Jobs.Order(StringComparer.Ordinal)); } + [Theory] + [InlineData("eng/Bundle.proj")] + [InlineData("eng/scripts/verify-native-dashboard-warnings.ps1")] + [InlineData("eng/aspire-managed-entitlements.plist")] + public void SharedBundlePhasesSelectRegularRuntimePackageConsumers(string path) + { + var result = SelectWithRealMap(path); + + Assert.False(result.SelectsAll); + Assert.Empty(result.UnmatchedFiles); + Assert.Equal( + ["Aspire.Cli.EndToEnd.Tests", "Aspire.Templates.Tests", "Infrastructure.Tests"], + result.TestProjects.Order(StringComparer.Ordinal)); + Assert.Contains(result.TestCauses["Aspire.Templates.Tests"], + cause => cause.Kind == CauseKind.PathRule && cause.Trigger == path); + Assert.Equal( + ["job:cli-starter-validation", "job:extension-e2e", "job:homebrew-installer", "job:native-dashboard-validation", "job:polyglot", "job:winget-installer"], + result.Jobs.Order(StringComparer.Ordinal)); + } + [Fact] public void CliBundleConsumersRunWhenStandaloneTerminalHostIsAffected() { diff --git a/tests/Infrastructure.Tests/WorkflowScripts/AutoRerunTransientCiFailuresTests.cs b/tests/Infrastructure.Tests/WorkflowScripts/AutoRerunTransientCiFailuresTests.cs index fd268ddf048..a85f72070d1 100644 --- a/tests/Infrastructure.Tests/WorkflowScripts/AutoRerunTransientCiFailuresTests.cs +++ b/tests/Infrastructure.Tests/WorkflowScripts/AutoRerunTransientCiFailuresTests.cs @@ -753,16 +753,21 @@ public async Task SkipsArtifactServiceNetworkErrorWhenNonArtifactStepAlsoFailed( Assert.Equal("Failed steps 'Build CLI | Upload RID-specific packages' are not covered by the retry-safe rerun rules.", result.SkippedJobs[0].Reason); } - [Fact] + [Theory] + [InlineData("Run tests (Windows)")] + [InlineData("Build native bundle and CLI packages")] + [InlineData("Build bundle payload archive")] [RequiresTools(["node"])] - public async Task AllowsNarrowOverrideForExplicitJobLevelInfrastructureAnnotationsOnIgnoredSteps() + public async Task AllowsNarrowOverrideForExplicitJobLevelInfrastructureAnnotationsOnIgnoredSteps(string failedStep) { - WorkflowJob job = CreateJob(failedSteps: ["Run tests (Windows)"]); + WorkflowJob job = CreateJob(failedSteps: [failedStep]); AnalyzeFailedJobsResult result = await AnalyzeSingleJobAsync(job, "The hosted runner lost communication with the server."); - Assert.Single(result.RetryableJobs); - Assert.Equal("Ignored failed step 'Run tests (Windows)' matched the job-level infrastructure override allowlist.", result.RetryableJobs[0].Reason); + Assert.Empty(result.SkippedJobs); + Assert.Equal( + $"Ignored failed step '{failedStep}' matched the job-level infrastructure override allowlist.", + Assert.Single(result.RetryableJobs).Reason); } [Fact] @@ -895,6 +900,22 @@ public async Task AllowsLogBasedOverrideForConnectionResetByPeerInBuildSteps() result.RetryableJobs[0].Reason); } + [Theory] + [InlineData("Build native bundle and CLI packages")] + [InlineData("Build bundle payload archive")] + [RequiresTools(["node"])] + public async Task DoesNotRetryBundlePhasesForGenericExitCodeAnnotations(string failedStep) + { + WorkflowJob job = CreateJob(failedSteps: [failedStep]); + + AnalyzeFailedJobsResult result = await AnalyzeSingleJobAsync(job, "Process completed with exit code 1."); + + Assert.Empty(result.RetryableJobs); + Assert.Equal( + $"Failed step '{failedStep}' is only retried when the job shows a high-confidence infrastructure override, and none was found.", + Assert.Single(result.SkippedJobs).Reason); + } + [Fact] [RequiresTools(["node"])] public async Task UsesLongerMarkdownFenceWhenMatchedPatternContainsBackticks() diff --git a/tools/CreateLayout/CreateLayout.csproj b/tools/CreateLayout/CreateLayout.csproj index d9bdf46194d..e15cb83112e 100644 --- a/tools/CreateLayout/CreateLayout.csproj +++ b/tools/CreateLayout/CreateLayout.csproj @@ -14,6 +14,11 @@ + + + + + diff --git a/tools/CreateLayout/Program.cs b/tools/CreateLayout/Program.cs index bc4162f15b4..c9543b458c1 100644 --- a/tools/CreateLayout/Program.cs +++ b/tools/CreateLayout/Program.cs @@ -4,6 +4,7 @@ using System.CommandLine; using System.Diagnostics; using System.IO.Compression; +using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; using Aspire.Shared; @@ -57,9 +58,9 @@ public static async Task Main(string[] args) Description = "Create a .tar.gz archive after building on all platforms" }; - var trayAppOption = new Option("--tray-app") + var trayOption = new Option("--tray-dir") { - Description = "Pre-built Aspire Tray.app directory (required for macOS; signed before layout assembly)" + Description = "Prepared native tray directory (.app directory on macOS; required for Windows, macOS, and glibc Linux)" }; var verboseOption = new Option("--verbose") @@ -67,13 +68,22 @@ public static async Task Main(string[] args) Description = "Enable verbose output" }; - var windowsTrayOption = new Option("--tray-windows") + var dashboardOption = new Option("--dashboard") { - Description = "Pre-built Windows tray publish directory (required for Windows; signed before layout assembly)" + Description = "Prepared Dashboard publish directory (discovered from artifacts when omitted)" }; - var linuxTrayOption = new Option("--tray-linux") + + var managedOption = new Option("--managed") + { + Description = "Prepared Aspire.Managed publish directory (discovered from artifacts when omitted)" + }; + var terminalHostOption = new Option("--terminal-host") + { + Description = "Prepared TerminalHost publish directory (discovered from artifacts when omitted)" + }; + var appHostServerOption = new Option("--apphost-server") { - Description = "Pre-built Linux tray publish directory (required for glibc Linux x64/ARM64)" + Description = "Prepared AppHost Server publish directory (discovered from artifacts when omitted)" }; var rootCommand = new RootCommand("CreateLayout - Build Aspire bundle layout for distribution"); @@ -83,9 +93,11 @@ public static async Task Main(string[] args) rootCommand.Options.Add(configurationOption); rootCommand.Options.Add(bundleVersionOption); rootCommand.Options.Add(archiveOption); - rootCommand.Options.Add(trayAppOption); - rootCommand.Options.Add(windowsTrayOption); - rootCommand.Options.Add(linuxTrayOption); + rootCommand.Options.Add(trayOption); + rootCommand.Options.Add(dashboardOption); + rootCommand.Options.Add(managedOption); + rootCommand.Options.Add(terminalHostOption); + rootCommand.Options.Add(appHostServerOption); rootCommand.Options.Add(verboseOption); rootCommand.SetAction(async (parseResult, cancellationToken) => @@ -101,7 +113,8 @@ public static async Task Main(string[] args) try { using var builder = new LayoutBuilder(outputPath, artifactsPath, rid, configuration, version, verbose, - parseResult.GetValue(trayAppOption), parseResult.GetValue(windowsTrayOption), parseResult.GetValue(linuxTrayOption)); + parseResult.GetValue(trayOption), parseResult.GetValue(dashboardOption), parseResult.GetValue(managedOption), + parseResult.GetValue(terminalHostOption), parseResult.GetValue(appHostServerOption)); await builder.BuildAsync().ConfigureAwait(false); if (createArchive) @@ -138,11 +151,14 @@ internal sealed class LayoutBuilder : IDisposable private readonly string _configuration; private readonly string _version; private readonly bool _verbose; - private readonly string? _trayAppPath; - private readonly string? _windowsTrayPath; - private readonly string? _linuxTrayPath; - - public LayoutBuilder(string outputPath, string artifactsPath, string rid, string configuration, string version, bool verbose, string? trayAppPath, string? windowsTrayPath, string? linuxTrayPath) + private readonly string? _trayDirectory; + private readonly string? _dashboardPath; + private readonly string? _managedPath; + private readonly string? _terminalHostPath; + private readonly string? _appHostServerPath; + + public LayoutBuilder(string outputPath, string artifactsPath, string rid, string configuration, string version, bool verbose, + string? trayDirectory, string? dashboardPath, string? managedPath, string? terminalHostPath, string? appHostServerPath) { _outputPath = Path.GetFullPath(outputPath); _artifactsPath = Path.GetFullPath(artifactsPath); @@ -150,9 +166,11 @@ public LayoutBuilder(string outputPath, string artifactsPath, string rid, string _configuration = configuration; _version = version; _verbose = verbose; - _trayAppPath = trayAppPath; - _windowsTrayPath = windowsTrayPath; - _linuxTrayPath = linuxTrayPath; + _trayDirectory = trayDirectory; + _dashboardPath = dashboardPath; + _managedPath = managedPath; + _terminalHostPath = terminalHostPath; + _appHostServerPath = appHostServerPath; } public void Dispose() @@ -187,13 +205,19 @@ public async Task BuildAsync() internal void CopyTray() { + if (_rid == "linux-musl-x64") + { + return; + } + + if (string.IsNullOrWhiteSpace(_trayDirectory)) + { + throw new InvalidOperationException($"The {_rid} bundle requires --tray-dir pointing to the prepared native tray directory (.app directory on macOS)."); + } + if (_rid is "linux-x64" or "linux-arm64") { - if (string.IsNullOrWhiteSpace(_linuxTrayPath)) - { - throw new InvalidOperationException("The Linux bundle requires --tray-linux pointing to the pre-built native tray publish directory."); - } - LinuxTrayPayload.Validate(_linuxTrayPath, _rid); + LinuxTrayPayload.Validate(_trayDirectory, _rid); if (OperatingSystem.IsWindows()) { throw new InvalidOperationException("Linux tray bundles must be assembled on Unix to preserve executable permissions."); @@ -202,7 +226,7 @@ internal void CopyTray() Directory.CreateDirectory(destination); foreach (var name in new[] { LinuxTrayPayload.ExecutableName, LinuxTrayPayload.IconName }) { - var source = Path.Combine(_linuxTrayPath, name); + var source = Path.Combine(_trayDirectory, name); var target = Path.Combine(destination, name); File.Copy(source, target, overwrite: true); File.SetUnixFileMode(target, File.GetUnixFileMode(source)); @@ -213,18 +237,14 @@ internal void CopyTray() if (_rid.StartsWith("win-", StringComparison.Ordinal)) { - if (string.IsNullOrWhiteSpace(_windowsTrayPath)) - { - throw new InvalidOperationException("The Windows bundle requires --tray-windows pointing to the pre-built native tray publish directory."); - } - WindowsTrayPayload.Validate(_windowsTrayPath, _rid); + WindowsTrayPayload.Validate(_trayDirectory, _rid); var destination = Path.Combine(_outputPath, "tray"); Directory.CreateDirectory(destination); // Only the explicitly produced runtime payload is shipped, never PDBs, // managed build intermediates, or logs from a previous smoke run. foreach (var name in new[] { WindowsTrayPayload.ExecutableName, WindowsTrayPayload.IconName }) { - File.Copy(Path.Combine(_windowsTrayPath, name), Path.Combine(destination, name), overwrite: true); + File.Copy(Path.Combine(_trayDirectory, name), Path.Combine(destination, name), overwrite: true); } Log("Copied Windows tray to tray/"); return; @@ -235,21 +255,16 @@ internal void CopyTray() return; } - if (string.IsNullOrWhiteSpace(_trayAppPath)) - { - throw new InvalidOperationException("The macOS bundle requires --tray-app pointing to the pre-built Aspire Tray.app."); - } - foreach (var relativePath in new[] { "Contents/MacOS/aspire-tray", "Contents/Info.plist", "Contents/Resources/Aspire.icns", "Contents/_CodeSignature/CodeResources" }) { - var path = Path.Combine(_trayAppPath, relativePath); + var path = Path.Combine(_trayDirectory, relativePath); if (!File.Exists(path)) { throw new InvalidOperationException($"Required macOS tray payload not found: {path}. Publish the tray app before creating the bundle."); } } - var executablePath = Path.Combine(_trayAppPath, "Contents", "MacOS", "aspire-tray"); + var executablePath = Path.Combine(_trayDirectory, "Contents", "MacOS", "aspire-tray"); if (OperatingSystem.IsWindows()) { throw new InvalidOperationException("macOS tray bundles must be assembled on a Unix host to preserve executable permissions."); @@ -261,15 +276,15 @@ internal void CopyTray() // Copy the sealed app verbatim, including hidden files, resources and // _CodeSignature. Reconstructing the app from its executable invalidates signing. - CopyDirectory(_trayAppPath, Path.Combine(_outputPath, "tray", "Aspire Tray.app"), excludeSymbols: false); + CopyDirectory(_trayDirectory, Path.Combine(_outputPath, "tray", "Aspire Tray.app"), excludeSymbols: false); Log("Copied Aspire Tray.app to tray/"); } - private void CopyManaged() + internal void CopyManaged() { Log("Copying aspire-managed..."); - var managedPublishPath = FindPublishPath("Aspire.Managed", "net10.0"); + var managedPublishPath = ResolvePublishPath("Aspire.Managed", "--managed", _managedPath, requireRidSpecific: false); if (managedPublishPath is null) { throw new InvalidOperationException("Aspire.Managed publish output not found."); @@ -296,7 +311,7 @@ private void CopyManaged() internal void CopyTerminalHost() { - var publishPath = FindPublishPath("Aspire.TerminalHost", "net11.0", requireRidSpecific: true) + var publishPath = ResolvePublishPath("Aspire.TerminalHost", "--terminal-host", _terminalHostPath, requireRidSpecific: true) ?? throw new InvalidOperationException("Aspire.TerminalHost RID-specific publish output not found."); foreach (var file in TerminalHostPayload.GetRequiredFiles(_rid)) { @@ -324,7 +339,7 @@ internal void CopyTerminalHost() internal void CopyAppHostServer() { - var publishPath = FindPublishPath("Aspire.Hosting.Native.Server", "net11.0", requireRidSpecific: true) + var publishPath = ResolvePublishPath("Aspire.Hosting.Native.Server", "--apphost-server", _appHostServerPath, requireRidSpecific: true) ?? throw new InvalidOperationException("AppHost Server v2 publish output not found."); var extension = _rid.StartsWith("win-", StringComparison.Ordinal) ? ".exe" : ""; var source = Path.Combine(publishPath, "Aspire.Hosting.Native.Server" + extension); @@ -347,12 +362,24 @@ internal void CopyDashboard() { Log("Copying Native AOT Dashboard..."); + if (_dashboardPath is not null && string.IsNullOrWhiteSpace(_dashboardPath)) + { + throw new InvalidOperationException("--dashboard requires a nonempty publish directory."); + } + // A non-RID publish contains a framework-dependent apphost instead of the native Dashboard. // Only RID-specific output can be used here. - var dashboardPublishPath = FindPublishPath("Aspire.Dashboard", "net11.0", requireRidSpecific: true); + var dashboardFramework = GetComponentTargetFramework("Aspire.Dashboard"); + var dashboardPublishPath = _dashboardPath ?? FindPublishPath("Aspire.Dashboard", dashboardFramework, requireRidSpecific: true); if (dashboardPublishPath is null) { - throw new InvalidOperationException("Aspire.Dashboard publish output not found."); + throw new InvalidOperationException( + $"Aspire.Dashboard publish output not found for RID '{_rid}', configuration '{_configuration}'. " + + $"Searched: {string.Join(", ", GetRidSpecificPublishPaths("Aspire.Dashboard", dashboardFramework))}"); + } + if (!Directory.Exists(dashboardPublishPath)) + { + throw new InvalidOperationException($"Dashboard publish directory not found at {dashboardPublishPath}"); } var isWindows = _rid.StartsWith("win", StringComparison.OrdinalIgnoreCase); @@ -486,19 +513,36 @@ public async Task CreateArchiveAsync() return archivePath; } + // Versions.props -> SDK-generated assembly metadata -> standalone discovery. + // Bundle.proj passes explicit paths instead, keeping copying aligned with validation and signing. + internal static string GetComponentTargetFramework(string projectName) => + typeof(LayoutBuilder).Assembly.GetCustomAttributes() + .SingleOrDefault(attribute => attribute.Key == $"{projectName}.TargetFramework")?.Value + ?? throw new InvalidOperationException($"Missing target framework metadata for {projectName}."); + + private string? ResolvePublishPath(string projectName, string option, string? selectedPath, bool requireRidSpecific) + { + if (selectedPath is null) + { + return FindPublishPath(projectName, GetComponentTargetFramework(projectName), requireRidSpecific); + } + if (string.IsNullOrWhiteSpace(selectedPath)) + { + throw new InvalidOperationException($"{option} requires a nonempty publish directory."); + } + if (!Directory.Exists(selectedPath)) + { + throw new InvalidOperationException($"{projectName} publish directory not found at {selectedPath}"); + } + + return selectedPath; + } + internal string? FindPublishPath(string projectName, string targetFramework, bool requireRidSpecific = false) { // Only use the requested configuration so stale output from another build cannot be bundled. // Prefer RID-specific publish paths over non-RID output. - var ridSpecificSearchPaths = new[] - { - // PlatformName-scoped output used by RID packaging and signing. - Path.Combine(_artifactsPath, "bin", projectName, _rid, _configuration, targetFramework, _rid, "publish"), - // RID-specific self-contained publish output (preferred for Aspire.Managed) - Path.Combine(_artifactsPath, "bin", projectName, _configuration, targetFramework, _rid, "publish"), - // Native AOT output - Path.Combine(_artifactsPath, "bin", projectName, _configuration, targetFramework, _rid, "native"), - }; + var ridSpecificSearchPaths = GetRidSpecificPublishPaths(projectName, targetFramework); var searchPaths = requireRidSpecific ? ridSpecificSearchPaths @@ -520,6 +564,16 @@ public async Task CreateArchiveAsync() return null; } + private string[] GetRidSpecificPublishPaths(string projectName, string targetFramework) => + [ + // PlatformName-scoped output used by RID packaging and signing. + Path.Combine(_artifactsPath, "bin", projectName, _rid, _configuration, targetFramework, _rid, "publish"), + // RID-specific self-contained publish output (preferred for Aspire.Managed). + Path.Combine(_artifactsPath, "bin", projectName, _configuration, targetFramework, _rid, "publish"), + // Native AOT output. + Path.Combine(_artifactsPath, "bin", projectName, _configuration, targetFramework, _rid, "native"), + ]; + private string? FindDcpPath() { // DCP is in NuGet packages as Microsoft.DeveloperControlPlane.{os}-{arch} diff --git a/tools/CreateLayout/README.md b/tools/CreateLayout/README.md index 31f61214a33..2df9711f30b 100644 --- a/tools/CreateLayout/README.md +++ b/tools/CreateLayout/README.md @@ -1,12 +1,13 @@ # CreateLayout Tool -This tool creates the Aspire bundle layout for distribution. It assembles Aspire.Managed, the Native AOT Dashboard and TerminalHost, DCP, and (on macOS, Windows, and glibc Linux) the native tray companion into a payload that the build embeds in the Native AOT Aspire CLI. The payload does not require a globally-installed .NET SDK or a separate shared runtime. +This tool creates the Aspire bundle layout for distribution. It assembles Aspire.Managed, the Native AOT AppHost Server, Dashboard and TerminalHost, DCP, and (on macOS, Windows, and glibc Linux) the native tray companion into a payload that the build embeds in the Native AOT Aspire CLI. The payload does not require a globally-installed .NET SDK or a separate shared runtime. ## Purpose The bundle layout enables polyglot app hosts (TypeScript, Python, Go, etc.) to use Aspire without needing a .NET SDK installed. The bundle includes: - **Aspire.Managed** - Self-contained executable containing the AppHost server and compatibility forwarders +- **AppHost Server** - Native AOT server and its ATS contract - **TerminalHost** - Native AOT terminal relay and native dependencies; Windows PTY sidecars are also copied beside Aspire.Managed for older Hosting - **Dashboard** - Native AOT compiled Blazor-based monitoring UI, native dependencies, and static assets - **DCP** - Developer Control Plane (orchestrator) @@ -17,11 +18,12 @@ The bundle layout enables polyglot app hosts (TypeScript, Python, Go, etc.) to u Before running CreateLayout, you must: 1. Restore the repository with `./restore.sh` (Linux/macOS) or `.\restore.cmd` (Windows) to set up the local SDK. -2. Publish `Aspire.Managed` as self-contained and `Aspire.Dashboard` and `Aspire.TerminalHost` with Native AOT for the RID and configuration passed to CreateLayout. Building Native AOT output requires the native toolchain for the target platform. +2. Publish `Aspire.Managed` as self-contained and `Aspire.Dashboard`, `Aspire.TerminalHost`, and `Aspire.Hosting.Native.Server` with Native AOT for the RID and configuration passed to CreateLayout. Building Native AOT output requires the native toolchain for the target platform. 3. Have the publish outputs available in the artifacts directory: - - `Aspire.Managed`: `artifacts/bin/Aspire.Managed/{config}/net10.0/{rid}/publish/` - - `Aspire.Dashboard`: `artifacts/bin/Aspire.Dashboard/{config}/net11.0/{rid}/publish/` - - `Aspire.TerminalHost`: `artifacts/bin/Aspire.TerminalHost/{config}/net11.0/{rid}/publish/` + - `Aspire.Managed`: `artifacts/bin/Aspire.Managed/{config}/{framework}/{rid}/publish/` + - `Aspire.Dashboard`: `artifacts/bin/Aspire.Dashboard/{config}/{framework}/{rid}/publish/` + - `Aspire.TerminalHost`: `artifacts/bin/Aspire.TerminalHost/{config}/{framework}/{rid}/publish/` + - `Aspire.Hosting.Native.Server`: `artifacts/bin/Aspire.Hosting.Native.Server/{config}/{framework}/{rid}/publish/` - When publishing with `PlatformName={rid}`, the path includes an additional `{rid}/` immediately after the project name. The bundle build uses this layout for the Dashboard. 4. Restore the DCP NuGet package for the target RID. CreateLayout searches `NUGET_PACKAGES`, or the default NuGet package cache when that variable is not set. 5. For macOS and Windows, publish and sign the matching native tray payload before assembling the layout. The app or executable is copied as-is; CreateLayout does not sign it. @@ -43,9 +45,7 @@ dotnet run --project tools/CreateLayout/CreateLayout.csproj -- [options] | `-a, --artifacts ` | Path to build artifacts directory | | `--rid ` | Target runtime identifier: `win-x64`, `win-arm64`, `linux-x64`, `linux-arm64`, `linux-musl-x64`, `osx-x64`, or `osx-arm64` | | `-c, --configuration ` | Build configuration of the published components, such as `Debug` or `Release`. Output from other configurations is not used. | -| `--tray-app ` | Prepared macOS `.app` directory; required for macOS RIDs | -| `--tray-windows ` | Prepared Windows directory containing `aspire-tray.exe` and `Aspire.ico`; required for Windows RIDs | -| `--tray-linux ` | Prepared Linux directory containing `aspire-tray` and `Aspire.png`; required for `linux-x64` and `linux-arm64` | +| `--tray-dir ` | Prepared native tray directory; required for Windows, macOS, and glibc Linux RIDs. Use the complete `.app` directory on macOS or the executable/icon publish directory on Windows/Linux. Not used for musl. | Unsupported runtime identifiers, including `win-x86`, are rejected before the output directory is changed. @@ -56,6 +56,30 @@ Unsupported runtime identifiers, including `win-x86`, are rejected before the ou | `--bundle-version ` | Version string for the layout (default: `0.0.0-dev`) | | `--archive` | Create a `.tar.gz` archive after building, including on Windows | | `--verbose` | Enable verbose output | +| `--dashboard ` | Exact Dashboard publish directory, not an executable path. Overrides artifact discovery. | +| `--managed ` | Exact Aspire.Managed publish directory. Overrides artifact discovery. | +| `--terminal-host ` | Exact TerminalHost publish directory. Overrides artifact discovery. | +| `--apphost-server ` | Exact AppHost Server publish directory. Overrides artifact discovery. | + +When a component directory is omitted, discovery uses that producer's framework +and the requested configuration, preferring platform-scoped output, then RID +publish output, then native output. Only Aspire.Managed also accepts non-RID +publish output. An explicit directory never falls back to discovery, even if +discoverable output exists. Empty or whitespace arguments are rejected. +Explicit and discovered payloads receive the same component validation and +debug-symbol filtering. + +The framework values come from `eng/Versions.props`: `DefaultTargetFramework` +for Aspire.Managed, `AspireDashboardTargetFramework`, +`AspireTerminalHostTargetFramework`, and `AspireNativeServerTargetFramework`. +At build time, `CreateLayout.csproj` passes these values to the SDK's +`AssemblyMetadata` generation. At runtime, CreateLayout reads the embedded +`.TargetFramework` metadata for standalone discovery; it does not +re-read repository files or assume a framework version. + +`eng/Bundle.proj` passes all four resolved component directories explicitly. +Layout copying therefore uses the same outputs as validation and signing, +without rediscovering stale output from a different framework or configuration. ### Examples @@ -66,7 +90,7 @@ dotnet run --project tools/CreateLayout/CreateLayout.csproj -- \ --artifacts ./artifacts \ --rid linux-x64 \ --configuration Release \ - --tray-linux ./artifacts/bin/Aspire.Tray.Linux/Release/net10.0/linux-x64/publish \ + --tray-dir ./artifacts/bin/Aspire.Tray.Linux/Release/net10.0/linux-x64/publish \ --bundle-version 13.5.0 \ --archive \ --verbose @@ -79,7 +103,7 @@ dotnet run --project tools/CreateLayout/CreateLayout.csproj -- ` --artifacts ./artifacts ` --configuration Release ` --rid win-x64 ` - --tray-windows ./artifacts/bin/Aspire.Tray.Windows/Release/net10.0/win-x64/publish + --tray-dir ./artifacts/bin/Aspire.Tray.Windows/Release/net10.0/win-x64/publish ``` **Build a macOS layout from published components:** @@ -89,7 +113,7 @@ dotnet run --project tools/CreateLayout/CreateLayout.csproj -- \ --artifacts ./artifacts \ --configuration Release \ --rid osx-arm64 \ - --tray-app "./artifacts/bin/Aspire.Tray.Mac/Release/net10.0/osx-arm64/app/Aspire Tray.app" + --tray-dir "./artifacts/bin/Aspire.Tray.Mac/Release/net10.0/osx-arm64/app/Aspire Tray.app" ``` ## Output Structure @@ -99,7 +123,13 @@ The tool creates the following layout: ```text {output}/ ├── managed/ -│ └── aspire-managed[.exe] # AppHost server and terminal host +│ └── aspire-managed[.exe] # Compatibility AppHost server and terminal forwarder +├── apphost-server/ +│ ├── aspire-apphost-server[.exe] +│ └── ats-contract.json +├── terminalhost/ +│ ├── Aspire.TerminalHost[.exe] +│ └── ├── dashboard/ │ ├── Aspire.Dashboard[.exe] │ ├── @@ -114,14 +144,19 @@ Linux musl layouts have no tray directory. The macOS app is copied as a complete ## How It Works 1. **Copies aspire-managed** - Copies the self-contained AppHost server and terminal host executable -2. **Copies Dashboard** - Copies the complete Native AOT Dashboard publish payload, including native libraries and `wwwroot` static assets, excluding `.pdb`, `.dbg`, and `.dSYM` debug symbols -3. **Copies tray payload** - Copies the prepared macOS app or validated Windows/Linux executable and icon -4. **Copies DCP** - Finds DCP binaries from NuGet package restore output -5. **Creates Archive** - Optionally creates `aspire-{version}-{rid}.tar.gz` beside the output directory on all platforms, including Windows +2. **Copies AppHost Server** - Requires the native server and a nonempty `ats-contract.json`, excludes symbols, and renames the executable to `aspire-apphost-server[.exe]` +3. **Copies Dashboard** - Copies the complete Native AOT Dashboard publish payload, including native libraries and `wwwroot` static assets, excluding `.pdb`, `.dbg`, and `.dSYM` debug symbols +4. **Copies TerminalHost** - Requires the native terminal host and its platform dependencies, excluding symbols +5. **Copies tray payload** - Copies the prepared macOS app or validated Windows/Linux executable and icon +6. **Copies DCP** - Finds DCP binaries from NuGet package restore output +7. **Creates Archive** - Optionally creates `aspire-{version}-{rid}.tar.gz` beside the output directory on all platforms, including Windows Dashboard packaging requires the executable, a nonempty `wwwroot/_framework/blazor.web.js`, and a nonempty SQLite native library for the target RID: `e_sqlite3.dll` on Windows, `libe_sqlite3.so` on Linux, or `libe_sqlite3.dylib` on macOS. CreateLayout fails before copying the Dashboard if any of these requirements is not met. -`Bundle.proj` verifies the platform's tray in the resulting archive before CLI embedding. These checks validate payload structure, not native UI behavior or signing service readiness. +Windows, macOS, and glibc Linux tray verification inspects the assembled archive rather than just the source +files, because copying and archiving must preserve the app's resources, +permissions, and signature. These checks do not establish native UI behavior or +signing service readiness. ## Integration with Build Scripts