fix(ci): Pin SDK from the PR head branch in apply workflow - #23922
fix(ci): Pin SDK from the PR head branch in apply workflow#23922MartinZikmund wants to merge 1 commit into
Conversation
`/apply-sync-gen` failed with NETSDK1045 on every PR based on `feature/breakingchanges`: `issue_comment` runs the workflow file from the default branch, which hardcoded the net10 pin, while the job checks out the PR head — whose projects target net11.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XshpwgMBfFZcPeGVFnh5zx
|
Claude finished @MartinZikmund's task in 1m 14s —— View job Code Review
Verdict: LGTM — clean, minimal, and correctly reasoned fix. Summary: The root cause is well-understood: The fix —
No issues found. 0 findings. |
There was a problem hiding this comment.
Pull request overview
This PR fixes the /apply-sync-gen comment-triggered workflow failing with NETSDK1045 on PRs whose head branch targets a newer .NET SDK than the default branch workflow file pins. It does this by deriving the SDK global.json pin from the checked-out PR head’s build/ci/net* directories instead of hardcoding build/ci/net10.
Changes:
- Update the apply workflow to copy the newest available
build/ci/net*/_global.jsonfrom the PR head checkout into the repo rootglobal.json. - Add inline comments explaining why the apply workflow must not hardcode the SDK version (workflow from default branch vs checkout from PR head).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GitHub Issue: closes #23921
PR Type:
🏗️ Build or CI related changes
What changed? 🚀
/apply-sync-genfailed withNETSDK1045("The current .NET SDK does not support targeting .NET 11.0") on every PR based onfeature/breakingchanges— for example this run.issue_commentevents always run the workflow definition from the default branch, while the job checks out the PR head.winappsdk-sync-apply.ymlonmasterhardcodedcp build/ci/net10/_global.json global.json, so a .NET 10 SDK was installed and then used to restore a tree whose projects targetnet11.0.build/ci/net11/doesn't exist onmasterat all, so simply bumping the path there is not an option.The pin is now taken from the newest
build/ci/net*directory present in the checked-out tree:Verified against both layouts:
masterresolves tobuild/ci/net10/_global.json(10.0.105),feature/breakingchangesresolves tobuild/ci/net11/_global.json(11.0.100-preview.5).winappsdk-sync-check.ymlis deliberately left alone — it ispull_request-triggered, so its workflow file and its checkout always come from the same branch and its hardcoded pin is always correct. Same forcodeql.yml(push / pull_request / schedule) and the XAML Styler workflows, which never evaluate a project's target framework.PR Checklist ✅
Screenshots Compare Test Runresults. — n/a