Wix Product Version with Build Script
Our projects are deployed with MSIs. Each MSI file is appended with the product version number (regular staff – major, minor, build number, revision number).
While this is enough for deployment, in production, it is hard to determine what product version is installed without either searching for assemblies to see the version, or some other piece of evidence. Today I decided to leverage Wix to generate the Product Version number, based on our NAnt script.
Nant script has all parts of product version defined as follow:
1: <property name="version.major" value="1" />2: <property name="version.minor" value="7" />3: <property name="build.number" value="0" readonly="false"/>4: <property name="svn.revision" value="0" readonly="false"/>5:6: <property name="project.version.full"7: value="${version.major}.${version.minor}.${build.number}.${svn.revision}"8: dynamic="true" readonly="false" />
Next step was updating Wix installer project file to include an external include file with a defined variable for product version, called ProductVersion, and apply that to project. Here’s partial Wix installer file:
1: <?xml version="1.0" encoding="UTF-8"?>2: <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">3:4: <?define build_dir = "$(var.ProjectDir)..\..\build\compile"?>5: <?define documentation_dir = "$(var.ProjectDir)..\..\docs"?>6:7: <?include $(var.build_dir)\ProductVersion.wxi ?>8:9: <Product Id="5646ced5-d897-4978-b1d6-338e5baadbe9"10: Name="COMPANY NAME $(var.ProductVersion)"11: Language="1033"12: Version="$(var.ProductVersion)"13: Manufacturer="COMPANY NAME"14: UpgradeCode="790b1905-c843-4973-a078-79874a7f30f2">15:
Include file, ProductVersion.wxi is the one that should contain variable ProductVersion. This include is generated by nant script, injecting nant project.version.full variable.
Nant script to generate Wix include file:
<echo file="${build.compile.dir}\ProductVersion.wxi" message='<?xml version="1.0" encoding="utf-8"?>

<Include>

<?define ProductVersion="${project.version.full}"?>

</Include>' />
Which results in a file, that contains the required product version variable for Wix installer:
<?xml version="1.0" encoding="utf-8"?><Include><?define ProductVersion="1.7.1234.4321"?></Include>
Once MSI is installed, Add/Remove programs contains the name with the version: