From 932fd8e4234aad97eb612831c6bd25bf42796645 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Thu, 5 Mar 2020 21:14:15 +0100 Subject: [PATCH] (GH-64) Report Error based on exit code * Fixes #64 --- Task/Cake.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Task/Cake.ps1 b/Task/Cake.ps1 index c4e7ad9..da9be57 100644 --- a/Task/Cake.ps1 +++ b/Task/Cake.ps1 @@ -99,6 +99,12 @@ if (!(Test-Path $CakePath)) { Throw "Could not find Cake.exe at $CakePath"; } +# Continue on error tool exit code determins result +$global:ErrorActionPreference = 'Continue' + # Start Cake Write-Host "Executing build script..."; Invoke-VstsTool -FileName $CakePath -Arguments "`"$Script`" -target=`"$Target`" -verbosity=`"$Verbosity`" --paths_tools=`"$ToolPath`" $Arguments" -RequireExitCodeZero; +if ($LASTEXITCODE -ne 0) { + Write-VstsSetResult -Result Failed -DoNotThrow +} \ No newline at end of file