WiX Property Reference Another Property

爱⌒轻易说出口 提交于 2019-12-23 07:03:50

问题


I am trying to create multiple shortcuts to my application that pass different arguments on the commandline by using the Arguments attribute of the Shortcut element. I want to be able to reference an existing property from another property in my WiX file.

I want to be able to create a shortcut by referencing the ARGUMENTS property via:

<Component Id="MyAppProgramMenuShortcut" Guid="MY-GUID-HERE">
    <RegistryValue Root="HKCU"
        Key="Software\[Manufacturer]\[ProductName]\MyAppShortcut" Type="string"
        Value="" KeyPath="yes" />
    <Shortcut Id="ProgramMenuShortcutMyApp" Directory="ProgramMenuDir"
        Name="MyApp" Target="[SHORTCUT_TARGET]"
        Arguments="-jar myApp.jar [ARGUMENTS]" WorkingDirectory="INSTALLDIR"
        Icon="logo.ico" />
</Component>

I've tried something equivalent to:

<Property Id="PROGRAM_FILES">C:\Program Files</Property>
<Property Id="MY_APP_DIR">[PROGRAM_FILES]\MyApp</Property>
<Property Id="ARGUMENTS">[MY_APP_DIR]\fileA.xml [MY_APP_DIR]\fileB.xml</Property>

but then I get this warning when passing it through candle.exe:

warning CNDL1077 : The 'MY_APP_DIR' Property contains '[PROGRAM_FILES]' in its value which is an illegal reference to another property. If this value is a string literal, not a property reference, please ignore this warning. To set a property with the value of another property, use a CustomAction with Property and Value attributes.

So, based on the suggestion in the warning I switched to something equivalent to:

<CustomAction Id="PROGRAM_FILES" Property="PROGRAM_FILES" Value="C:\Program Files"/>
<CustomAction Id="MY_APP_DIR" Property="MY_APP_DIR" Value="[PROGRAM_FILES]\MyApp"/>
<CustomAction Id="ARGUMENTS" Property="ARGUMENTS" Value="[MY_APP_DIR]\fileA.xml [MY_APP_DIR]\fileB.xml"/>

and I get no warnings or errors, but the problem is that when I install the application the shortcuts don't have the arguments in the target field.

Am I not doing something that I should be doing? Is there a way to do what I want to do?


回答1:


You don't need properties for Program Files or your product's install directory. Use [#FileId] to refer to the complete path to that file.

Also, if you want multiple shortcuts, just have multiple Shortcut elements with different Arguments attributes. If you want one of several shortcuts, you can have multiple Components with Shortcuts and use a Condition to install only one of them.



来源:https://stackoverflow.com/questions/7179578/wix-property-reference-another-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!