I'm new to TeamCity so forgive me if I'm missing something. We use psake, a powershell build tool similar in function to NAnt, I've noticed that even when my PowerShell script fails the TeamCity build succeeds. I think this could be because the command TeamCity creates to run my powershell script uses this at the end: && exit /B %ERRORLEVEL%. The && tells the windows command interpreter to run the next statement when the previous statement doesn't raise an error. It seems to me that "& exit /B %ERRORLEVEL%" is what's actually wanted here. This will ensure that the "exit" command always runs setting the exit code to the ERRORLEVEL set by the powershell script.
Is this valid analysis or am I doing something wrong?