7

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

<?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>
4

2 回答 2

19

我正在添加按预期工作的代码以供将来参考和问题的确切答案:

<?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>
于 2013-01-30T11:27:06.847 回答
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>
于 2018-02-16T10:31:00.777 回答