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 one of our projects. Visual Studio would build the solution successfully on our development machines and our integration machine, but the TFS build script failed when compiled on our build server.
Long story short, we should ALWAYS be using project references or referencing dll’s out of our /lib/ folder, and I shouldn’t write my build scripts to deploy to our web servers if the compile fails.
I found this answer on MSDN forums that sets a property called BuildFailed to true if the compilation fails and makes that a condition of the build scripts AfterDropBuild target.
<Target Name="BeforeOnBuildBreak"> <CreateProperty Value="true"> <Output TaskParameter="Value" PropertyName="BuildFailed" /> </CreateProperty> </Target> <Target Name="AfterDropBuild" Condition=" '$(BuildFailed)'!='true' "> <!-- Deploy your files here --> </Target>
Now all I have to do is modify and test 15 build scripts on 7 different TFS projects to ensure this never happens again. Sigh.




