Suffering from the same symptoms when running directly from the console. this is my powershell hack/fix. configure sonar with x report pairs -> testresults0.trx & coverage0.coveragexml
Param([string]$projectDir)
$coverageExe = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe"
function makeFilePathsRelative {
param([string]$filePath, [string]$find,[string]$replace)
$tempFilePath = "$env:TEMP\"+([System.GUID]::NewGuid().ToString())
(Get-Content -Path $filePath) -replace [regex]::escape($find), [regex]::escape($replace) | Add-Content -Path $tempFilePath
Remove-Item -Path $filePath
Move-Item -Path $tempFilePath -Destination $filePath
}
function prepareTrx {
Param([string]$projectDir)
Set-Location $projectDir
$trxReports = get-childitem -path "." -Recurse -Filter *.trx
$count = $trxReports.Length; #bug
$projectDir = (Get-Item -Path ".\").FullName + '\'
$id = 0
foreach($trxReport in $trxReports)
{
#makeFilePathsRelative $outFile $projectDir ""
$outFile = $projectDir+"TestResults"+($id++)+".trx"
Copy-Item -Recurse -Path $trxReport.FullName -Destination $outfile
makeFilePathsRelative $outFile '/href=\"([^\"]*)/g' 'href=Coverage"'+ $id +".xml"
}
$coverageReports = get-childitem -path "." -Recurse -Filter *.coverage
$id = 0
foreach($coverageReport in $coverageReports)
{
#makeFilePathsRelative $outFile $projectDir ""
$outFile = $projectDir+"Coverage"+($id++)+".coveragexml"
Write-Host $coverageExe "analyze" "/output:"+$outFile $coverageReport.FullName;
$params = @(
"analyze"
"/output:"+$outFile
$coverageReport.FullName
)
&$coverageExe $params
}
}