Is it possible to pass variable to WIX localization file?

前端 未结 3 2040
暖寄归人
暖寄归人 2021-01-04 03:59

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



        
相关标签:
3条回答
  • 2021-01-04 04:05

    I was trying to get localization file to use variables. Came across this post:

    There are different layers of variables in WiX (candle's preprocessor variables, Light's WixVariables/localization variables/binder variables, and MSI's properties). Each have different syntax and are evaluated at different times:

    Candle's preprocessor variables "$(var.VariableName)" are evaluated when candle runs, and can be set from candle's commandline and from "" statements. Buildtime environment properties as well as custom variables can also be accessed similarly (changing the "var." prefix with other values).

    Light's variables accessible from the command-line are the WixVariables, and accessing them is via the "!(wix.VariableName)" syntax. To access your variable from your commandline, you would need to change your String to: This build was prepared on !(wix.BuildMachine)

    If you instead need to have the BuildMachine value exist as an MSI property at installation time (which is the "[VariableName]" syntax) you would need to add the following to one of your wxs files in a fragment that is already linked in:

    Now, the environment variable COMPUTERNAME always has held the name of my build machines in the past, and you can access that this way: $(env.COMPUTERNAME). So, you can get rid of the commandline addition to light.exe and change your wxs file like this:

    <WixProperty Id="BuildMachine" Value="$(env.COMPUTERNAME)"/>

    0 讨论(0)
  • 2021-01-04 04:11

    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>
    
    0 讨论(0)
  • 2021-01-04 04:19

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

    0 讨论(0)
提交回复
热议问题