Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX Heat.exe command parameter -var does not accept spaces?

I have this WIX command that uses all invariant paths and it doesn't need a system environment (unlike this example http://weblogs.sqlteam.com/mladenp/archive/2010/02/23/WiX-3-Tutorial-Generating-filedirectory-fragments-with-Heat.exe.aspx):

"%wix%bin\heat.exe" dir "$(SolutionDir)Web\obj\$(Configuration)\Package" 
                    -cg PACKAGEFILES -gg -g1 -sreg -srd -dr DEPLOYFOLDER 
                    -var wix.PackageSource="$(SolutionDir)Web\obj\$(Configuration)\Package"
                    -out "$(SolutionDir)WebInstaller\PackageFragment.wxs"

It works great, except on our build server where the solution path has a space in it and this error is thrown:

heat.exe error HEAT5057: The switch '-var' does not allow the spaces from the value. Please remove the spaces in from the value: wix.PackageSource=C:\Build\Builds 1\26e27895ae75b7cb\CADPortal\src\trunk\Web\obj\Debug\Package

I can't change the path and it shouldn't be necessary anyway in my opinion.

My question is: How do I solve this? (I don't even get why WIX is making trouble over a quoted path/string var with a space)

like image 841
Martin Clemens Bloch Avatar asked May 28 '13 09:05

Martin Clemens Bloch


1 Answers

To include a variable and its definition using heat, use the following mechanism.

  1. Create an include (myinclude.wxi) file where you define your variable and its value:
<?xml version="1.0" encoding="utf-8"?>
<Include> 
  <?define PackageSource="c:\somePath"?>
</Include>
  1. Create an xsl file (mytransform.xsl) for adding the <?include myinclude.wxi?> to the wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:template match="wix:Wix">
    <xsl:copy>
      <xsl:processing-instruction name="include">myInclude.wxi</xsl:processing-instruction>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <!-- Identity transform. -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
  1. Run heat and specify the -t parameter that points to the transform:

    heat.exe dir "c:\somePath" -cg PACKAGEFILES -gg -g1 -sreg -srd -dr DEPLOYFOLDER -var PackageSource -t mytransform.xsl -out PackageFragment.wxs

This will create the PackageFragment.wxs file as intended, add the include statement using the xsl transform, and use the variable value from the wxi file when compiling the msi (using candle later on).

like image 175
Dan Avatar answered Sep 29 '22 10:09

Dan