Skip to content

Copy Mercurial from only one LibChorus TFM build - #401

Merged
hahn-kev merged 1 commit into
masterfrom
fix-mercurial-ini-race
Oct 1, 2026
Merged

hahn-kev merged 1 commit into
masterfrom
fix-mercurial-ini-race

Conversation

@hahn-kev

@hahn-kev hahn-kev commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixed a flakey CI failure due to duplicate work when building to frameworks at once.


AI summary

Windows CI sometimes fails building LibChorus with:

SIL.Chorus.Mercurial.targets(24,3): error MSB3491: Could not write lines to file "D:\a\chorus\chorus\/Mercurial/mercurial.ini". The process cannot access the file ... because it is being used by another process.

(seen in https://github.com/sillsdev/chorus/actions/runs/36093584645)

Cause: SIL.Chorus.Mercurial adds CopyFiles and AdjustFixUtf8 to BuildDependsOn. LibChorus targets net462;netstandard2.0, so both inner builds run those targets in parallel and write the same $(SolutionDir)/Mercurial/mercurial.ini.

Fix:

  • LibChorus.csproj sets Mercurial4ChorusTargetFramework to netstandard2.0.
  • Directory.Build.targets removes ;CopyFiles;AdjustFixUtf8 from BuildDependsOn in the other inner builds. This has to be in a .targets file because NuGet's package targets load after the project file and before Directory.Build.targets. Unescape is needed because property functions escape ; in their result.

netstandard2.0 was picked because projects referencing LibChorus call its inner builds directly (skipping the outer build), and netstandard2.0 is built on every OS and CI leg. The package's buildMultiTargeting targets do nothing because the outer Build target doesn't read BuildDependsOn, so moving the work to the outer build would mean more plumbing.

The LibChorus nuspec is unchanged: the SIL.Chorus.Mercurial dependency keeps the same excludes.

A more robust fix belongs upstream in sillsdev/Mercurial4Chorus: write mercurial.ini with Overwrite="true" / WriteOnlyWhenDifferent="true" instead of appending, and add an opt-out property. The override here depends on the package's exact ;CopyFiles;AdjustFixUtf8 text.

Test plan

  • Deleted Mercurial/ and ran dotnet build Chorus.sln -m four times on Windows (SDK 11 RC; three with --no-incremental): all succeeded, each detailed log shows CopyFiles and AdjustFixUtf8 running once, in the netstandard2.0 build
  • Clean dotnet build Chorus.sln -m with SDK 8.0.425 (CI's version): succeeded, one AdjustFixUtf8
  • mercurial.ini has exactly one fixutf8 line after each build
  • With TortoiseHg removed from PATH, HgRepositoryTests and HgWrappingTests pass on net8.0 and net462, so tests find the repo's Mercurial/ folder
  • Windows CI passes

🤖 Generated with Claude Code


This change is Reviewable

SIL.Chorus.Mercurial adds CopyFiles and AdjustFixUtf8 to BuildDependsOn,
so LibChorus's net462 and netstandard2.0 inner builds both ran them in
parallel and wrote the same Mercurial/mercurial.ini. That could fail
Windows CI with MSB3491 (file in use). Run them only in the
netstandard2.0 build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rmunn

rmunn commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I've run into the same thing, and had to re-run the CI workflows a few times until the timing of the two builds happened to diverge enough that they didn't hit the AdjustFixUtf8 step simultaneously. I'll wait until the tests finish running before I approve this, but it looks good to me.

@github-actions

Copy link
Copy Markdown

Test Results

       8 files  +       2     346 suites  +108   1h 6m 9s ⏱️ + 19m 14s
1 031 tests ±       0     975 ✔️ ±       0    56 💤 ±  0  0 ❌ ±0 
3 266 runs  +1 052  3 143 ✔️ +1 029  123 💤 +23  0 ❌ ±0 

Results for commit 8472d2e. ± Comparison against base commit fb88365.

@rmunn rmunn 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.

LGTM

@hahn-kev
hahn-kev merged commit 116b10b into master Oct 1, 2026
7 checks passed
@hahn-kev
hahn-kev deleted the fix-mercurial-ini-race branch October 1, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants