20

I'm trying to create an installer with a UI, using WiX.

My INSTALLFOLDER is set up using this:

<Directory Id="TARGETDIR"
           Name="SourceDir">
  <Directory Id="ProgramFiles64Folder">
    <Directory Id="ManufacturerFolder"
               Name="[Manufacturer]">
      <Directory Id="INSTALLFOLDER"
                 Name="[ProductName]" />
    </Directory>
  </Directory>
</Directory>

In the <Product> section, I'm defining:

<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />

<Property Id="WIXUI_INSTALLDIR"
          Value="INSTALLFOLDER" />

When I run the installer and get to the Destination Folder panel, I see:

Install Service to: 
C:\Program Files\[Manufacturer]\[ProductName]\

How can I make it evaluate the variables for display?

Note: if I leave them, and click Next, Install and Finish it works. It just looks bad.

serialhobbyist
  • 4,768
  • 5
  • 43
  • 65

2 Answers2

43

Binder variables can make this very easy without needing to mess around defining preprocessor variables. It'd go a lot like this:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFiles64Folder">
    <Directory Id="ManufacturerFolder" Name="!(bind.property.Manufacturer)">
      <Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
    </Directory>
  </Directory>
</Directory>

The !(bind.) syntax is documented in the Linker (light) topic in WiX.chm.

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • 2
    It doesn't appear that this works when an instance transform is applied -- I still get the default ProductName when installing a different instance. – arathorn May 21 '14 at 19:44
  • @arathorn Have you got solution for Instance Transform? I have similar issue and get default product name when i applied instance transform. – chex Aug 09 '18 at 04:59
  • Sadly for me this just spits out the string value "!(bind.property.Manufacturer)" when assigned to Product/@Manufacturer – Reahreic Feb 11 '21 at 18:43
11

Define your variables in a config file.

For example, create a file named config.wxi containing the following:

<?xml version="1.0" encoding="utf-8"?>
  <Include>
    <?define Manufacturer = "Company Name" ?>
    <?define ProductName = "Product Name" ?>
  </Include>

Then reference the variables in your .wxs file using $(var.Manufacturer) and $(var.ProductName).

BryanJ
  • 8,485
  • 1
  • 42
  • 61