2

I am running the following command:

heat.exe dir bin\Release -sfrag -sreg -var var.sourcebin -dr myappfolder -cg myapp_comp_group

This generates a nice wxs file that looks a bit like this:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <ComponentGroup Id="myapp_comp_group">
      <ComponentRef Id="cmpE519314043C2FFE1104E067D33CBC652" />
      <ComponentRef Id="cmp0431CFEC47E793CE59C185A8BDD9D865" />
    </ComponentGroup>
  </Fragment>
  <Fragment>
    <DirectoryRef Id="myappfolder">
      <Directory Id="dir4ADCEBD4F8C9DC384017088D96B7A1C3" Name="somebinfolder">
        <Component Id="cmpE519314043C2FFE1104E067D33CBC652" Guid="EB84C1A8-7BF5-4967-878D-8DAD9DFFA0A6">
          <File Id="filD8C8D39058B0FF5C9608B1F99B0CD5BA" KeyPath="yes" Source="$(var.sourcebin)\app.config" />
        </Component>
      </Directory>
    </DirectoryRef>
  </Fragment>
</Wix>

I am using this by heat generated wxs file in my project, but I get an error, because the $(var.sourcebin) has not been set.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define sourcebin="C:\svn\myapp\bin\Release"?>

  <!-- leaving some stuff out of course -->
  <Module>
    <ComponentGroupRef Id="myapp_comp_group"/>
  </Module>
</Wix>

error CNDL0150: Undefined preprocessor variable '$(var.sourcebin)'.

How do I define this variable so it is picked up by the heat generated file? I don't want to change the heat generated file manually, because it is re-generated every time.

Marnix
  • 6,384
  • 4
  • 43
  • 78

1 Answers1

2

Open project Properties, Choose Build tab and add preprocessor variable as needed.

sourcebin="C:\svn\myapp\bin\Release";

In the define section use:

<?define sourcebin = $(var.sourcebin)?> 

Heat command you can leave as it is.

This will be the same when you will need to pass variables from msbuild (Wixproj file) to other files in your project(wxs,wxi...). Common use when using TFS.

Arkady Sitnitsky
  • 1,846
  • 11
  • 22
  • I can find the preprocessor variable on the build tab, but I can't find the "define" section. Would you elaborate on where that is located? – Daedalus Oct 31 '17 at 14:14