You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prerelease fix (#215 GITHUB_REF override) is ineffective — GITHUB_REF is reserved; use IGNORE_GITHUB_REF #221
The fix for #213 (PR #215) restores the develop leg's prerelease tag by overriding GITHUB_REF in the nbgv step env:. This does not work. GITHUB_REF is a GitHub-reserved variable that a step-level env: cannot reliably override — the runner re-injects the dispatch ref. NBGV's GitHub Actions cloud-build provider reads GITHUB_REF for BuildingRef, so on a publish dispatched from main the develop leg is still classified as the public ref and publishes a clean (stable) version.
Evidence (CI)
First real publish after #215 landed in a derived repo — the develop leg's nbgv step:
GITHUB_REF: refs/heads/develop # the step-env override (as configured)
"BuildingRef": "refs/heads/main" # NBGV still saw the dispatch ref
"PublicRelease": true
"SemVer2": "1.4.2" # clean, no -g suffix
The validate-release gate correctly blocked the publish (so no bad package shipped), but the develop prerelease leg never publishes.
Root cause
GITHUB_REF is reserved; overriding it via step env: is unsupported (GitHub: "Setting an environment variable with the GITHUB_ prefix may result in unexpected behavior"). NBGV reads it for BuildingRef:
NBGV versions from the checked-out branch; its cloud provider only overrides that with GITHUB_REF. Each matrix leg already checks out its own branch (Switched to a new branch 'develop'). Set NBGV's own IGNORE_GITHUB_REF=true so it ignores the CI ref and uses the checked-out branch:
- name: Run Nerdbank.GitVersioning tool stepid: nbgvuses: dotnet/nbgv@masterenv:
IGNORE_GITHUB_REF: true
Drop the branch input/threading added to get-version-task.yml and its callers for the (ineffective) GITHUB_REF override; the validate-release entry gate stays as the backstop.
Verified (CI probe, real dotnet/nbgv action)
checkout
IGNORE_GITHUB_REF
PublicRelease
SemVer2
develop
true
False
1.4.2-g14f645dfd9
main
true
True
1.4.3
main
false
False
1.4.3-g… (reproduces the bug)
Supersedes #215. Found in a derived repo's first real publish + a CI probe.
Fixed on develop via #222 (36f7eeb): NBGV IGNORE_GITHUB_REF (supersedes the ineffective #215 GITHUB_REF override; validate-release gate retained as backstop). Ships on the next develop → main release.
Important refinement — IGNORE_GITHUB_REF=true alone is insufficient; it must be paired with re-adding the branch input and a git checkout -B <branch> step.
Reason: with IGNORE_GITHUB_REF, NBGV versions from the checked-out git branch. build-nugetlibrary (and any caller pinning to a commit SHA) checks out a detached HEAD, where NBGV sees no branch and classifies every leg as prerelease — so the main leg builds a X.Y.Z-g<sha> package that mismatches its clean X.Y.Z release tag.
Verified with the nbgv tool:
state
result
detached at main SHA + IGNORE_GITHUB_REF
PublicRelease=False, 1.4.3-gef05e9edc1 (wrong)
detached + IGNORE_GITHUB_REF + git checkout -B main
PublicRelease=True, 1.4.3 (correct)
Complete fix
get-version-task.yml: keep the branch input; after checkout, force a local branch so NBGV sees the logical branch from a detached SHA:
(The cleaner long-term alternative is to compute the version once and thread it into build-nugetlibrary rather than recomputing on a detached checkout — that removes the dual-get-version divergence entirely.)
Activity
Use NBGV IGNORE_GITHUB_REF instead of the ineffective GITHUB_REF over…
ptr727 commentedon Jun 27, 2026
Fixed on
developvia #222 (36f7eeb): NBGV IGNORE_GITHUB_REF (supersedes the ineffective #215 GITHUB_REF override; validate-release gate retained as backstop). Ships on the nextdevelop→mainrelease.ptr727 commentedon Jun 27, 2026
Important refinement —
IGNORE_GITHUB_REF=truealone is insufficient; it must be paired with re-adding thebranchinput and agit checkout -B <branch>step.Reason: with
IGNORE_GITHUB_REF, NBGV versions from the checked-out git branch.build-nugetlibrary(and any caller pinning to a commit SHA) checks out a detached HEAD, where NBGV sees no branch and classifies every leg as prerelease — so the main leg builds aX.Y.Z-g<sha>package that mismatches its cleanX.Y.Zrelease tag.Verified with the nbgv tool:
IGNORE_GITHUB_REFPublicRelease=False,1.4.3-gef05e9edc1(wrong)IGNORE_GITHUB_REF+git checkout -B mainPublicRelease=True,1.4.3(correct)Complete fix
get-version-task.yml: keep thebranchinput; after checkout, force a local branch so NBGV sees the logical branch from a detached SHA:Thread
branchto both get-version callers (build-release-taskandbuild-nugetlibrary-task).CI-verified (detached build-nugetlibrary path)
ptr727.LanguageTags.1.4.3.nupkg(clean)ptr727.LanguageTags.1.4.4-gf2560a8e4c.nupkg(prerelease)(The cleaner long-term alternative is to compute the version once and thread it into
build-nugetlibraryrather than recomputing on a detached checkout — that removes the dual-get-version divergence entirely.)