diff --git a/build.psm1 b/build.psm1 index c61750c9ec..4932eab761 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1230,7 +1230,13 @@ function Publish-TestResults $_ -replace 'result="Ignored"', 'result="Skipped"' } | Out-File -FilePath $tempFilePath -Encoding ascii -Force - Write-Host "##vso[results.publish type=$Type;mergeResults=true;runTitle=$Title;publishRunAttachments=true;resultFiles=$tempFilePath;]" + # If we attempt to upload a result file which has no test cases in it, then vsts will produce a warning + # so check to be sure we actually have a result file that contains test cases to upload. + # If the the "test-case" count is greater than 0, then we have results. + # Regardless, we want to upload this as an artifact, so this logic doesn't pertain to that. + if ( @(([xml](Get-Content $Path)).SelectNodes(".//test-case")).Count -gt 0 -or $Type -eq 'XUnit' ) { + Write-Host "##vso[results.publish type=$Type;mergeResults=true;runTitle=$Title;publishRunAttachments=true;resultFiles=$tempFilePath;]" + } $resolvedPath = (Resolve-Path -Path $Path).ProviderPath Write-Host "##vso[artifact.upload containerfolder=testResults;artifactname=testResults]$resolvedPath"