In this post, I show how I’ve managed to integrate WiX into my NAnt build scripts while retaining consistency of versioning.
In most build scenarios, the build script is in charge of versioning. For example, the following NAnt target updates the master build number for a system, leaving the result in the property build.version.
Once this target has executed, the next step is to inject the version number into our assemblies and our installers. For .NET assemblies, NAnt has a very useful <asminfo> task which can be used generate source files for C# and Visual Basic that contain the version number.
To achieve the same results for our WiX files, the <echo> task comes to the fore.
The first <echo> statement overwrites any existing version.wxs file, and the following two <echo> statements append additional lines. If you decipher all the XML encoding, you’ll see that the output file will look something like this:
With this version file in place, the version can be pulled into the main WXS file with an include directive.
The last step is to refer to the version number where required, replacing the hard coded values. As a minimum, replace the Version attribute on the Product element.
The version number can also injected into the filename of the final MSI, as can be seen in this build fragment.
One catch to be aware of is that changing the name of the MSI file requires that each newer version of the installer be a major upgrade. If you want to perform minor updates or patches with your MSIs, the name of the MSI must remain unchanged.
Comments
blog comments powered by Disqus