Give each TFM build its own GitVersion output file - #402
Merged
Merged
Conversation
GitVersion.MsBuild runs gitversion in every inner build and writes
obj/gitversion.json by default, so the parallel inner builds of a
multi-targeted project (LibChorus, ChorusMerge, and their tests) share
one file. If one build reads it while another is rewriting it, GetVersion
silently gets empty values and GetAssemblyVersion fails with MSB4044
("not given a value for the required parameter NuGetVersion").
Write obj/gitversion.$(TargetFramework).json in inner builds instead. The
outer build keeps obj/gitversion.json.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rmunn
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevents build failures on a race between 2 TFM builds writing the same file.
AI summary
CI intermittently failed building
src/LibChorus/LibChorus.csprojfor net462 with:(seen in https://github.com/sillsdev/chorus/actions/runs/36810778313, while the netstandard2.0 build of the same project succeeded).
Cause. GitVersion.MsBuild 5.10.3 runs gitversion.exe in every inner build (
RunGitVersionis hooked beforeGetAssemblyVersion/CoreCompile) and writes the result toGitVersionOutputFile, which defaults toobj/gitversion.json. That file is shared by all TFMs of a project, and the inner builds run in parallel. If one build'sGetVersionreads the file while another build's gitversion has truncated it for rewriting,GetVersionsucceeds silently with empty outputs,Versionends up empty, and the SDK'sGetAssemblyVersionfails. Emptyingobj/gitversion.jsonand building net462 with gitversion stubbed out reproduces the exact error, with no GetVersion warning (matching the CI log). This affects every multi-targeted project: LibChorus, ChorusMerge, ChorusMerge.Tests and LibChorus.Tests. It's the same class of race as the mercurial.ini one fixed in #401.Fix. In
Directory.Build.props, inner builds setGitVersionOutputFiletoobj/gitversion.$(TargetFramework).json. The outer build (noTargetFramework, used by pack) keepsobj/gitversion.json. It has to be in .props, because GitVersion's props bake the path into the command line at evaluation time. It uses a literal relativeobj/becauseBaseIntermediateOutputPathisn't set yet at that point and the path goes unquoted into the gitversion command line.Test plan
obj/gitversion.jsonbefore the fixdotnet msbuild -getPropertyshows a distinct output file per TFM, with the outer build unchangeddotnet build Chorus.sln -m -c Releaseruns: 0 errors🤖 Generated with Claude Code
This change is