Blog Home  Home Feed your aggregator (RSS 2.0)  
.Net Jonesie - Unified Version Numbering for Projects and Installers
A simple programmers blog
 
# Friday, June 10, 2011

Having a single unified version number across all assemblies in a product has always been an issue for me and I suspect many others.  For some reason, this has been a lot harder to achieve than it should.  I suspect the reason has been more to do with me than the tools…

Anywho, this morning I managed to solve the problem for our product and the new WIX based installer.  Here’s the steps I used.

Create AssemblyInfo files for the Company and Version.  I created a CompanyAsseblyInfo.cs file that looks like this:

using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyCompany("ARANZ Medical Limited")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

And a VersionAssemblyInfo.cs file that looks like this:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("3.0.*")]
#if PocketPC || WindowsCE
#else
[assembly: AssemblyFileVersion("3.0")]
#endif

I added these to a solution folder.

In each published project in the solution I add these files as a link:

image

Then I removed the duplicated entries from the project’s default AssemblyInfo.cs file.

Now I have a single file containing the version number and company information. 

WIX doesn’t used these files of course, but that’s not a problem thanks to a nifty WIX Extension I found on CodePlex.  Simply reference this dll in your WIX project and update your Product.wxs file like this:

image

Now whenever I do a build – either locally or on our build server – all the assemblies and the installer will have the same internal version number.  No need to futz around with MSBuild or CruiseControl tasks.  Of course, I still need to manage the version number manually for major upgrades but our daily builds in a sprint or iteration will be automatically incremented.

Enjoy!

Update: So it turns out the Visual Studio and MSBuild too I guess, do not do a very good job of incrementing the build and revision numbers automatically.  Some of the assemblies in the solution were being generated with a version number of 3.0.0.0 despite the AssemblyVersionNumber being 3.0.*.  To get around this required some work in CruiseControl.

Firstly, I created a VersionNumber.proj file in the solution that looks like this:

image

This uses the MSBuild Community Tasks for it’s Version and FileUpdate tasks.

Next, I updated the CruiseControl config to use MSBuild to execute this script prior to building the solution:

image

Lastly, I installed MSBuild Community tasks to the build server and restarted CruiseControl.  For some reason it was not able to find the .targets file in the MSBuild directory to I copied this to the working folder also.

This is such a drag, but at least it now works and I still have a single place to update the version number.

Friday, June 10, 2011 10:07:57 AM (New Zealand Standard Time, UTC+12:00)  #    Comments [0]   General  | 
Comments are closed.
Copyright © 2012 Peter G Jones. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: