Skip to content

Commit e89b097

Browse files
committed
Update tools.ps1/tools.sh to avoid hiding errored exit codes
1 parent 1fc5cf6 commit e89b097

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

eng/common/tools.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,8 @@ function MSBuild-Core() {
814814
Write-Host "See log: $buildLog" -ForegroundColor DarkGray
815815
}
816816

817-
if ($ci) {
817+
# When running on Azure Pipelines, override the returned exit code to avoid double logging.
818+
if ($ci -and $env:BUILD_BUILDNUMBER -ne $null) {
818819
Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed."
819820
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
820821
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error

eng/common/tools.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ function MSBuild-Core {
479479
# We should not Write-PipelineTaskError here because that message shows up in the build summary
480480
# The build already logged an error, that's the reason it failed. Producing an error here only adds noise.
481481
echo "Build failed with exit code $exit_code. Check errors above."
482-
if [[ "$ci" == "true" ]]; then
482+
483+
# When running on Azure Pipelines, override the returned exit code to avoid double logging.
484+
if [[ "$ci" == "true" && -n ${BUILD_BUILDNUMBER:-} ]]; then
483485
Write-PipelineSetResult -result "Failed" -message "msbuild execution failed."
484486
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
485487
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error

0 commit comments

Comments
 (0)