如何在WIX中将快捷方式目录引用到PackageGroup中?

问题描述

我有这个TestProduct.wxs文件,其代码如下:

<Wix
    xmlns="http://schemas.microsoft.com/wix/2006/wi"
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

    <Fragment>
        <util:RegistrySearch
            Id="ExistsSearch"
            Root="HKLM"
            Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{...}"
            Win64="no"
            Result="exists"
            Variable="IsInstalled" />

    <Variable Name="IsstemplateFile" Type="string" Value="[MediaRootDirectory]\ADMIN.iss" bal:Overridable="no" Persisted="yes" />
    <Variable Name="IssFile" Type="string" Value="" bal:Overridable="no" Persisted="yes" />

        <Feature Id="ProductFeature" Title="WebPageShortcutInstaller" Level="1">
          <ComponentGroupRef Id="ProductComponents" />
        </Feature>

        <SetProperty Id="URL" Value="http://www.google.com" Sequence="execute"  Before="CreateShortcuts" />

      <PackageGroup Id="PackageGroup">
            <ExePackage
                Id="AdministratorPackage"
                SourceFile="..."
                DetectCondition="IsInstalled = 1"
                displayName="Administrator"
                InstallCondition="InstallationType ~= InstallationTypeServer OR InstallationType ~= InstallationTypeClient"
                Compressed="yes"
                Cache="no"
                PerMachine="yes"
                Permanent="no"
                Vital="yes"
                InstallCommand="...">

                <ExitCode Value="3010" Behavior="forceReboot" />
                <ExitCode Value="1641" Behavior="forceReboot" />

            </ExePackage>
        </PackageGroup>
    </Fragment>

    <Fragment>
      <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="WebPageShortcutInstaller" />
        </Directory>
        <Directory Id="DesktopFolder">
          <Directory Id="DesktopShortcutID" />
        </Directory>
      </Directory>
    </Fragment>

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <Component Id="cmpWebPageShortcut" Guid="{}">
          <Shortcut Directory="DesktopFolder" Id="shortcutWebPage" Name="WEb Page" Description="WebPage" Target="[URL]" Icon="IconDesktop">
            <Icon Id="IconDesktop" SourceFile="favicon.ico" />
          </Shortcut>
          <RemoveFolder Id="removestartmenuFolder" Directory="DesktopShortcutID" On="uninstall" />
          <RegistryValue Root="HKCU" Key="..." Name="installed" Type="integer" Value="1" KeyPath="yes" />
        </Component>
      </ComponentGroup>
    </Fragment>
</Wix>

还有另一个Bundle.wxs,其中有一个像这样的链:

        <Chain> 

            <!-- Server -->
            <PackageGroupRef Id="PackageGroup" />
            <RollbackBoundary />
...
        </Chain> 

我想调用我的Bundle.wxs PackageGroup ,同时在destkop上创建图标。 当我尝试安装 PackageGroup 时,WIX安装程序运行正常。我的主要问题是在桌面上创建图标。我不知道为什么不创建。 功能ID 中的 ComponentGroupRef 不起作用。

我将这段代码改成另一种形状,用Product.wxs创建一个MSI,一切正常。

<?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
         xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
      
        <Product Id="*" Name="WebPageShortcutInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Waters" UpgradeCode="...">
            <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    
            <MediaTemplate EmbedCab="yes" />
    
            <Feature Id="ProductFeature" Title="WebPageShortcutInstaller" Level="1">
                <ComponentGroupRef Id="ProductComponents" />
            </Feature>
    
        <SetProperty Id="URL" Value="http://www.google.com" Sequence="execute"  Before="CreateShortcuts" />
    
      </Product>   
        <Fragment>
            <Directory Id="TARGETDIR" Name="SourceDir">
                <Directory Id="ProgramFilesFolder">
                    <Directory Id="INSTALLFOLDER" Name="WebPageShortcutInstaller" />
                </Directory>
          <Directory Id="DesktopFolder">
            <Directory Id="DesktopShortcutID" />
          </Directory>
            </Directory>
        </Fragment>      
        <Fragment>
            <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
          <Component Id="cmpWebPageShortcut" Guid="...">
            
            <Shortcut Directory="DesktopFolder" Id="shortcutWebPage" Name="Web Page" Description="WebPage" Target="[URL]" Icon="IconDesktop">
              <Icon Id="IconDesktop" SourceFile="favicon.ico" />
            </Shortcut>
                 
            <RemoveFolder Id="removestartmenuFolder" Directory="DesktopShortcutID" On="uninstall" />
            <RegistryValue Root="HKCU" Key="Software\..." Name="installed" Type="integer" Value="1" KeyPath="yes" />
          </Component>
            </ComponentGroup>
        </Fragment>
    </Wix>

注意:必须使用 PackageGroup ,因为我需要将ID调用到中。我只想为第一个选项制作正确的形状。

解决方法

Bundle不支持快捷方式或组件。他们需要进入Product