The VSTest@2 output shows that a trx file is generated. But then its added to the run attachments and very quickly i see the file is cleared up before the build then gets to the Sonarcloud analyze step.
“Adding trx file C:*_temp\TestResults*.trx to run attachments” (replaced folder name and file name with * where its identifiable account info)
Can you share your pipeline configuration as well as the logs (in debug mode) of the Run Code Analysis task please ? (you can activate the debug mode by adding the system.debug=true pipeline variable)
I’ll look to try and get this for you. As this is a private project I do wonder if some of the log output might be sensitive, is there a better way for me to share this with you without it being on a public forum?
I’ve worked out why this happened and resolved the issue.
VSTest@2 was definitely deleting the trx file but this was due to using batching of unit tests (something that needs to be set for incremental test discovery) like: batchingBasedOnAgentsOption: 'customBatchSize' customBatchSizeValue: '1000'
This is due to the pipeline being used in 2 modes, 1 for quicker builds (using test discovery), 1 for longer builds which runs all tests and also now runs sonar.
The batching isnt needed for non-test discovery mode so I’ve removed that from the mode that runs sonar and now it can successfully pick up on the trx files.