WiX (Windows Installer Xml), Create universal variables
Asked Answered
A

1

5

I was studying for WiX for several days through some online tutorial. I saw three cases to create some variables

  1. <? define Variable = "value" ?> and then use the value as $(var.Variable)
  2. Create a localization file. Type in content as <String Id="Variable">Value</String> and then use the value as !(loc.Variable)
  3. Create a include file. Type in content as <Property Id="VARIABLE" Value="value" /> and then include the file, use the property in Fragment as [VARIABLE]

I know the localization file is mainly used for different locales. But I don't know when we should use each case. Can anyone help explain?

Ahwaz answered 21/5, 2018 at 7:50 Comment(1)
You might still end up with three choices but Properties are a Windows Installer feature, not a WiX feature, and any of the three can be used in a WiX include file-that's an independent concept. In general, it seems like the tutorial is overusing the word variable and creating false equivalencies.Levitus
C
2

I haven't used these constructs that much. However, I think Bob Arnson (WiX developer) explains this pretty well in this blog entry about localization (the explanation is good, but I still manage to confuse myself - carbon error).

Essentially:

  • Preprocessor variables - $(var.Variable) - are resolved by the WiX preprosessor - it happens before compilation (Candle.exe).
  • Localization variables - !(loc.LanguageLcid) - are resolved at link time (Light.exe). The linking process can spit out multiple MSI files in different languages. Hence localization is a link-time process.
  • See link 3 below for a localization sample. Once you localize, you localize most or all fields. In the sample below I don't localize version and upgrade code - they remain the same for all output MSI files.
  • You have to determine in each case what should be localized. Should the Manufacturer name be localized? Perhaps if you want Asian characters for Asian setups, and an equivalent Latin character name otherwise?
  • Include files are simply included in the WiX source before compilation. It is like including a header file in C++. This makes it a preprocessor construct. See link 2 below for a discussion of the use of include files.
  • UPDATE: There are also Burn Engine Variables - if you make setup.exe launchers with WiX.
  • WixVariable:

I am sure there are other technical reasons as well. Rob or Bob would need to illuminate. There could also be differences in WiX 4 than what I am used to in WiX 3 - and there could be changes planned that I am unaware of.


Some Links:

  1. Is it possible to pass variable to WIX localization file? (for easy retrieval)
  2. Wix Installer : Setting component condition property when doing a MSIEXEC admin install at command line (a lenghty description of preprocessor constructs versus other useful constructs to create flavors of setups)
  3. Wix toolset license agreement multi-languages issue (using localization)
  4. Wix string with characters not available in database 's codepage although codepage is set
  5. On various preprocessor constructs $(env.someval), $(sys.someval), $(var.someval): https://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html
Chrysotile answered 21/5, 2018 at 15:32 Comment(1)
additional info on variables (using localized strings containing other variables) would be useful.Bridoon

© 2022 - 2024 — McMap. All rights reserved.