Skip to content

fix(ci): Pin SDK from the PR head branch in apply workflow - #23922

Open
MartinZikmund wants to merge 1 commit into
masterfrom
dev/mazi/ci-apply-sdk-pin
Open

fix(ci): Pin SDK from the PR head branch in apply workflow#23922
MartinZikmund wants to merge 1 commit into
masterfrom
dev/mazi/ci-apply-sdk-pin

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #23921

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

/apply-sync-gen failed with NETSDK1045 ("The current .NET SDK does not support targeting .NET 11.0") on every PR based on feature/breakingchanges — for example this run.

issue_comment events always run the workflow definition from the default branch, while the job checks out the PR head. winappsdk-sync-apply.yml on master hardcoded cp build/ci/net10/_global.json global.json, so a .NET 10 SDK was installed and then used to restore a tree whose projects target net11.0. build/ci/net11/ doesn't exist on master at 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:

run: cp "$(ls -d build/ci/net* | sort -V | tail -1)/_global.json" global.json

Verified against both layouts: master resolves to build/ci/net10/_global.json (10.0.105), feature/breakingchanges resolves to build/ci/net11/_global.json (11.0.100-preview.5).

winappsdk-sync-check.yml is deliberately left alone — it is pull_request-triggered, so its workflow file and its checkout always come from the same branch and its hardcoded pin is always correct. Same for codeql.yml (push / pull_request / schedule) and the XAML Styler workflows, which never evaluate a project's target framework.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — n/a, CI-only change; the pin command was executed against both branch layouts instead
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features) — n/a
  • 🖼️ Validated PR Screenshots Compare Test Run results. — n/a
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

`/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
Copilot AI review requested due to automatic review settings July 30, 2026 10:00
@MartinZikmund MartinZikmund self-assigned this Jul 30, 2026
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 14s —— View job


Code Review

  • Gather context and read changed file
  • Analyze the change
  • Post review findings

Verdict: LGTM — clean, minimal, and correctly reasoned fix.

Summary:

The root cause is well-understood: issue_comment-triggered workflows always execute the workflow definition from the default branch, while the checkout step checks out the PR head. The old hardcoded net10 path therefore broke any PR whose head branch targets net11.0.

The fix — cp "$(ls -d build/ci/net* | sort -V | tail -1)/_global.json" global.json — dynamically resolves the newest net* pin present in the checked-out tree, which is exactly what's needed. A few notes:

  • sort -V (version sort) correctly orders net9 < net10 < net11 where a lexicographic sort would not. The double-quoted subshell handles any path with spaces.
  • If build/ci/net* matches nothing or the picked directory has no _global.json, ls/cp will exit non-zero and fail the step loudly — the right behavior.
  • The explanatory comment added above the step accurately captures the non-obvious why (issue_comment workflow-definition/checkout mismatch).
  • winappsdk-sync-check.yml and codeql.yml retain their hardcoded net10 pin — the PR description correctly explains both are pull_request/push-triggered and therefore always have their workflow file and checkout on the same branch. No change needed there.

No issues found. 0 findings.

Copilot AI left a comment

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.

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.json from the PR head checkout into the repo root global.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] /apply-sync-gen fails with NETSDK1045 on PRs based on feature/breakingchanges

2 participants