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

4

3

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 ?

Hold answered 30/5, 2018 at 19:45 Comment(0)
S
8

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.

Sw answered 30/5, 2018 at 21:3 Comment(3)
thanks. It solved the problem. I was not aware that I needed the File Id.Hold
I defined the File Id, the error is still present. would be any other cause?Irina
@Irina if your component is defined in a fragment make sure that fragment is brought into the main product with a ComponentRef or ComponentGroupRef or FeatureRef depending on the structure of your install. You can also try making a small test install that includes everything in one file to see if you can get it working that way. Sometimes you can get in a state where your intermediate files aren't rebuilt but need to be so also try a clean and build. If none of that works probably make your own question on SOSw
U
0

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

Undermost answered 30/5, 2018 at 19:50 Comment(1)
thanks but it did not fix the issue. Still the same issue with lower case f.Hold
S
0

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 ?

Sheilasheilah answered 31/5, 2018 at 14:9 Comment(2)
I tried with my exe name (TestWix3.exe). It did not work . (same error)Hold
The correct solution seems to be the one given by Brian SutherlandHold
S
0

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.).

Sloth answered 14/11, 2022 at 10:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.