Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX Property Reference Another Property

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?

like image 524
E-rich Avatar asked Aug 24 '11 17:08

E-rich


1 Answers

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.

like image 69
Bob Arnson Avatar answered Nov 16 '22 03:11

Bob Arnson