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)
For this cases you can define a prepocessor variable in the Build section of the project properties, in your case
PackageSource=Web\obj\$(Configuration)\Package
and reference in the heat call like
So I ended up coding some build event code that inserts the necessary definition into the Heat generated file at the top, but under the starting WIX tag. Personally I'm starting to question the power of WIX if you need to do this kind of shenanigans/hacks.
Anyway this is my full build event code for anyone that needs it. (It also finds an invariant path for MSBuild.exe and creates a web package.)
The
-var
switch provides the name of a preprocessor variable. Something likevar.Foo
. Preprocessor variable names cannot contain spaces in them. The valuewix.PackageSource=Whatever SolutionDir Expands To\Web\obj\Whatever Configuration Expands To\Package
is not a valid name for a preprocessor variable because it has spaces in it. I expect the backslashes will be a problem as well.To include a variable and its definition using heat, use the following mechanism.
<?include myinclude.wxi?>
to the wxs file: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).