Wix and Team Build – Passing Variables

Published on December 29, 2006

Just in case anyone else is trying to crack this nut, this info should save a bit of time.

I was trying to pass in the product version number from the team build project (TFS with wix.targets) to dynamically update the ProductVersion in the MSI file generated by Wix.  Here is what I discovered:

 

Build.proj

<PropertyGroup>  <OutputName>TM21</OutputName>  <OutputType>package</OutputType>  <DefineConstants>MyVersion=1.0.0.101</DefineConstants>  <WixToolPath>C:binwixwix-3.0.2015.0-binaries</WixToolPath></PropertyGroup>

Product.wxs

<Product Id="{80848DC4-CE85-481d-AE4E-D08CEFE906ED}" Name="Tavis Manufacturing 2.1W" Language="1033" Version="$(var.MyVersion)" Manufacturer="Tavis Software Inc." UpgradeCode="{0A1C26BF-6C29-4be5-A820-CE61203F94FA}">

 

Ok, so who decided to call the property "DefineConstants"?  It is just sooooo intuitive that you need to "DefineConstants" so that you can access the "variables" from within wxs file.  Anyway, it's really not a big problem once you know how :-)