I have got a Team Foundation Server Build running cleanly. It produces several assemblies and I would like the assemblies versions to have the last number to be the changset number. That is, if I commit with a changeset11667 for example the assembly version number should be "x.y.z.11667". I've checked the availible macros, but none is the changeset number.
I would still like to be able to build the solution file on my dev machine as normal, just using the checked in version number.
How would I go about getting this in place?
In the end a colleague of mine wrote the following MSBuild task that solved the problem.
I am working on a tool to automate the build process it is still on development and it's open source here is the link (I am planning a release in about one week):
https://github.com/jupaol/NCastor
Now I would recommend you to check the Semantic versioning:
http://semver.org/
To get the latest changeset from TFS, you have several options:
I built a custom routine to do this
https://github.com/jupaol/NCastor/blob/develop/Solutions/NCastor.AutoBuilder/NCastor.AutoBuilder.Runner/Targets/Build/Versioning/VersionControlServers/TFS/GetTFSRevisionVersion.target
I had to build that routine because the Community tasks and the MSBuild Extenssions tasks were not working on a 64bits machine, if you are using a 32bits machine to build then you can use the following tasks:
Using http://msbuildextensionpack.codeplex.com/
Using http://msbuildtasks.tigris.org/
Example to set the different versions:
Once you have created the file simply add that file as a link to each project and voila! all your projects are sharing the common assembly info.
Have a look at the Community TFS Build Extension project on CodePlex. It contains an AssemblyInfo activity and the TfsVersion activity that are capable of changing the assembly info during the build process using a custom format.
To have it build on your dev machine you have to implement those build extensions on your own using batch files and the TFS command line utilities.
For what purpose are you wanted to do that ? If you want to have a relation between a DLL and the source code to pull from TFS the best way is to index the symbols using TFS Source Control in the PDB generation. This way when you debug any version of your software Visual Studio will get the right version of the source from TFS when needed.
Realize that this will stop working once you exceed 65,535 changesets. Perhaps you want to update some other field. BTW, yes, build engineering is engineering. Pointing at a solution and telling it to build is only the beginning of the journey.