WiX Toolset Quick Reference ↩
This document gathers WiX hints and tips. |
The dialog strings must be localized. WiX comes with 40 sets of loc strings; you specify them using the -cultures
switch to %WIX%\light.exe
.
The WiX Toolset engine supports 3 types of custom variables :
- Environment variables : The syntax is
$(env.<var_name>)
where<var_name>
is case-insensitive. For example, we write$(env.APPDATA)
to retrieve the environment variable%APPDATA%
. - System variables : The syntax is
$(sys.<var_name>)
.CURRENTDIR
- The current directory where the build process is running.SOURCEFILEPATH
- the full path to the file being processed.SOURCEFILEDIR
- the directory containing the file being processed.BUILDARCH
- the platform this package is compiled for (Intel, x64, Intel64, ARM). - User-defined variables : The user has two ways to defined them, either at the top of a WiX source file as
<?define MyVariable="Hello World" ?>
or from the command line using option-d
, e.g.candle -dMyVariable="Hello World" ...
.
The WiX Toolset engine provides many built-in variables to be used in WiX source files. In particular, some of them are needed to target the runtime architecture (e.g. x86, x64, ia64) of the generated Windows installer.
For instance, the variables below are defined as follows for a 64-bit Windows operating system 1 (CSIDL="constant special item ID list") :
WiX variable | CSIDL | Path |
---|---|---|
CommonFilesFolder | CSIDL_PROGRAM_FILES_COMMONX86 |
C:\Program Files\Common Files |
CommonFiles64Folder | CSIDL_PROGRAM_FILES_COMMON |
C:\Program Files (x86)\Common Files |
ProgramFilesFolder | CSIDL_PROGRAM_FILESX86 |
C:\Program Files (x86) |
ProgramFiles64Folder | CSIDL_PROGRAM_FILES |
C:\Program Files |
SystemFolder | CSIDL_SYSTEMX86 |
C:\Windows\System32 |
System64Folder | CSIDL_SYSTEM |
C:\Windows\SysWOW64 |
The WiX developer has to take care of them when specifying the candle
option -arch <name>
:
> %WIX%\candle.exe --help Windows Installer XML Toolset Compiler version 3.11.2.4516 Copyright (c) .NET Foundation and contributors. All rights reserved. usage: candle.exe [-?] [-nologo] [-out outputFile] sourceFile [sourceFile ...] [@responseFile] -arch set architecture defaults for package, components, etc. values: x86, x64, or ia64 (default: x86) [...]
Footnotes ▴
[1] Windows System Information ↩
-
On the Windows prompt we call the command
wmic.exe
to display information about the installed Windows operating system : -
> wmic os get BuildNumber, Caption, OSArchitecture, Version BuildNumber Caption OSArchitecture Version 19042 Microsoft Windows 10 Pro 64-bit 10.0.19042
☛ WMIC Deprecation
wmic.exe
is deprecated since the Windows May 2021 Update (21H1).
Alternatively we get the same system information with the PowerShell cmdlet -
> powershell -c "Get-WmiObject -ClassName Win32_OperatingSystem | Select BuildNumber,Caption,Version,OSArchitecture" BuildNumber Caption Version OSArchitecture ----------- ------- ------- -------------- 19042 Microsoft Windows 10 Pro 10.0.19042 64-bit
Get-WmiObject
: