From f8e13868c8d9c3428b738206acbdcbe196ca7564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Thu, 15 Dec 2022 15:38:10 +0100 Subject: [PATCH] Update tools.ps1/tools.sh to avoid hiding errored exit codes --- eng/common/tools.ps1 | 3 ++- eng/common/tools.sh | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index aba6308ad..2e0a77c62 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -814,7 +814,8 @@ function MSBuild-Core() { Write-Host "See log: $buildLog" -ForegroundColor DarkGray } - if ($ci) { + # When running on Azure Pipelines, override the returned exit code to avoid double logging. + if ($ci -and $env:BUILD_BUILDNUMBER -ne $null) { Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error diff --git a/eng/common/tools.sh b/eng/common/tools.sh index c110d0ed4..2cd597009 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -479,7 +479,9 @@ function MSBuild-Core { # We should not Write-PipelineTaskError here because that message shows up in the build summary # The build already logged an error, that's the reason it failed. Producing an error here only adds noise. echo "Build failed with exit code $exit_code. Check errors above." - if [[ "$ci" == "true" ]]; then + + # When running on Azure Pipelines, override the returned exit code to avoid double logging. + if [[ "$ci" == "true" && -n ${BUILD_BUILDNUMBER:-} ]]; then Write-PipelineSetResult -result "Failed" -message "msbuild execution failed." # Exiting with an exit code causes the azure pipelines task to log yet another "noise" error # The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error