Skip to content

feat: add IsMonobuild parameter to step templates for self-ref support#6433

Merged
kythant merged 16 commits intorelease/dev/monobuildfrom
user/kythant/foundation-step-templates-monobuild-aware
Apr 28, 2026
Merged

feat: add IsMonobuild parameter to step templates for self-ref support#6433
kythant merged 16 commits intorelease/dev/monobuildfrom
user/kythant/foundation-step-templates-monobuild-aware

Conversation

@kythant
Copy link
Copy Markdown
Contributor

@kythant kythant commented Apr 28, 2026

In the monobuild context, the WindowsAppSDK monorepo IS the self repo, so @WinAppSDK template references would require declaring a self-ref repository resource (which has compile-time-only ref limitations).

Add an IsMonobuild parameter (default false) to all 7 step templates. When true, shared templates (PublishSymbol, DetermineVersion, EsrpCodeSigning, ConvertWttLogToXUnit) are invoked WITHOUT the @WinAppSDK suffix, resolving from self.

Per-component pipelines work unchanged (default IsMonobuild=false preserves @WinAppSDK cross-repo behavior). The monobuild caller (Foundation-Build-Stage.yml) passes IsMonobuild=true.

A microsoft employee must use /azp run to validate using the pipelines below.

WARNING:
Comments made by azure-pipelines bot maybe inaccurate.
Please see pipeline link to verify that the build is being ran.

For status checks on the main branch, please use TransportPackage-Foundation-PR
(https://microsoft.visualstudio.com/ProjectReunion/_build?definitionId=81063&_a=summary)
and run the build against your PR branch with the default parameters.

In the monobuild context, the WindowsAppSDK monorepo IS the self repo,
so @WinAppSDK template references would require declaring a self-ref
repository resource (which has compile-time-only ref limitations).

Add an IsMonobuild parameter (default false) to all 7 step templates.
When true, shared templates (PublishSymbol, DetermineVersion,
EsrpCodeSigning, ConvertWttLogToXUnit) are invoked WITHOUT the
@WinAppSDK suffix, resolving from self.

Per-component pipelines work unchanged (default IsMonobuild=false
preserves @WinAppSDK cross-repo behavior). The monobuild caller
(Foundation-Build-Stage.yml) passes IsMonobuild=true.
@kythant
Copy link
Copy Markdown
Contributor Author

kythant commented Apr 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

kythant added 4 commits April 27, 2026 17:27
When IsMonobuild=true, shared templates need to reference the running
pipeline's self repo (the WinAppSDK monorepo). An un-suffixed template
reference resolves relative to the calling template's repo (Foundation),
not the pipeline's self.

Use @self suffix to explicitly reference the running pipeline's repo,
which is the WinAppSDK monorepo in the monobuild context.
In the per-component context, BuildAll.ps1 expects NuGetLicense files at
WinAppSDK/Build/WindowsAppSDK/NuGetLicense (relative to repo root) because
the WinAppSDK monorepo is checked out as a separate folder.

In the monobuild context, the WinAppSDK monorepo IS the repo root, so the
files live at Build/WindowsAppSDK/NuGetLicense. Add a conditional pre-step
that mirrors them to the expected per-component path so BuildAll.ps1 finds
them without needing modification.
Don't assume the NuGetLicense source path - try both s/Build/... and
s/WinAppSDK/Build/... since OneBranch's checkout layout depends on
which checkout it processes first. Print debug info if neither found.
Replace 10 inline if/else blocks across 7 step templates with a single
template invocation per call site. Each shared template gets one wrapper:
  - WindowsAppSDK-EsrpCodeSigning-Wrapper.yml
  - WindowsAppSDK-PublishSymbol-Wrapper.yml
  - WindowsAppSDK-DetermineVersion-Wrapper.yml
  - WindowsAppSDK-ConvertWttLogToXUnit-Wrapper.yml

Each wrapper accepts IsMonobuild + InnerParams (object) and dispatches
to either @WinAppSDK or @self at compile time via if/else.

Net: 65 lines removed, no behavior change.
@kythant
Copy link
Copy Markdown
Contributor Author

kythant commented Apr 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

kythant added 11 commits April 28, 2026 11:22
Replaces the filesystem mirror approach with a direct REST API fetch from
the OS/WinAppSDK repo. This avoids needing a checkout step at all - no
WinAppSDK repo resource, no checkout: self with a path: directive (which
OneBranch silently ignores in dual-checkout scenarios).

Uses System.AccessToken for auth. Fetches preview/license.txt and
release/license.txt from refs/heads/release/dev/monobuild and places
them at the path BuildAll.ps1 expects:
WinAppSDK/Build/WindowsAppSDK/NuGetLicense/{preview,release}/license.txt
- Update Mirror script to copy NuGetLicense from \/Build/WindowsAppSDK/NuGetLicense (monobuild self) to \/WindowsAppSDK/WinAppSDK/Build/WindowsAppSDK/NuGetLicense (where BuildAll.ps1 expects, relative to Foundation)
- Add workingDirectory: \/WindowsAppSDK to BuildAll.ps1 PowerShell tasks when IsMonobuild=true so they run from Foundation root
- Other path references (\\BuildOutput, etc.) don't matter for the Pack portion - BuildAll.ps1 writes/reads relative to its working directory
…path

Diag dir output confirmed self (monobuild) lands at s/WinAppSDK and
Foundation lands at s/. Foundation's BuildAll.ps1 hardcoded path
'WinAppSDK/Build/WindowsAppSDK/NuGetLicense/preview/license.txt' is
relative to its own location (s/) and resolves to the monobuild's
copy at s/WinAppSDK/Build/WindowsAppSDK/NuGetLicense/preview/license.txt.
No mirror needed.
Diag dir output from build 145657939 confirmed the actual layout when PackFoundation runs both checkouts:

  - self (WinAppSDK monorepo): C:\__w\1\s\WinAppSDK\

  - Foundation:                C:\__w\1\s\WindowsAppSDK\

BuildAll.ps1 (in Foundation root) reads NuGetLicense via the relative path 'WinAppSDK\Build\WindowsAppSDK\NuGetLicense\...', which resolves against its own location. The previous attempts mirrored the wrong source (s\Build\... instead of s\WinAppSDK\Build\...) and the 'remove mirror' commit assumed Foundation was at s\ rather than s\WindowsAppSDK\.

Re-add the mirror with correct paths and add workingDirectory to StageFiles + PackNuget so BuildAll.ps1 runs from Foundation root. Gated on IsMonobuild so per-component pipelines are unaffected.
PowerShell@2 resolves filePath relative to Build.SourcesDirectory before workingDirectory takes effect, so filePath BuildAll.ps1 fails in monobuild (BuildAll.ps1 is at s\WindowsAppSDK\, not s\). Same issue affects other Foundation-relative paths.

Use $(Build.SourcesDirectory)\WindowsAppSDK as the Foundation root in monobuild for: StageFiles filePath, Copy-symbols sourceFolder, SetVersion nuspec path, PackNuget filePath, MoveToOutputDirectory FullNuget SourceFolder. Per-component pipeline behavior unchanged via the else branches.
Reverts the conditional path/workingDirectory rewrites added in c37453e and e817455. The monobuild side will swap checkout layout instead so Foundation lands at s/ and self lands at s/WinAppSDK, which makes BuildAll.ps1s hardcoded relative paths just work without any conditioning here.
In monobuild, BuildAll.ps1 lives at s/WindowsAppSDK/ and reads BuildOutput\ relative to its own location. Artifact downloads must therefore land at s/WindowsAppSDK/BuildOutput, not s/BuildOutput. Apply the same monobuild-aware conditioning to the 6 DownloadPipelineArtifact@2 calls (3 Foundation per-platform, 1 Foundation anycpu, 3 MRT per-platform).

This is the missing piece from the previous monobuild Pack iteration: filePath/workingDirectory were corrected, but the downloaded artifacts still landed at the per-component path so StageFiles/PackNuget had nothing to stage and exit 1.
…tes-monobuild-aware

Conflict in WindowsAppSDK-PackTransportPackage-Steps.yml: upstream PR #6434 folded the standalone Foundation anycpu DownloadPipelineArtifact into the per-platform loop and renamed ProjectReunion -> Project.Reunion in the push displayName; this branch had added monobuild-conditional targetPath to both. Resolution: keep upstream consolidated loop and displayName, drop the redundant standalone anycpu block, and preserve the conditional targetPath on the consolidated loop and on the MRT loop.
@kythant
Copy link
Copy Markdown
Contributor Author

kythant commented Apr 28, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

# @WinAppSDK (per-component pipelines) or @self (monobuild) at compile time.

parameters:
- name: IsMonobuild
Copy link
Copy Markdown
Contributor

@alexlamtest alexlamtest Apr 28, 2026

Choose a reason for hiding this comment

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

Nit: unnecessary indentation? The 2 spaces are not required, I think. But that should be ok.
Similar below, not repeating.

@@ -46,7 +54,10 @@ steps:
pipeline: $(_foundationBuildOutputPipeline)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: This indentation looks unusual in yml code. But it might just work.

@kythant kythant merged commit 21715ba into release/dev/monobuild Apr 28, 2026
49 checks passed
@kythant kythant deleted the user/kythant/foundation-step-templates-monobuild-aware branch April 28, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants