Build fails or behaves differently in TeamCity but not locally
If a build fails build fails or otherwise misbehaves in TeamCity but you believe it should not, please check that the follow these procedure:
Find a way to do the task from a command prompt. Make sure it works on the TeamCity agent machine, under the same user TeamCity agent runs under, with the same environment the agent receives. If necessary, run the TeamCity agent under a different user or tweak it's environment. When the command runs OK, configure the same command in a TeamCity build using a command-line runner with the custom script setting. If that works, try other runner if that feels applicable.
Here are details on the approach:
Check that the build runs fine from the command prompt when run on the same machine as the TeamCity agent and under the same user that the agent is running, with the same environment variables and the same working directory, same architecture (32/64 bit) command line.