Wednesday, July 30, 2014

TFS 2013 Pre Build Script Assembly Version Updates

I was looking at a "simple" way to update the TFS build definitions and adjust the Assembly versions of the projects being compiled. I came across this article (http://msdn.microsoft.com/en-us/library/dn376353.aspx) leveraging the pre and post build scripts that are available in the newer build definitions.

The problem I had with the scripts included in the TFS Build Extensions is that it uses the Build Number or Label. This does not really make sense to me so I started hacking at it.
Fortunately it was not as big a task as trying to delve into the new build definition's workflow and trying to find the variables that "used to" exists.

If you are interested, I have posted the resulting PowerShell.
Simply add this to the TFS repository, and then reference it as a pre-build step in your build definition and you will notice that your AssemblyVersionInfo.cs files are updated before the build, replacing the revision to the changeset number.
This will give you a reference from the actual assemblies back to the code or changeset that they originate from.



Enjoy!