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

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.
Here is the error:
Any idea why the binding of (bind.fileVersion) does not work ?

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.

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

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 ?

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

Related

Wix error undefined preprocessor variable(error CNDL0150)

I am trying to build my first installer using WIX. I am not using visual studio instead i am using command line. I have a wxs file and i have also created a .wxi file for the Headers and i have defined them buy i get the following error when i run the candle.exe "Undefined preprocessor variable '$(var.ProjectDir)'"
Here is the .wxs and .wxi
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{CB06C559-BCBF-4C85-95F3-FE55F6F50463}" Name="My first msi installer" Language="1033" Version="1.0.0.0" Manufacturer="Wave-axis" UpgradeCode="9be991bb-ceb1-4320-bfc7-56738e32c99a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<Icon Id="icon.ico" SourceFile="$(var.ProjectDir)icon.ico" />
<Property Id="WAVEAXIS" Value="icon.ico" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<UIRef Id="WixUI_Minimal" />
<!--used for the UI for the installer-->
<Feature Id="ProductFeature" Title="My first msi installer" Level="1">
<!-- This includes all the feature of the installer-->
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="ApplicationShortcut" />
<!--Used for shortcut on the start up menu-->
<ComponentRef Id="ApplicationShortcutDesktop" />
<!--used for desktop shortcut-->
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<!--install location of the application-->
<Directory Id="INSTALLFOLDER" Name="My first msi installer" />
</Directory>
<Directory Id="ProgramMenuFolder">
<!--install location for the startup-->
<Directory Id="ApplicationProgramsFolder" Name="My first msi installer" />
</Directory>
<Directory Id="DesktopFolder" Name="Desktop" />
<!--install loaction for the desktop-->
</Directory>
</Fragment>
</Wix>
.wxi code
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define firstapplication.TargetDir ?>
<?define ProjectDir ?>
<?define firstapplication_TargetDir ?>
<?define ProductId=652648517 ?>
</Include>
regards Sagar
You need to include your wxi file in every wxs file you wish to use the properties in at the top of your file before the <Wix> tag
<?include $(sys.SOURCEFILEDIR)Path\to\InstallVars.wxi?>
<Wix xmlns="http://...">
...
</Wix>
This page will explain some of the available variables for the preprocessor like "SOURCEFILEDIR".

How to ship file in our desktop folder and how to create shortcut to desktop folder?

I want to ship file to our target folder and create shortcut to desktop folder.my wix coding is
enter code here`
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="5A157ECF-D387-43EF-855E-C39E9F26B463" Name="DesktopPermission" Language="1033" Version="1.0.0.0" Manufacturer="Naveen" UpgradeCode="5A157ECF-D387-43EF-855E-C39E9F26B463">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="DesktopPermission" Level="1">
<ComponentRef Id="compid"/>
</Feature>
<DirectoryRef Id="APP_DIR">
<Component Id="compid" Guid="F2450B59-EA82-4762-8AEF-984D54F6EAA9">
<File Id="BuildFile" KeyPath="yes" Source="C:\Users\naveen.raja\Desktop\Text.txt"/>
</Component>
</DirectoryRef>
<CustomAction Id="sample" Directory="APP_DIR" Value="C:\Users\naveen.raja\Desktop\Installone" Execute="immediate" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="APP_DIR" Name="myfile">
</Directory>
</Directory>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="258B1044-131B-49F7-90CB-CC92C8658191">
<Shortcut Id="ApplicationDesktopShortcut"
Name="Text under your icon"
Description="Comment field in your shortcut"
Target="[APP_DIR]"
WorkingDirectory="APP_DIR"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software/MyAppName"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Product>
<Fragment>
<InstallExecuteSequence>
<Custom Action="sample" Sequence="600" />
</InstallExecuteSequence>
</Fragment>
</Wix>
but the file not shipped and also not created the shortcut. so please help what are all things to change in this coding. Thanks in advance.
Normally, if you provide a verbose log of your installation, it makes it easier to see exactly what went wrong. Without that log, I had to go with your code only.
Your code as provided didn't compile for me (I am using v3.9), and there were other errors in form probably preventing your installer from running as you intended. The errors I found were of the following types:
1: your custom action to set the location of APP_DIR wasn't ever included because the fragment scheduling it was never referenced. That would cause the file to be installed to C:\myfile\Text.txt (replace C: with the drive with the largest amount of free space on your computer) instead of under your desktop as you intended. (May your file be there?)
2: Code failed ICE21 because ApplicationShortcutDesktop wasn't included in any feature (probable reason that your shortcut didn't appear).
3: Code couldn't compile because was repeated.
4: Code failed ICE 12 because your custom action "sample" is of type: 35. Therefore it must come after CostFinalize # 1000 in Seq Table: InstallExecuteSequence.
A side note: Normally ProductCode (Product\#Id) and UpgradeCode (Product\#Upgrade) are NOT the same value. You may wish to learn more about those two values in Windows Installer/MSI. There are a lot of experts in this area on the wix toolset's wix-users list. In fact, a lot of help can be found by searching that lists archives and/or by asking questions there.
Fixing these four errors, your file's folder and your shortcut to the file's folder both showed up on the indicated desktop, and the file was found added to that folder.
Here's what my version (minimal changes) of your code looks like:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="5A157ECF-D387-43EF-855E-C39E9F26B463" Name="DesktopPermission" Language="1033" Version="1.0.0.0" Manufacturer="Naveen" UpgradeCode="5A157ECF-D387-43EF-855E-C39E9F26B463">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="DesktopPermission" Level="1">
<ComponentRef Id="compid"/>
<ComponentRef Id="ApplicationShortcutDesktop"/>
</Feature>
<DirectoryRef Id="APP_DIR">
<Component Id="compid" Guid="F2450B59-EA82-4762-8AEF-984D54F6EAA9">
<File Id="BuildFile" KeyPath="yes" Source="C:\Users\naveen.raja\Desktop\Text.txt"/>
</Component>
</DirectoryRef>
<CustomAction Id="sample" Directory="APP_DIR" Value="C:\Users\naveen.raja\Desktop\Installone" Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="sample" After="CostFinalize" />
</InstallExecuteSequence>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="APP_DIR" Name="myfile">
</Directory>
</Directory>
<DirectoryRef Id="TARGETDIR">
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="258B1044-131B-49F7-90CB-CC92C8658191">
<Shortcut Id="ApplicationDesktopShortcut"
Name="Text under your icon"
Description="Comment field in your shortcut"
Target="[APP_DIR]"
WorkingDirectory="APP_DIR"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software/MyAppName"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Directory>
</DirectoryRef>
</Product>
</Wix>
Hope that helps!

Wix XML Error - The Component/#Directory attribute cannot be specified when the Component element is nested underneath a Directory element

First time doing some Wix practice, so im completely new to it.
Here is my short script:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SampleMSI" Language="1033" Version="1.0.0.0" Manufacturer="Nunya" UpgradeCode="b2c39f9b-1de1-433e-bc59-a3548cc531b9">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Installs Signout Utility" Keywords="Practice,Signout,Utility,MSI,Installer" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SampleMSI" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SampleMSI" />
<Directory Id="APPFOLDER" Name="APPDir" >
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="CMP_ADispOCX"
Guid="5E23B839-35CA-480E-8AFC-2E914BA8E32A"
Directory="INSTALLLOCATION">
<File Id="FILE_ADispocx"
Source="ADisp.ocx"
KeyPath="yes" />
</Component>
<Component Id="CMP_Abtn32ocx"
Guid="98B357F2-C295-4019-A878-885E56AA3BF3"
Directory="INSTALLLOCATION">
<File Id="FILE_Abtn32a20ocx"
Source="btn32a20.ocx"
KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I just wanted to make sure they are going to the same folder, basic installation check. (it is my first time)
I get this error however:
Error 2 The Component/#Directory attribute cannot be specified when the Component element is nested underneath a Directory element.
I get it twice for each component id I have.
Am I missing something? Im using Wix 3.6 A Developers Guide for reference.
edit: Side question......how do I specify an exact path? like C:\Herp\Derp
You don't need to specify the directory of a Component if you did so already in the ComponentGroup element. Remove the Directory attribute in both Components elements in your fragment.
Change your code to this
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="CMP_ADispOCX"
Guid="5E23B839-35CA-480E-8AFC-2E914BA8E32A">
<File Id="FILE_ADispocx"
Source="ADisp.ocx"
KeyPath="yes" />
</Component>
<Component Id="CMP_Abtn32ocx"
Guid="98B357F2-C295-4019-A878-885E56AA3BF3">
<File Id="FILE_Abtn32a20ocx"
Source="btn32a20.ocx"
KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>

Reference WixUI Error

Enviorment:Win7+VS2012+Wix3.7.
Complile error:
Unresolved reference to symbol 'WixUI:WixUI_InstallDir' in section
'Product:{9E327731-0EAC-4A02-9C3C-9C136ACCE05B}'
Code is the follow:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{9E327731-0EAC-4A02-9C3C-9C136ACCE05B}" Name="SetupProject2" Language="1033" Version="1.1.1.1" Manufacturer="Anser" UpgradeCode="61eb40a6-21d9-4f23-9c9e-078b98707371">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject2" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Property Id="WIXUI_INSTALLDIR">INSTALLDIR</Property>
<UIRef Id="WixUI_InstallDir"/>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject2" />
</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> -->
<Component Id="ProductComponent" DiskId="1" Guid="{65F464D6-BC0B-4679-9546-CF8B6CFCE184}">
<File Name='test.exe' Source="test.exe" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
I can't find the reason.Who can help me?
Reference WixUIExtension.dll in the project.
I refer to the similar question in the follow site.
How to add a UI to a WiX 3 installer?

Confused with Wix bootstraper

I am having trouble understanding wix documentation. I have created a simple installer that allows user to select a destination folder for app. It looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="AppName" Language="1033" Version="1.0.0.0" Manufacturer="Manufacturer" UpgradeCode="guid">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProjectFeature" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir"/>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="OeeCoach" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<Component Id="EntityFramework" Guid="guid">
<File Id="EntityFramework.dll" Source="../App/bin/Release/EntityFramework.dll" KeyPath="yes" />
</Component>
<Component Id="MvvmLight.Extras" Guid="guid">
<File Id="GalaSoft.MvvmLight.Extras.WPF4.dll" Source="../App/bin/Release/GalaSoft.MvvmLight.Extras.WPF4.dll" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Now I need to check for .net 4 and its prerequisites, but I could not understand hot to do this. Documentation says that I need to use Bundle element, but compiler seems to complain when it is together with Product element in same wix file.
Any help is appreciated.
The bootstrapper is a separate project from your setup project. If you are using Visual Studio, add a new project to your solution and choose Bootstrapper project (instead of Setup project).