Wix Installer开始菜单快捷方式未出现

时间:2013-01-29 12:59:41

标签: wix windows-installer wix-extension

我正在尝试使用WiX v3.7为Windows应用程序创建一个安装程序项目(因为VS2012不再包括设置和部署项目)用于学习目的。 Wix工具集已集成到VS,我正在创建一个新的WiX单一安装程序设置项目。安装程序总是成功编译(除了图标扩展中的警告),它运行完美并且应该放置桌面快捷方式,但是无法在Windows 7 Professional x64 Service Pack 1上放置正确的开始菜单快捷方式。 我在网上搜索并尝试了几乎所有我看到的东西,但到目前为止还没有成功。 product.wxs文件如下所示,“my_guid”字符串由项目中的适当GUID替换。显然我错过了一点,但看不到哪里。也不会创建注册表项,因此最后一个片段可能由于某种原因而无法执行。怎么能解决这个问题?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="my_guid" Name="WixSingleSetupExample" Language="1055" Version="1.0.0.0" Manufacturer="Can Yucel" UpgradeCode="my_guid">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate />

        <Feature Id="ProductFeature" Title="WixSingleSetupExample" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
            <ComponentRef Id="ApplicationShortcut" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="DesktopFolder" Name="Desktop" />
            <Directory Id="ProgramMenuFolder">
                <Directory Id="ApplicationProgramsFolder" Name="WixSingleSetup"/>
            </Directory>
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="WixSingleSetupExample" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
          <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
          <Component Id="ProductTextFile">
              <File Source="blankText.txt" KeyPath="yes">
                  <Shortcut Id="desktopShortcut" Advertise="yes" Directory="DesktopFolder" Name="WixSingleSetup Help" WorkingDirectory="INSTALLFOLDER" Icon="icon1.txt" IconIndex="0">
                      <Icon Id="icon1.txt" SourceFile="blankText.txt"/>
                  </Shortcut>
              </File>      
          </Component>
        </ComponentGroup>
    </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="my_guid">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="WixSingleSetup Help"
                  Description="Setup Example"
                  Target="blankText.txt"
                  WorkingDirectory="INSTALLFOLDER"
                  Icon="icon2.txt"
                  IconIndex="0">
          <Icon Id="icon2.txt" SourceFile="blankText.txt"/>
        </Shortcut>
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software/Microsoft/WixSingleSetup" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>

2 个答案:

答案 0 :(得分:18)

我正在添加代码,以供将来参考,以及问题的确切答案:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="guid_here" Name="WixSingleSetupExample" Language="1055"
           Version="1.0.0.0" Manufacturer="Can Yucel" UpgradeCode="guid_here">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="WixSingleSetupExample" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ProgramMenuDir"/>
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">

      <Directory Id="DesktopFolder" Name="Desktop" />

      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ApplicationProgramsFolder" Name="WixSingleSetup">
          <Component Id="ProgramMenuDir" Guid="guid_here">
            <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
            <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\WixSetup"
                           Type="integer" Value="1" Name="installed" KeyPath="yes" />
          </Component>
        </Directory>
      </Directory>


      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="WixSingleSetupExample" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <!-- TODO: Remove the comments around this Component element and the
           ComponentRef below in order to add resources to this installer. -->
      <Component Id="ProductTextFile">
        <File Source="blankText.txt" KeyPath="yes">
          <Shortcut Id="desktopShortcut" Advertise="yes" Directory="DesktopFolder"
                    Name="WixSingleSetup Help" WorkingDirectory="INSTALLFOLDER"
                    Icon="icon1.txt" IconIndex="0">
            <Icon Id="icon1.txt" SourceFile="blankText.txt" />
          </Shortcut>
          <Shortcut Id="startMenuShotcut" Directory="ApplicationProgramsFolder"
                    Name="WiXSingleSetup Help" WorkingDirectory="INSTALLFOLDER"
                    Icon="icon2.txt" IconIndex="0" Advertise="yes">
            <Icon Id="icon2.txt" SourceFile="blankText.txt"/>
          </Shortcut>
        </File>      
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

答案 1 :(得分:1)

我最近开始使用Wix,而且我已经坚持了几周你所描述的问题。

我找到了另一种添加开始菜单快捷方式的方法,无需添加额外的组件(删除菜单文件夹),也无需在目标计算机注册表上创建热键。

这可以通过将<RemoveFolder ... />定义移动到<Component Id="ProductTextFile" ...>元素来完成。此后修改后的工作脚本:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="{GUID HERE}" Name="WixSingleSetupExample" Language="1055"
           Version="1.0.0.0" Manufacturer="Can Yucel" UpgradeCode="{GUID HERE}">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Icon Id="ICON1.ICO" SourceFile="icon1.ico" />
    <Icon Id="ICON2.ICO" SourceFile="icon2.ico" />

    <Feature Id="ProductFeature" Title="WixSingleSetupExample" Level="1">
      <ComponentRef Id="ProductTextFile" />
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="DesktopFolder" Name="Desktop" />

      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ApplicationProgramsFolder" Name="WixSingleSetup" />
      </Directory>

      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="WixSingleSetupExample" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
      <Component Id="ProductTextFile" Directory="INSTALLFOLDER" Guid="{GUID HERE}">
        <File Source="blankText.txt" KeyPath="yes">
          <Shortcut Id="desktopShortcut" Advertise="yes" Directory="DesktopFolder"
                    Name="WixSingleSetup Help" WorkingDirectory="INSTALLFOLDER"
                    Icon="ICON1.ICO" IconIndex="0" />

          <Shortcut Id="startMenuShotcut" Directory="ApplicationProgramsFolder"
                    Name="WiXSingleSetup Help" WorkingDirectory="INSTALLFOLDER"
                    Icon="ICON2.ICO" IconIndex="0" Advertise="yes" />
        </File>

        <RemoveFolder Id="ProgramMenuDir" Directory="ApplicationProgramsFolder" On="uninstall"/>
      </Component>
  </Fragment>
</Wix>