Azure DevOps Sonar task only finding one TRX file

I have a Azure DevOps build that creates two TRX files for a .NET solution, one unit test for x64 and another for x86. Using the Azure task 5.* I can do the analysis on the project but the analyzer will only ever pick up one of the two TRX files and therefore doesn’t calculate the code coverage correctly. Is it not possible to have multiple TRX files discovered?

A sample run I get two TRX files (logs) as below:



When the analyzer runs it can only ever find the last file written.

Attempting to locate a test results (.trx) file…
Looking for TRX files in: E:\Builds_VNext\Agent1_Builds\142\TestResults, E:\Builds_VNext\Agent1_Builds\142\s\TestResults
The following test results files were found: E:\Builds_VNext\Agent1_Builds\142\s\TestResults\DA_NAM_TFS_BUILD_1_S011_2022-04-25_11_30_59.trx

My scan prepare task has this set:


Hey there.

The scanner should happily pick up both files and is designed to do so. Are you sure that somehow, one file isn’t overwriting the other / the test results folder isn’t being cleared between your test runs? At the very end of your analysis, do both files still exist in your TestResults folder?

Ah, didn’t think about that. Looking deeper into it, the TestResults folder is being cleared by the Azure task that runs the test, so the second task clears the TestResults before it runs. Is there a way to have the scanner look at more than one directory? The Complete SonarQube Analysis always looks in the TestResults folder (is this configurable at all?)

Yes, you can adjust your relevant sonar.cs.*.reportsPaths analysis parameter to point to multiple reports. See the documentation on Test Execution Analysis Parameters.