安装快捷方式时出错

时间:2014-10-07 20:25:14

标签: xml xaml wix installer windows-installer

在我的WiX安装程序中,如果我使用此代码,我的桌面快捷方式可以正常工作:

<Component Id="TrayWithStartMenuAndDesktopShortcuts" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT="1"]]></Condition>
  <File Id="TrayFileWithStartMenuAndDesktopShortcuts" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsDesktopShortcut" Directory="DesktopFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>

但是当我使用以下代码时,只要双击桌面快捷方式,就会弹出一条错误消息,此计算机上未使用的组件。”

<Component Id="TrayWithStartMenuAndDesktopShortcuts" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT="1"]]></Condition>
  <File Id="TrayFileWithStartMenuAndDesktopShortcuts" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsDesktopShortcut" Directory="DesktopFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
    <Shortcut Id="TrayWithStartMenuAndDesktopShortcutsProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>
<Component Id="TrayWithStartMenuShortcut" Directory="INSTALLFOLDER" Permanent="no" SharedDllRefCount="no" Transitive="no">
  <Condition><![CDATA[STARTMENUSHORTCUT="1" AND DESKTOPSHORTCUT<>"1"]]></Condition>
  <File Id="TrayFileWithStartMenuShortcut" DiskId="1" Hidden="no" ReadOnly="no" System="no" Vital="yes" Compressed="yes" Name="Tray.exe" Source="Tray.exe" KeyPath="yes">
    <Shortcut Id="TrayFileWithStartMenuShortcutProgramFilesShortcut" Directory="ProgramMenuFolder" Name="Creator" WorkingDirectory="INSTALLFOLDER" Icon="Creator.ico" Advertise="yes" />
  </File>
</Component>

请注意安装如何根据满足的条件进行更改。如果有条件地安装我的快捷方式并使其正常工作,我该怎么办?

1 个答案:

答案 0 :(得分:1)

看起来是因为快捷方式被广告,并且显然广告的快捷方式将无法运行,除非安装了功能下的所有组件,在我的情况下,并非所有组件都是有条件的。我在重构时使用了Raymond的答案:Create shortcut to desktop using WiX