Tuesday, March 27, 2012

TFS 2010 Destroying unwanted builds

Hello World,

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 1.0.10.0 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" 1.0.10.0

Comes back with saying: No builds found for build specification '1.0.10.0'.

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 2.0.43.0 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: 1.0.10.0 and confirmed the deletion. Then the usual reset of the build number and lo: everything was hunky dory again!

Happy Coding!!

Tuesday, March 20, 2012

Rollback a changeset in TFS 2010

Hello World,

I guess each one of us has this "bad hair day" when you just can't get things right. On one such day, I checked in some code to TFS just to realise while testing that I have broken stuff! Now, I came from a background in VSS and SVN as SCM (Software Configuration Management) systems and they both had an option to "Rollback" to the previous version so you could just undo any malaise you may have caused.
I was taken aback when I did not see this option in the context menu in TFS if I right clicked a changeset upto which things were working. One of my colleagues suggested the following:
  1. Do a "Get Specific" with the changeset upto which everything was fine
  2. Checkout all affected files
  3. Resolve conflicts (there should be some)
  4. Checkin the files
You effectively overwrite your changes with the previous changeset.
Some things to note though:
  • If project and solution files were modified, you may need additional checks to ensure they have been rolled back
  • Sometimes, you may need to make some changes so that TFS detects that the files have changed (e.g. add a space at the end of a codefile
Turns out, there is another way to do a rollback through the TF commandline tool (using VS command prompt) as detailed in MSDN although, as the comments at the bottom suggest, you may need to change directory to your workspace.

Happy Coding!

Monday, March 19, 2012

ASP.NET use jQuery post for ajax

Hello World,

I came through an interesting scenario which required us to change an ASP.NET form submit to ensure that the browser does not show this message:
Entire discussion and solution on this stackoverflow link
Happy Coding

Wednesday, March 14, 2012

Baseless merge in TFS 2010

Hello World,

              I was recently involved in a major rewrite of one of our products and needed to prep a release candidate. As most organisations do, our ALM (Application Lifecycle Managemet) practices require that changes be merged all the way up to the Main branch and then a branch be derived out of that with the "Release X.x" format. (if you haven't guessed already, X is the major version and x the minor one).
So, this was a major rewrite and it had to be a baseless merge. Now as per MSDN, a baseless merge is "process of merging items that are not directly branched from each other" [MSDN]; whilst my dev branch was related all the way up to Main, the reason I decided it had to be a baseless merge is because I did not want TFS to bother about the relationship of the files in the branches. For example, if I have renamed a file, this should be viewed as a deleted file and a new file be added in the branch.
            A baseless merge also requires more manual conflict resolutions than when you perform a normal merge but I was fine with that as I required more control in liu of the extra manual work.
The way things are, basless merge can only be done through command prompt so you need to fire up the Visual studio command prompt [for the heck of it, the VS command prompt just sets some environment variables so you don't have to type the entire path to VS executables]. The details are there in the MSDN link so I'll just mention my experiences:

  1. File deletions do not always get merged up (This blog suggests that the TFS server must be SP1 or higher), so to be 100% confident, always compare the source and target branches of merge after the merge
  2. If files in the target branch are locked (e.g. binary files are locked if some other user has checked them out for edit), you can use the TFS Sidekicks tool to undo the checkout. Caveat: you should have administrator access to the team project
Happy Coding!

Saturday, March 3, 2012

Hello World,

An excellent video by Jeffery Richter (CLR via C# fame) on designing and developing multi-threaded applications using .NET 4.0 features: Here

Happy coding