Robocopy will exit with a code above 0 and still possibly not be a failure. PSake detects anything above 0 as a failure and fails the build. This is fine, but how come this still fails:
task Deploy {
robocopy $source $dest /NP /S /XO /NFL /NDL /NJH /NJS | Out-Default
if ($lastexitcode -eq 3)
{
Write-Host "Got Here"
$lastexitcode = 0
}
Write-Host "Deploy local complete"
Write-Host $lastexitcode
}
TaskTearDown {
if ($LastExitCode -ne 0) {
write-host "Build failed"
exit 1
}
}
I can verify that the Deploy if statement is hit and the Write-Host outputs 0, correctly, yet the TaskTearDown still detects the last exit code as 3! How do I fix this?
$lastexitcode
, it's an automatic variable. Assignment perhaps creates a local variable andTaskTearDown
still sees the original. In any case try to use a different approach without$lastexitcode = 0
. – Proselytize