【问题标题】:Shortcut (non-advertised) not being created with Wix installer?没有使用 Wix 安装程序创建快捷方式(非广告)?
【发布时间】:2018-01-25 23:24:00
【问题描述】:

我使用 Wix 3.11 构建了一个简单的 MSI 安装程序。它包括一个 EXE 和一个快捷方式,但该快捷方式永远不会出现在桌面上。我构建的 MSI 没有错误,否则它安装得很好,并且 MSI 日志文件中没有错误。我使用 Orca 查看了 MSI,并在他们的表格中看到了快捷方式和桌面目录。想法?我也尝试将 ALLUSERS 设置为 1 也无济于事。这是我的 wxs 文件:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" Name="Imaginary Product" Language="1033" 
    Version="1.2.3.4" Manufacturer="Company" UpgradeCode="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">

    <Package Id="*" InstallerVersion='300' Compressed='yes'/>

    <Media Id="1" Cabinet="ImaginaryProduct.cab" EmbedCab="yes"/>

    <?if $(sys.BUILDARCH)="x64" ?>
      <?define Win64 = "yes" ?>
      <?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
    <?else ?>
      <?define Win64 = "no" ?>
      <?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
    <?endif ?>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="DesktopFolder" SourceName="Desktop">
        <Component Id="MainExecutableShortcut" Guid="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}">
          <Shortcut Id="ImaginaryUIEXEShortcut" Name="Imaginary UI" Description="Runs Imaginary UI" Target="ImaginaryUI.exe" WorkingDirectory="ProductProgramFilesFolder"/>
          <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall"/>
          <RegistryValue Root="HKCU" Key="Software\Microsoft\ImaginaryUI" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
        </Component>
      </Directory>

      <Directory Id="$(var.PlatformProgramFilesFolder)">
        <Directory Id="ManufacturerProgramFilesFolder" Name="Company">
          <Directory Id="ProductProgramFilesFolder" Name="Imaginary Product">
            <Component Id="MainExecutable" Guid="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}">
              <File Id="ImaginaryUIEXE" Name="ImaginaryUI.exe" Vital="yes" Source=".\bin\$(var.Configuration)\ImaginaryUI.exe" KeyPath="yes"/>
            </Component>
          </Directory>
        </Directory>
      </Directory>
    </Directory>


    <Feature Id='MainApplication' Level='1'>
      <ComponentRef Id="MainExecutable" Primary="yes"/>
      <ComponentRef Id="MainExecutableShortcut" Primary="yes"/>
    </Feature>

  </Product>
</Wix>

更新:当快捷方式未指定和图标时,我在安装程序日志中看到:

Action start 16:27:50: CreateShortcuts.
MSI (s) (08:34) [16:27:50:522]: Note: 1: 2205 2:  3: Icon 
MSI (s) (08:34) [16:27:50:522]: Note: 1: 2228 2:  3: Icon 4: SELECT `Name`, `Data` FROM `Icon` 
MSI (s) (08:34) [16:27:50:522]: Note: 1: 2205 2:  3: MsiShortcutProperty 
MSI (s) (08:34) [16:27:50:523]: Note: 1: 2205 2:  3: MsiShortcutProperty 
Action ended 16:27:50: CreateShortcuts. Return value 1.

当我指定一个时,我看到的更少:

MSI (s) (14:D0) [16:34:59:527]: Doing action: CreateShortcuts
MSI (s) (14:D0) [16:34:59:527]: Note: 1: 2205 2:  3: ActionText 
Action start 16:34:59: CreateShortcuts.
MSI (s) (14:D0) [16:34:59:528]: Note: 1: 2205 2:  3: MsiShortcutProperty 
MSI (s) (14:D0) [16:34:59:528]: Note: 1: 2205 2:  3: MsiShortcutProperty 
Action ended 16:34:59: CreateShortcuts. Return value 1.

所以,没有失败的迹象。图标刚刚进入以太。

【问题讨论】:

    标签: wix desktop-shortcut


    【解决方案1】:

    我不确定这是否是您的问题,但要使用桌面文件夹,您只需将其定义为

    <Directory Id="DesktopFolder"/>
    

    我认为您实际上是将快捷方式放在“C:\Desktop\”中(假设 TARGETDIR 是 C:)。所有System Folder Properties 都应该以相同的方式定义。

    另外,从你的组件定义中删除它

    <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall"/>
    

    您不想删除 Desktop 文件夹,它不是您在安装时创建的,也不是您拥有的。此外,如果该文件夹中存在任何其他内容,RemoveFolder 将不会执行任何操作,并且基本上每个人的桌面文件夹中都至少有一个回收站,因此它永远不会执行任何操作。

    我不确定为什么在其他快捷方式定义(如开始菜单)中使用 RemoveFolder。这可能是由于 Windows 安装程序的工作方式,如果存在包含文件的组件,它只会隐式删除文件夹。

    【讨论】:

    • 感谢您的提示,但没有骰子。我删除了 Directory SourceName 属性以及 RemoveFolder 元素,但仍未创建快捷方式。我在安装驱动器中搜索了匹配的 *.lnk 文件,但一无所获。
    • 尝试使用 Target="[#ImaginaryUIEXE]" 来使用文件 ID 的值。我不确定您是否正确地执行 ProgramFilesFolder ...应该只是自动设置,并且在构建和使用“x86”或“x64”作为平台时,它将根据您的配置选择正确的文件夹,但这可能是一个单独的问题,或者它可能只是按照您设置的方式工作。
    【解决方案2】:

    我很确定 Target 必须是一个 ID,而不是文件名。所以改变

    Target="ImaginaryUI.exe"
    

    Target="[#ImaginaryUIEXE]" 
    

    【讨论】:

      猜你喜欢
      • 2011-01-04
      • 1970-01-01
      • 2012-07-31
      • 2016-12-16
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多