Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX condition properties passed from command line don't work?

I have a property for whether to install shortcuts that need to be passed via command line arguments. The conditions seem to work when I set the properties within the wxs file, but they seem to be ignored when setting them through the command line. From the log I see that they are being set:

MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTUPSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTMENUSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLDESKTOPSHORTCUT property. Its current value is '0'. Its new value: '1'.

However, they the shortcuts aren't being installed.

Also, it seems like since they need to be in their own component to be able to set conditions on them, they can no longer be advertised shortcuts. How would you get conditionally installed advertised shortcuts?

Current shortcut code:

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0"/>
...
<Component Id="StartMenuShortcut" Guid="MY-GUID">
  <Condition>INSTALLSTARTMENUSHORTCUT</Condition>
  <Shortcut Id="StartMenuServerShortcut"
    Directory="ProgramMenuDir"
    Name="Application Name" WorkingDirectory="INSTALLDIR" Advertise="no"
    Target="[!FileEXE]"
    Icon="Icon.ico" />
</Component>

And repeated for other shortcuts

Edit:

Trying what Sacha suggested and adding the following:

<Property Id="INSTALLSTARTUPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLDESKTOPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="yes"/>

Now it installs all the shortcuts even though they're set to 0 both in the xml and on the command line. The command line I'm passing is:

msiexec /i MySetup.msi INSTALLSTARTUPSHORTCUT=0 INSTALLDESKTOPSHORTCUT=0 INSTALLSTARTMENUSHORTCUT=0 /l*v inst.log /qb

tried putting the values in quotes and still no go. Not shown here, but I was successful in manipulating the ALLUSERS property to do per-user or per-machine registries by doing ALLUSERS="" or ALLUSERS="2" So passing in properties should be possible, but I'm not sure what I'm doing wrong.

like image 675
Davy8 Avatar asked Dec 18 '22 08:12

Davy8


2 Answers

Two things since there are two questions here:

  1. Advertised Shortcuts must be in the same Component that installs the File they point at. That is requried because the Windows Installer points an advertised Shorcut at the KeyPath of the Component. So, you can't use advertised Shorcuts if you want them to be optionally installed.

I have a blog post about how to create a shorcut and pass validation.

  1. The Properties you are using need to be marked secure to pass from the install UI process to the server-side. To do that just do

    <Property Id="INSTALLSTARTMENUSHORTCUT" Secure="yes"/>

Notice that I did not add a Value attribute. If you specify a Value, even if it is 0, then your INSTALLSTARTMENUSHORCUT will evaluate to TRUE. A blank/non-defined Property is FALSE, any other value is TRUE.

like image 192
Rob Mensching Avatar answered Dec 19 '22 21:12

Rob Mensching


Have you tried marking the properties as secure?

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="Yes" />

Looking at the documentation for the Shortcut Table I don't think you can get conditionally advertised shortcuts. We get around this by installing an Advertised start menu shortcut, and a regular desktop shortcut.

like image 45
saschabeaumont Avatar answered Dec 19 '22 21:12

saschabeaumont