If you’ve worked with TFS builds for any length of time, you would’ve surely had days when the build just would not do what it is supposed to do: build stuff!!
We had this issue the other day when tfs build was stuck and some of my builds did not complete, yet the version numbers got incremented. Now what I wanted is to delete those “bad” builds, reset the build number and then fire a build that would get me the expected build number. I fired up my build explorer for the build definition in question and then clicked on “Delete Build”:
Next, reset the version number in the build configuration folder and queued up a new build. To my horror, TFS came back with this:
Build Failed: version 22.214.171.124 already exists!
So, I turned to the trusted Visual Studio command prompt to look up the TFSbuild tool’s destroy command. MSDN describes this in detail. Unfortunately, the following command:
TFSBuild destroy /collection:http://tfs:8080/tfs/defaultcollection /BuildDefinition:”\Team Project\My Shiny Product” 126.96.36.199
Comes back with saying: No builds found for build specification ‘188.8.131.52’.
I tried the /daterange switch then:
TFSBuild destroy /collection:http://tfs:8080/tfs/defaultcollection /BuildDefinition:”\Team Project\My Shiny Product” /daterange:~2012-03-27
Note that this would come back with a confirmation for each build for the team project in the date range, something similar to:
Destroy build record for MyShinyProduct Production 184.108.40.206 permanently? (Yes/No/All)
Be very careful at what you respond ’cause you obviously do not want to delete somthing required!
I found the one I was interested in: 220.127.116.11 and confirmed the deletion. Then the usual reset of the build number and lo: everything was hunky dory again!