Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set a preprocessor variable to the value of a property?

Tags:

wix

xsd

wix3

I have a WiX include file with the following code

<Fragment Id="PropertyFragment">
  <Property Id="DynamicLanguageCode" Value="[SystemLanguageID]" />
  <?define productLanguage = [DynamicLanguageCode]?>
</Fragment>

Now in my Product tag in my WiX script I'd like to set the Language attribute to the value of productLanguage, as it only takes localizable integers. Is there a way I can get my variable to be assigned the value of the property?

Thanks

like image 776
Ray Dey Avatar asked Jan 29 '10 14:01

Ray Dey


People also ask

How do you declare a preprocessor variable in Wix?

Any environment variable can be referenced with the syntax $(env. VarName). For example, if you want to retrieve the environment variable %_BuildArch%, you would use $(env. _BuildArch).

What is a preprocessor variable?

A preprocessor variable is specified in a %DECLARE statement with the FIXED, CHARACTER, or INITIAL attribute. No other attributes can be declared for a preprocessor variable, and attributes must not be repeated. (Other attributes are supplied by the preprocessor, however.)


2 Answers

Without arguing why, this could be done like that:

<Property Id="DynamicLanguageCode" Value="$(var.SystemLanguageID)" />
like image 161
VeV Avatar answered Oct 04 '22 12:10

VeV


It's important to clear up confusion around the difference between wix variables and windows installer properties.

A wix variable can be referenced as $(var.foo). Such a variable can be defined by passing -d command line arguments to candle.exe. It can also be defined by the <?define foo="bar"?> syntax. A wix variable is a concept that only exists while building your setup. It is something that it is filled in by the wix preprocessor before anything else happens, much like #define statements in C++.

A windows installer property is something that is filled in during installation. One way to define properties is to put them in the Property table of an MSI file. This is what the wix Property element does. Some (but not all) data types used in a windows installer database allow you to reference such a property with the [FOO] syntax. One example of a data type which supports this is the Shortcut data type, used by the Target attribute of the wix Shortcut element. The Language datatype does not support this!

like image 29
Wim Coenen Avatar answered Oct 04 '22 14:10

Wim Coenen