If I run psake.ps1 on my continuous integration server and it doesn't result in a non-zero errorlevel somebody's going to have a false-positive at some point... In a basic test, ".\build.ps1 idontexist" the $lastexitcode was still zero. Similarly, running ".\build.cmd idontexist" is the same.
It looks like psake.psm1 is catching all throws, spitting them out in red, and setting $psake.build_success = false. This tells me that the errorlevel/$lastexitcode should be based on $psake.build_success or is an uncaught exception that should bubble out.
Hope you find this useful to the community.
Fixed errorlevel/$lastexitcode handling based on $psake.build_success…
…, so that it works consistently for psake.ps1 and psake.cmd in both PowerShell window or Command Prompt window.
This appears to have been resolved in a similar manner with another commit. If it is still an issue, please update your pull request and reopen. (Apologies for not reviewing this earlier. For some reason, I stopped getting notifications. My bad.)