SonarCloudAnalyze@3 unable to parse the .NET coverage file in Azure DevOps

  • ALM used : Azure DevOps
  • CI system used : Azure DevOps
  • Scanner command used : SonarCloudAnalyze@3
  • Languages of the repository : C# / .NET Framework 4.8
  • Context : SonarCloudAnalyze is unable to parse the coverage file (coveragexml) in my azure devops pipeline.
    The coverage file (.coveragexml) and the unit tests results (.trx file) are correctly discovered, but the it seems sonar is unable to determine the tests files (*.cs) absolute path.


  • Error observed :
Looking for TRX files in: D:\a\1\TestResults, D:\a\1\s\TestResults
The following test results files were found: D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20.trx
Absolute path to coverage file: D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coverage
The following code coverage attachments were found from the trx files: D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coverage
Not using the fallback mechanism to detect binary coverage files.
Converting coverage file 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coverage' to 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml'.
Coverage report conversion completed successfully.
10:13:03.364 DEBUG: Pattern matcher extracted prefix/absolute path 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml' from the given pattern 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml'.
10:13:03.364 DEBUG: Pattern matcher returns a single file: 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml'.
10:13:03.364 DEBUG: The current user dir is 'D:\a\1'.
10:13:03.364 INFO: Parsing the Visual Studio coverage XML report D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml
10:13:03.432 DEBUG: The file 'Facturation.ServiceWindows.Tests\FacturationContextDefinition.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.433 DEBUG: The file 'Facturation.ServiceWindows.Tests\UnitTestHelper.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.438 DEBUG: The file 'Facturation.ServiceWindows.Tests\States\ControleStatutsHelperTest.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.439 DEBUG: The file 'Facturation.ServiceWindows.Tests\helpers\CalculMontantsLigneHelperTest.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.439 DEBUG: The file 'Facturation.ServiceWindows.Tests\helpers\InformationComptableTest.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.439 DEBUG: The file 'Facturation.ServiceWindows.Tests\Fonctions\Revision\RevisionMensuelTests.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
...
10:13:03.820 DEBUG: The file '/_/src/Moq/Async/Awaitable.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.823 DEBUG: The file '/_/src/Moq/Async/AwaitableFactory.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.825 DEBUG: The file '/_/src/Moq/Async/AwaitableFactory`1.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.828 DEBUG: The file '/_/src/Moq/Async/AwaitableFactory`2.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.830 DEBUG: The file '/_/src/Moq/Async/AwaitExpression.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.833 DEBUG: The file '/_/src/Moq/Async/TaskFactory.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.835 DEBUG: The file '/_/src/Moq/Async/TaskFactory`1.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.838 DEBUG: The file '/_/src/Moq/Async/ValueTaskFactory.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.840 DEBUG: The file '/_/src/Moq/Async/ValueTaskFactory`1.cs' is not indexed or does not have the supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.850 DEBUG: The file 'D:\a\1\s\src\Facturation.Common.Infrastucture\FacturationContext.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.851 DEBUG: The file 'D:\a\1\s\src\Facturation.Common.Infrastucture\FacturationContext.StoredProcedures.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.851 DEBUG: The file 'D:\a\1\s\src\Facturation.Common.Infrastucture\Resilience\ResiliencePipelineProvider.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.852 DEBUG: The file 'D:\a\1\s\src\Facturation.Common.Infrastucture\Extensions\SqlParameterExtensions.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
10:13:03.852 DEBUG: The file 'D:\a\1\s\src\Facturation.Common.Infrastucture\EntitiesConfiguration\BudgetIndicesProjetesEntityConfiguration.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
etc
...
10:13:03.936 INFO: Adding this code coverage report to the cache for later reuse: D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20\In\fv-az619-609\VssAdministrator_fv-az619-609_2025-02-11.10_12_22.coveragexml
10:13:03.936 DEBUG: Analyzing coverage after aggregate found '0' coverage files.
10:13:03.936 DEBUG: The total number of file count statistics is '0'.
10:13:03.937 INFO: Sensor C# Tests Coverage Report Import [csharpenterprise] (done) | time=575ms
10:13:03.938 INFO: Sensor C# Unit Test Results Import [csharpenterprise]
10:13:03.939 DEBUG: Pattern matcher extracted prefix/absolute path 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20.trx' from the given pattern 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20.trx'.
10:13:03.939 DEBUG: Pattern matcher returns a single file: 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20.trx'.
10:13:03.939 INFO: Parsing the Visual Studio Test Results file 'D:\a\1\s\TestResults\VssAdministrator_fv-az619-609_2025-02-11_10_12_20.trx'.
10:13:03.943 DEBUG: Parsed Visual Studio Unit Test - testId: 77df6ef5-3186-91dc-585a-b9c518def00a outcome: Passed, duration: 219
10:13:03.944 DEBUG: Parsed Visual Studio Unit Test - testId: 77773f8e-a201-ba82-21aa-bb7f81c99f05 outcome: Passed, duration: 0
10:13:03.944 DEBUG: Parsed Visual Studio Unit Test - testId: 4d6a5944-3895-23cf-81d1-1c0cf9d7d820 outcome: Passed, duration: 0
10:13:03.945 DEBUG: Parsed Visual Studio Unit Test - testId: a9e997e5-27df-190b-50ce-4b5f99d959fb outcome: Passed, duration: 0
10:13:03.947 DEBUG: Parsed Visual Studio Unit Test - testId: fd40d99f-ecb6-984f-97bd-dde7c2a3117b outcome: Passed, duration: 16
10:13:03.947 DEBUG: Parsed Visual Studio Unit Test - testId: d6067139-eeb8-d151-c2e6-a92621fb1872 outcome: Passed, duration: 1251
10:13:03.948 DEBUG: Parsed Visual Studio Unit Test - testId: fd861b2b-d2be-4d62-732c-1233e12f43c5 outcome: Passed, duration: 0
10:13:03.948 DEBUG: Parsed Visual Studio Unit Test - testId: 4ea9224b-abb9-8cd2-83c4-5c3f1ca2a621 outcome: Passed, duration: 0
10:13:03.955 DEBUG: Parsed Visual Studio Unit Test - testId: a99f982b-287e-3cf8-0247-b10a9c5de8cc outcome: Passed, duration: 250
10:13:03.956 DEBUG: Parsed Visual Studio Unit Test - testId: d939a924-33f9-dd3e-04e5-000799175f1e outcome: Passed, duration: 16
10:13:03.956 DEBUG: Parsed Visual Studio Unit Test - testId: c9b23956-673f-6a6c-c42b-5228ef557cd9 outcome: Passed, duration: 0
10:13:03.958 DEBUG: Parsed Visual Studio Unit Test - testId: 56b723ec-3a82-0603-64c7-e86dfd95c6dc outcome: Passed, duration: 250
10:13:03.958 DEBUG: Parsed Visual Studio Unit Test - testId: 36175781-f417-4e49-b8b0-bae05b554952 outcome: Passed, duration: 47
10:13:03.958 DEBUG: Parsed Visual Studio Unit Test - testId: fcae27c3-cf08-650b-7c00-2a451d69556e outcome: Passed, duration: 0
10:13:03.959 DEBUG: Test method Facturation.ServiceWindows.Tests.Facturation.ServiceWindows.Tests.helpers.CalculMontantsLigneHelperTest.Should_CalculateSingleLineBasicScenario cannot be mapped to the test source file. The test will not be included.
10:13:03.959 DEBUG: Test method Facturation.ServiceWindows.Tests.Facturation.ServiceWindows.Tests.Fonctions.Revision.RevisionMensuelTests.GetCurrentTexteFormuleToEdit_ThrowsException cannot be mapped to the test source file. The test will not be included.
10:13:03.959 DEBUG: Test method Facturation.ServiceWindows.Tests.Facturation.ServiceWindows.Tests.States.ControleStatutsHelperTest.ControlStatutsHelper_ShouldThrowArgumentNullException_WhenStatedataIsnull cannot be mapped to the test source file. The test will not be included.
10:13:03.960 DEBUG: Test method Facturation.ServiceWindows.Tests.Facturation.ServiceWindows.Tests.helpers.InformationComptableTest.PlusProcheReleve_ShouldReturnReleveWithHigherNumber_WhenSimilarDate cannot be mapped to the test source file. The test will not be included.
10:13:03.960 DEBUG: Test method Facturation.ServiceWindows.Tests.Facturation.ServiceWindows.Tests.Fonctions.Revision.RevisionMensuelTests.GetRegexIndicesBaseToEdit_ReturnsCorrectRegExp cannot be mapped to the test source file. The test will not be included.

*Working tree

  • Potential workaround

No workaround. I’ve tried 100 different setup to make it work (including using dotnet-coverage tool instead of VSTest), no success at all.

Hey there.

Comparing all the files indexed by the scanner, and the files referenced in your coverage report, you seem to be dealing with two distinct sets of files:

The indexed files are in the projects:

  • Idefac.ServiceWindows.Process
  • Idefac.ServiceWindows.Business
  • Idefac.ServiceWindows.Domain
  • Idefac.ServiceWindows
  • Facturation.ServiceWindows.Tests
  • Idefac.ServiceWindows.Console

While when parsing your coverage report, all the files referenced in the report (covered by tests) are in the projects:

  • Moq (/_/src/Moq/…)
  • Facturation.Common.Infrastucture
  • Facturation.Common.Domain

So from here, it looks like the tests you’re running (and the coverage report generated) doesn’t match what you’re actually building.

I don’t know any more about your project, but maybe that’s a good place for you to start investigating. Are you actually testing what you’re think you’re building (and vice-versa)?

Hello,

Thank you for your response.

However, at this point, I don’t see what I can modify within the process.
I have provided almost all the elements at my disposal : CI yaml, folders and project structure, logs excerpts, csproj file of the test project…

Could you first let me know if, with these elements, it seems properly configured to push the code coverage into Sonar considering this context : .NET Framework, Azure DevOps, VSTask@3, etc ?

Thanks.

The pipeline looks correct!

But if the coverage file being produced doesn’t contain coverage for any of the files you’re building, there’s not much we can suggest :confused: Any other tool reading coverage data would face the same issue.

This is a Community where folks try to help each other. It is not a service desk where you provide all the files, and somebody works tirelessly to get you the answer. I looked at what you provided and called out what stood out to me. It may require more investigation on your part!

I highly suggest you

  • go back to your build logs and make sure what you’re building is what you’re expecting to build, and that the tests you’re running match that.
  • Double check the coverage report being produced by your tests. Does it contain the files you expect?

Hello,

Could you at least enlighten us about this error message :

The file '[...].cs' doesn't have a deterministic build path and isn't indexed or doesn't have a supported language. We'll skip this cover entry. What does “Verify sonar.sources in .sonarqube\out\sonar-project.properties

Do you have any documentation to understand the meaning and how to resolve this issue ?
Is it because .net projects are located in subfolders ( “/src” and “/tests”) ?

Note that “Moq”, “Facturation.Common.Infrastucture”, “Facturation.Common.Domain” are NuGet packages. The only sources we have in this solution are starting with Idefac.ServiceWindows and Facturation.ServiceWindows.Tests.

Also, I’ve tried to generate the coverage report with AltCover, no success either.

I’ve tried :

  • coverlet ==> KO (report always empty can’t figure out why)
  • AltCover ==> KO but report is filled, except sonar is unable to parse it correctly ?

Check out these logs for example :

17:51:58.556 DEBUG: 'Facturation.ServiceWindows.Tests/Fonctions/Revision/RevisionMensuelTests.cs' generated metadata as test with charset 'UTF-8'
17:51:58.556 DEBUG: 'Facturation.ServiceWindows.Tests\Fonctions\Revision\RevisionMensuelTests.cs' indexed as test with language 'cs'

Then…

17:52:18.108 DEBUG: The file 'Facturation.ServiceWindows.Tests\Fonctions\Revision\RevisionMensuelTests.cs' does not have a deterministic build path and is either not indexed or does not have a supported language. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
17:52:18.109 DEBUG: CoveredFile created: (ID '1021', path 'Facturation.ServiceWindows.Tests\Fonctions\Revision\RevisionMensuelTests.cs', NO INDEXED PATH).

It does not make any sense…

After making some more tests, i’m now pretty sure this issue occurs when the source files are in subfolders.

Example :

  • \rootdir
    • \src
      • \ProjectExample1
        • \fileExample.cs
        • \ProjectExample1.csproj
      • \ProjectExample2
        • \fileExample.cs
        • \ProjectExample2.csproj
    • \tests
      • \ProjectTest
        • \fileExample.cs
        • \ProjectTest.csproj

Sonar is going to index the source files with the relative path from “rootdir”, so src\ProjectExample1\fileExample.cs or tests\ProjectTest\fileExample.cs.

But the coverage report refers to ProjectExample1\fileExample.cs or ProjectTest\fileExample.cs.

Similar to the structure in this doc : Project's initial analysis scope | SonarQube Cloud Documentation

I guess many other projects use this folder structure, is it not handled natively in Sonar ?

After many many tests, I finally managed to find what the issue was.

I had a file named Directory.Build.props at the root of my sources, with this content :

<Project>
  <PropertyGroup>
    <PathMap>$(MSBuildProjectDirectory)=$(MSBuildProjectName)</PathMap>
  </PropertyGroup>
</Project>

Deleted it and now the coverage report contains correct file paths !

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.