Alex Rivera | Logout

Passing multiple values to Wix DefineConstants property with MSBuild

Asked 2009-02-03T10:50:48.817
15

I'm currently integrating my Wix projects in MSBuild. It is necessary for me to pass multiple values to the Wix project. One value will work (ProductVersion in the sample below).

<Target Name="BuildWixSetups">
    <MSBuild Condition="'%(WixSetups.Identity)'!=''"
                Projects="%(WixSetups.Identity)"
                Targets="Rebuild" Properties="Configuration=Release;OutputPath=$(OutDir);DefineConstants=ProductVersion=%(WixSetups.ISVersion)" ContinueOnError="true"/>
</Target>

However, how do I pass multiple values to the DefineConstants key? I've tried all the 'logical' separators (space, comma, semi-colon, pipe-symbol), but this doesn't work.

Has someone else come across this problem?

Solutions that don't work:

  1. Trying to add a DefineConstants element does not work because DefineConstants needs to be expressed within the Properties attribute.
Edit
Report

1 Answer

5

I still had a lot of trouble getting this to work, but peices of each answer above, contributed to my solution, so I wanted to share.

Environment: TFS Build Server 2010 - Powershell calling MSBuild.exe Wix 3.6 is installed on the build server

Goal is to pass the build version number and 5 directories into MSBuild, so that Candle.exe will receive them correctly

The Build calls a command file at the end of the build, and that command file, includes a step to call a powershell script to build the Wix installer. It passes in the version number for the build and the source and output directories (the output is a UNC fileshare reference \tfsbuildserver..)

To get it to work, in the Powershell ps1 file,

  • use a single /p:DefineConstants= that starts with a double "
  • encode all the seperating ; as %3b
  • the = are ok unencoded
  • there should be no additional quotes around any file names with spaces

    $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
    
    $options = " /p:Configuration=Release /p:Platform=x64 "
    $options = $options + " /p:DefineConstants="""
    $options = $options + "SolutionDir=" + $SourceDir
    $options = $options + "%3bTFSBuildSourceLanding=" + $OutputLocation + "SharepointWebRoot\Landing"
    $options = $options + "%3bTFSBuildSourceLandingAdmin=" + $OutputLocation + "SharepointWebRoot\LandingAdmin"
    $options = $options + "%3bTFSBuildSourceRegistration=" + $OutputLocation + "Extranet_Registration"
    $options = $options + "%3bTFSBuildSourceGAC=" + $OutputLocation + "GAC"
    $options = $options + "%3bTFSBuildSourceSQL=" + $OutputLocation + "SQL"
    $options = $options + "%3bProductVersion=" + $BuildVersion + """" 
    
    
    $build = $msbuild + " ""EUM WIX\EUM Wix.wixproj"" " + $options + " /t:Build"
    $clean = $msbuild + " ""EUM WIX\EUM Wix.wixproj"" " + $options + " /t:Clean"
    
    
    Write-Host "Building Wix Installer..."
    Invoke-Expression $clean
    Invoke-Expression $build
    
    answered 2012-08-30T15:13:39.737

Your Answer