Monday, December 6, 2010

Override WiX variables from the team build 2010

Following the good advice from Mihailo I started to use variables in wix for pointing to files root location.
The next thing to resolve was to override those variables from the team build 2010. Here are my findings.

One can pass params in the “Run Msbuild for Project” activity via CommandLine Arguments property:

String.Format("/p:SkipInvalidConfigurations=true /p:DefineConstants=""BinPathForSetup={0}"" {1}", 
BinariesDirectory, MSBuildArguments)

When you build a solution, this activity executes on the solution actually and thus you’ll get a warning message for every c# project:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.CSharp.targets (160):
The parameter to the compiler is invalid, '/define:BinPathForSetup=xyz will be ignored.
So for now I’m just scratching my head for how to get rid of this by the most natural means….
Anyway, in order to override the value inside wxs file only when it is not defined in the team build, 
following can be used:

    <?ifndef BinPathForSetup ?>
    <?define BinPathForSetup=..\XYZ\bin\Debug\ ?>
    <?endif ?>

Post a Comment