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 ?>


Mihailo Lalevic said...
This comment has been removed by the author.
Mihailo Lalevic said...

I used this in our TFS Build, I don't know if it's relevant.

<WixVariables>Source_Files_Folder=\\Server\Some Folder\</WixVariables>

<SolutionToBuild Include="$(SolutionRoot)/SomeInstaller.sln">

Stanislav Dvoychenko said...

Thanks man! I guess something like this, translated to team build 2010...