Skip to content

build: Microsoft.Build.Tasks.Git cannot read this repo's reftable ref storage — every local build errors #424

Description

@jamesburton

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

  1. Bump Microsoft.SourceLink.GitHub / Microsoft.Build.Tasks.Git. reftable support has been landing in recent releases — check the changelog before assuming.
  2. 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.
  3. 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

  • dotnet build succeeds locally with no -p: workaround and no Microsoft.Build.Tasks.Git error.
  • Whichever fix is chosen is documented in-repo, so the next agent does not re-derive it. This has already cost multiple sessions.
  • If (2) is chosen, the props comment states why and links this issue.

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions