Preventing Team Build From Deploying Files After a Failed Build

I just finished debugging an issue with one of my teams build scripts in TFS where all the files and folders on our dev and qa websites were deleted after the build failed to compile. The issue was that someone had changed a project reference to a DLL reference out of the /bin/debug/ folder of [...]