Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pass variable to WIX localization file?

I need to use variable in WIX localization file WIXUI_en-us.wxl. I tried use it like this:

<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product $(var.InstallationVersionForGUI) is already installed</String>

But it doesn't work. And when I declared property and used it this way:

<String Id="Message_SomeVersionAlreadyInstalled" Overridable="yes">A another version of product [InstallationVersionForGUI] is already installed</String>

doesn't work either.

Where was I wrong?

Thanks for help and your time.

like image 445
Elena Avatar asked Jul 26 '11 09:07

Elena


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

How do you add localization on WiX?

Right click on your project in Solution Explorer and select Add > New Item... Select WiX Localization File, give the file an appropriate name, and select Add.


2 Answers

Localization strings are processed at link time, so you can't use $(var) preprocessor variables. Using a [property] reference is supported, as long as the place where the localization string is used supports run-time formatting (e.g., using the Formatted field type).

like image 151
Bob Arnson Avatar answered Sep 23 '22 00:09

Bob Arnson


Your second method should work just fine. This is the same method used by the default .wxl files.

For example, in your .wxl file you would declare your string:

<String Id="Message_Foo">Foo blah blah [Property1]</String>

And in your .wxs file, you declare the property. If you wish, you can declare the property to match a WiX variable (which it sounds like you're trying to do)

<Property Id="Property1">$(var.Property1)</Property>
like image 38
saschabeaumont Avatar answered Sep 24 '22 00:09

saschabeaumont