Monday, April 25, 2011

How can I set the WiX installer version to the curent build version?

Hi All,

I wrote an application and its WiX installer and put it under version control using subversion. When the WiX installer builds I want its version number to be the current build version of the application. How do I accomplish this? I used c# to code the application.

N.B. I am using ccnet to build this project

From stackoverflow
  • This looks reasonably close to what you are trying to accomplish. See what the equivalent is in cruise control.

    http://www.ageektrapped.com/blog/setting-properties-for-wix-in-msbuild/

  • You could use Product/@Version="!(bind.FileVersion.FileId)" and light.exe will populate the value with the version of the file referenced by the FileId.

    Nicholas Piasecki : Just what I was looking for! Although I had to use "!(bind.FileVersion.FileId)" (a "!" instead of "$"), otherwise I got a preprocessor directive error.
    Rob Mensching : Yeah, sorry, constant mental mistake I make. $ is preprocessor variable and ! is binder variable.
  • I did this in one of my projects by writing a preprocessor extension to read the file version from my executable. So the WiX file looks 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>">
    

    I've posted the code for in on CodePlex: http://wixfileversionext.codeplex.com/

0 comments:

Post a Comment