Project Description
This is a WiX preprocessor extension that can read the version resources of any file into variables.

Summary
While working on a WiX installer for one of my projects I wanted to automatically set the product version based on the version of my executable. After searching the web I found a few solutions (setting an environment variable, using a PowerShell script to edit the wxs file) but they all felt like hacks to me.

I decided to write a WiX preprocessor extension that could read the version number out of my executable as the installer was complied.

The extension supports reading any property in the .NET FileVersionInfo class. This allows a WiX install to automatically read the version information using something like:

    <?define ProductName="$(fileVersion.ProductName($(var.MyApp.TargetPath)))" ?>
    <?define CompanyName="$(fileVersion.CompanyName($(var.MyApp.TargetPath)))" ?>
    <?define ProductVersion="$(fileVersion.ProductVersion($(var.MyApp.TargetPath)))" ?>

    <Product 
        Id="<product ID>" 
        Name="$(var.ProductName)" 
        Version="$(var.ProductVersion)" 
        Manufacturer="$(var.CompanyName)" 
        Language="1033" 
        UpgradeCode="<upgrade code>">

Requirements

Windows Installer XML (WiX) 3.0 http://wix.sourceforge.net/

Last edited Mar 13, 2009 at 1:55 PM by ckaczor, version 8