Skip to content

Disable copy hard links in code coverage builds - #7850

Open
rosebyte wants to merge 4 commits into
dotnet:mainfrom
rosebyte:rosebyte-coverlet-file-locking
Open

rosebyte wants to merge 4 commits into
dotnet:mainfrom
rosebyte:rosebyte-coverlet-file-locking

Conversation

@rosebyte

@rosebyte rosebyte commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Disable copy hard links for coverage builds to keep Coverlet's instrumented assemblies and PDBs separate from the original build outputs.

The coverage pipeline already omitted CreateHardLinksForCopyLocalIfPossible=True, but still unconditionally enabled CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=True. This can make the obj and bin PDB paths refer to the same underlying file.

Coverlet rewrites assemblies and PDBs during instrumentation. Instrumenting one project's output can therefore lock the original PDB while another project reads it, a likely cause of the recurring file-access failures.

Changes

  • Explicitly set both copy hard-link options to False for coverage builds.
  • Preserve the existing build command and hard-link settings for non-coverage jobs.
  • Leave native/publish linking and test parallelism unchanged.

The trade-off is increased disk usage and copy I/O in the coverage job, without serialising test execution.

Fixes #7417

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.81%. Comparing base (d008702) to head (724a20c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7850   +/-   ##
=======================================
  Coverage   70.81%   70.81%           
=======================================
  Files        1421     1421           
  Lines      280000   280034   +34     
  Branches    27620    27621    +1     
=======================================
+ Hits       198290   198318   +28     
- Misses      73549    73554    +5     
- Partials     8161     8162    +1     
Flag Coverage Δ
Debug 70.81% <ø> (+<0.01%) ⬆️
production 64.25% <ø> (-0.01%) ⬇️
test 90.78% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread build/ci/job-template.yml Outdated
hardLink: ''
hardLink: '/p:CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=False /p:CreateHardLinksForCopyLocalIfPossible=False'
${{ if eq(parameters.codeCoverage, 'false') }}:
hardLink: '/p:CreateHardLinksForCopyLocalIfPossible=True'

@matouskozak matouskozak Oct 26, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add CreateHardLinksForCopyFilesToOutputDirectoryIfPossible=True for the non code-coverage jobs since we removed it from the shared command?

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.

Code coverage build fails to instrument file in use

3 participants