Psake and robocopy failing Psake and robocopy failing powershell powershell

Psake and robocopy failing


robocopy exit codes below 8 are non-error status codes. Only exit codes of 8 and above indicate an error. See here.

The reason why your teardown task still reports an exit code of 3 is probably because the automatic variable $LastExitCode is a global variable, whereas your deploy task creates an additional local variable $lastexitcode that masks the global variable in the scope of the task. As suggested in this answer to a similar question, use the $global: prefix:

$global:LastExitCode = $null