wix 3 installer: Unresolved bind-time variable !(bind.fileVersion.Name.exe)

6.8k Views Asked by At

I'm trying to use the binding "bind.fileVersion" from Wix3. (ie: 3.11.1)

For some me reason, I get the following error message:

Unresolved bind-time variable !(bind.fileVersion.TestWix3.exe).

My goal is to fill the 'Product Id' line. Especially the Version="$(var.VERSION)" information.

Here's the content of my "Product.wxs" file:

<?xml version="1.0" encoding="UTF-8"?>

<?define LongName = "Test wix 3" ?>    
<?define Manufacturer = "Test" ?>
<?define ProductUpgradeCode = "5fc3e435-fad3-4c1d-997f-3483beffe0a4" ?>

<?define MAINEXE=$(var.TestWix3.TargetFileName)?>
<?define VERSION="!(bind.fileVersion.$(var.MAINEXE))"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="*" Name="$(var.LongName)" Language="1036" Codepage="1252" Version="$(var.VERSION)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.ProductUpgradeCode)">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="Wix3Installer" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="Wix3Installer" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
                <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->     
        </ComponentGroup>
    </Fragment>
</Wix>

Here is the screenshot of my solution in VS2017 Community. enter image description here

Here is the error: enter image description here

Any idea why the binding of (bind.fileVersion) does not work ?

4

There are 4 best solutions below

3
Brian Sutherland On BEST ANSWER

The FileId part of the bind variable is representing the <File Id="..."> Id. ie:

!(bind.fileVersion.TestWix3.exe)

...

<Component Id="MainProduct">
    <File Id="TestWix3.exe" KeyPath="yes" Source="$(var.TestWix3.TargetPath)"/>
    ... other stuff maybe ...
</Component>

Currently your component and file definitions are TODO so you can't use this type of bind variable yet.

1
Bob Arnson On

The syntax is !(bind.fileVersion.FileId) -- note the lowercase f.

2
Mumpiz On

Your define ?define MAINEXE=$(var.TestWix3.TargetFileName)? translates to: create a variable with Name MAINEXE and set it to the value of another variable.

There is no variable defined TestWix3.TargetFileName Your second define created a variable with Name VERSION and uses the undefined MAINEXE

using the defines like this instead
?define MAINEXE=sample.exe?
?define VERSION="!(bind.fileVersion.$(var.MAINEXE))"? compiles no problem

I ommitted the <&lt >&gt before and after ?

0
LinuxDev On

In our case (C++ program), this bind.FileVersion error message apparently was fixed by adding Win32 rc VERSIONINFO resources that were actually missing in the relevant library project (I'd think that WiX requires proper version declaration of a binary to e.g. make its installation/upgrade decisions etc.).