Skip to content

[BUG] Includes reports for temporary (?) build files in coverage.cobertura.xml #1763

@ruffin-bailey-fhr

Description

@ruffin-bailey-fhr

Describe the bug

When running dotnet test with "XPlat Code Coverage" one project is including temporary (or non-existent?), assumedly build-related files in the cobertura report.

When a coverage report is created (fully aware this is another tool; this is simply how I found the issue), many lines of errors like this are reported:

2025-07-25T16:10:02: File 'C:\build\_work\138\s\src\ACME.Common\Code\Attributes\AuditField.cs' does not exist (any more).

Note that ACME.Common is an in-project reference for the project being tested.

To Reproduce

Going to be hard to reproduce exactly without access to our project, but here's how I reproduce locally.

Run from the home folder of the test project's csproj file (C:\OurAppPath\ACME.OurSolution\tests\ACME.Diagnostics.Tests):

dotnet test --settings:..\tests.runsettings `
        --collect:"XPlat Code Coverage" `
        -- RunConfiguration.DisableAppDomain=true

tests.runsettings content (located in parent tests folder):

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
 <DataCollectionRunSettings>
     <DataCollectors>
         <DataCollector friendlyName="XPlat code coverage">
             <Configuration>
                 <Format>cobertura,opencover</Format>
                 <Exclude>**build**</Exclude>
             </Configuration>
         </DataCollector>
     </DataCollectors>
 </DataCollectionRunSettings>
</RunSettings>

Expected behavior

Reports only on the files in the solution.

Actual behavior

Returns results from temporary or non-existant files outside of the solution.

<?xml version="1.0" encoding="utf-8"?>
<coverage line-rate="0.4432" branch-rate="0.3178" version="1.9" timestamp="1753468984" lines-covered="535" lines-valid="1207" branches-covered="191" branches-valid="601">
    <sources>
        <source>C:\</source>
    </sources>
    <packages>
        <package name="ACME.Common" line-rate="0.1638" branch-rate="0.1173" complexity="597">
            <classes>
                <class name="System.StringHelper" filename="build\_work\138\s\src\ACME.Common\Code\StringHelper.cs" line-rate="0" branch-rate="0" complexity="22">

<!-- and it continues. That's the first one -->

Again, note that ACME.Common is an in-project reference for the project being tested.

Configuration (please complete the following information):

Please provide more information on your .NET configuration:

  • Which coverlet package and version was used?
    • coverlet --version
      • 6.0.4.1+90b21079d4
  • Which version of .NET is the code running on?
    • Testing project: .NET Framework 4.7
    • Project under test: .NET Framework 4.0
  • What OS and version, and what distro if applicable?
    • Edition Windows 11 Enterprise
    • Version 23H2
    • OS build 22631.5472
    • Experience Windows Feature Experience Pack 1000.22700.1106.0
  • What is the architecture (x64, x86, ARM, ARM64)?
    • x64
  • Do you know whether it is specific to that configuration?
    • Which configuration? Windows 11 (& associated stack) or this project's configuration?
      • If the latter, it does not add these files to another set of tests, though those test & tested projects does not reference ACME.Common, a Project reference.
      • If the former, I am unable to test on another operating system.

Additional context

[X] ❗ Please also read Known Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedTo be investigated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions