Symptom
Every local build, in every worktree, fails or warns with:
Microsoft.Build.Tasks.Git : Error reading git repository information:
Found invalid data while decoding
Agents have been working around it ad hoc with -p:EnableSourceControlManagerQueries=false. Fresh CI clones are unaffected.
Root cause — verified, and it is NOT worktree count
This repository has been converted to git's newer reftable ref-storage format:
$ git config --get extensions.refstorage
reftable
$ ls .git/reftable/ | head -3
0x000000000001-0x000000000f64-ae9c5151.ref
0x000000000f65-0x00000000115e-8ef0b162.ref
0x00000000115f-0x0000000011a7-57bdb026.ref
$ ls .git/packed-refs
ls: cannot access '.git/packed-refs': No such file or directory
Microsoft.Build.Tasks.Git (used by SourceLink) is a from-scratch managed reimplementation of git's ref and pack readers. In the versions in common circulation it understands only the classic loose-refs + packed-refs layout, not reftable. "Found invalid data while decoding" is the textbook symptom of that managed reader hitting a reftable block it does not recognise.
This explains the otherwise-odd observation that it affects every worktree identically — an earlier hypothesis blamed worktree count (24 sharing one .git), which is wrong. git fsck is clean; a git gc and removal of .git/objects/info/commit-graphs were both tried and neither helped, consistent with this diagnosis.
Also noted while verifying: .git/HEAD contains ref: refs/heads/.invalid, which is where the .invalid branch name in tooling output comes from. Probably a harness artifact and unrelated, but recorded here so it is not rediscovered.
Fixes, in order of preference
- Bump
Microsoft.SourceLink.GitHub / Microsoft.Build.Tasks.Git. reftable support has been landing in recent releases — check the changelog before assuming.
- If no fixed version exists yet, set
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries> in the repo-root Directory.Build.props as an explicit, commented stopgap — replacing the per-build -p: flag agents currently pass by hand. A documented opt-out beats folklore. Cost: SourceLink metadata absent from local builds; CI unaffected.
- Last resort, and a real repo-format change rather than a cleanup:
git config extensions.refstorage files reconverts to the classic format. Untested — do not run it casually. Verify first with a binlog (-bl on a failing build) showing the exact file and offset the decoder chokes on.
Acceptance criteria
Separately: 24 worktrees share this .git and most are stale. Worth cleaning for tidiness — but it is not the cause of this, and cleanup will not fix it.
Symptom
Every local build, in every worktree, fails or warns with:
Agents have been working around it ad hoc with
-p:EnableSourceControlManagerQueries=false. Fresh CI clones are unaffected.Root cause — verified, and it is NOT worktree count
This repository has been converted to git's newer reftable ref-storage format:
Microsoft.Build.Tasks.Git(used by SourceLink) is a from-scratch managed reimplementation of git's ref and pack readers. In the versions in common circulation it understands only the classic loose-refs +packed-refslayout, not reftable. "Found invalid data while decoding" is the textbook symptom of that managed reader hitting a reftable block it does not recognise.This explains the otherwise-odd observation that it affects every worktree identically — an earlier hypothesis blamed worktree count (24 sharing one
.git), which is wrong.git fsckis clean; agit gcand removal of.git/objects/info/commit-graphswere both tried and neither helped, consistent with this diagnosis.Also noted while verifying:
.git/HEADcontainsref: refs/heads/.invalid, which is where the.invalidbranch name in tooling output comes from. Probably a harness artifact and unrelated, but recorded here so it is not rediscovered.Fixes, in order of preference
Microsoft.SourceLink.GitHub/Microsoft.Build.Tasks.Git. reftable support has been landing in recent releases — check the changelog before assuming.<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>in the repo-rootDirectory.Build.propsas an explicit, commented stopgap — replacing the per-build-p:flag agents currently pass by hand. A documented opt-out beats folklore. Cost: SourceLink metadata absent from local builds; CI unaffected.git config extensions.refstorage filesreconverts to the classic format. Untested — do not run it casually. Verify first with a binlog (-blon a failing build) showing the exact file and offset the decoder chokes on.Acceptance criteria
dotnet buildsucceeds locally with no-p:workaround and noMicrosoft.Build.Tasks.Giterror.Separately: 24 worktrees share this
.gitand most are stale. Worth cleaning for tidiness — but it is not the cause of this, and cleanup will not fix it.