1

我正在努力根据 WiX-Installer 中选择的功能创建桌面快捷方式。如果我运行安装程序,则不会出现快捷方式。如果只选择一个功能或两者都选择,则无关紧要。有什么想法吗?

<?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="XXX" Name="MyProduct" Language="1031" Codepage="1252" Version="4.4.0" Manufacturer="MyCompany" UpgradeCode="XXX">
    <Package Description="MyProductDescription" Comments="someText" InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Languages="1031"/>
    <Media Id="1" Cabinet="application.cab" EmbedCab="yes" CompressionLevel="high"/>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder" Name="PFiles">
            <Directory Name="LfF" Id="INSTALLDIR">
                <Directory Id="BIN" Name="bin"/>
                    <Component Id="App1.exe" Directory="BIN" Guid="XXX">
                        <File Id="App1.exe" KeyPath="yes" Source="$(var.src)\App1.exe" />
                    </Component>
                    <wix:Component Id="DesktopShortcutApp1" Directory="DesktopFolder" Guid="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
                        <wix:Shortcut Id="desktopShortcutApp1" Directory="DesktopFolder" Name="App1.exe" Target="[App1.exe]" WorkingDirectory="BIN" Icon="DesktopIconApp1.exe" IconIndex="0" />
                        <wix:RegistryValue Root="HKCU" Key="Software\[Manufacturer]\App1_Desktop_Shortcut" Name="installed" Type="integer" Value="1" />
                    </wix:Component>
                    <Component Id="App2.exe" Directory="BIN" Guid="XXX">
                        <File Id="App2.exe" KeyPath="yes" Source="$(var.src)\App2.exe" />
                    </Component>
                    <wix:Component Id="DesktopShortcutApp2" Directory="DesktopFolder" Guid="" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
                        <wix:Shortcut Id="desktopShortcutApp2" Directory="DesktopFolder" Name="App2.exe" Target="[App2.exe]" WorkingDirectory="BIN" Icon="DesktopIconApp2.exe" IconIndex="0" />
                        <wix:RegistryValue Root="HKCU" Key="Software\[Manufacturer]\App2_Desktop_Shortcut" Name="installed" Type="integer" Value="1" />
                    </wix:Component>
                </Directory>
            </Directory>
        </Directory>
        <Directory Id="DesktopFolder"/>
        <Directory Id="ProgramMenuFolder">
            <Directory Id="ProgramMenuDir" Name="MyProductName">
                <Component Id="StartMenuShortcuts" Guid="XXX">
                    <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
                    <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value=""/>
                </Component>
            </Directory>
        </Directory>
    </Directory>
    <Feature Id="App1" Level="1" Title="App1" TypicalDefault="advertise">
        <ComponentRef Id="App1.exe" />
        <ComponentRef Id="DesktopShortcutApp1" />
    </Feature>
    <Feature Id="App2" Level="1" Title="App2" TypicalDefault="advertise">
        <ComponentRef Id="App2.exe" />
        <ComponentRef Id="DesktopShortcutApp2"/>
    </Feature>
    <UI>
    </UI>
    <WixVariable Id="WixUIBannerBmp" Value="..\src\bannerapp.bmp"/>
    <WixVariable Id="WixUIDialogBmp" Value="..\src\dialogapp.bmp"/>
    <UIRef Id="WixUI_FeatureTree_NoLicense"/>
    <Icon Id="DesktopIconApp1.exe" SourceFile="$(var.src)\App1.exe"/>
    <Icon Id="DesktopIconApp2.exe" SourceFile=".$(var.src)\App2.exe"/>            
</Product>

该脚本是原始脚本的缩短版本。的内容Directory Id="BIN"是通过heat.exe 生成并使用xslt 修改的。

4

1 回答 1

0

经过多次尝试和错误,我找到了解决方案。

  1. 使快捷元素成为包含文件元素的组件的子元素
  2. 使图标元素成为快捷方式元素的子元素
  3. 在每个功能中设置Level="32767"and TypicalDefault="install"(这意味着:不要安装该功能)

在安装过程中,选择您要安装的功能,并且仅为此/这些创建桌面快捷方式。

这是代码:

<?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="XXX" Name="MyProduct" Language="1031" Codepage="1252" Version="4.4.0" Manufacturer="MyCompany" UpgradeCode="XXX">
        <Package Description="MyProductDescription" Comments="someText" InstallerVersion="400" Compressed="yes" InstallScope="perMachine" Languages="1031"/>
        <Media Id="1" Cabinet="application.cab" EmbedCab="yes" CompressionLevel="high"/>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder" Name="PFiles">
                <Directory Name="LfF" Id="INSTALLDIR">
                    <Directory Id="BIN" Name="bin"/>
                        <Component Id="App1.exe" Directory="BIN" Guid="XXX">
                            <File Id="App1.exe" KeyPath="yes" Source="$(var.src)\App1.exe" />
                            <Shortcut Id="desktopShortcutApp1" Directory="DesktopFolder" Name="App1.exe" WorkingDirectory="BIN" Advertise="yes">
                                <Icon Id="DesktopApp1.ico" SourceFile="$(var.src)/App1.ico" />
                            </Shortcut>
                        </Component>
                        <Component Id="App2.exe" Directory="BIN" Guid="XXX">
                            <File Id="App2.exe" KeyPath="yes" Source="$(var.src)\App2.exe" />
                            <Shortcut Id="desktopShortcutApp2" Directory="DesktopFolder" Name="App2.exe" WorkingDirectory="BIN" Advertise="yes">
                                <Icon Id="DesktopApp2.ico" SourceFile="$(var.src)/App2.ico" />
                            </Shortcut>
                        </Component>
                    </Directory>
                </Directory>
            </Directory>
            <Directory Id="DesktopFolder"/>
            <Directory Id="ProgramMenuFolder">
                <Directory Id="ProgramMenuDir" Name="MyProductName">
                    <Component Id="StartMenuShortcuts" Guid="XXX">
                        <RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
                        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value=""/>
                    </Component>
                </Directory>
            </Directory>
        </Directory>
        <Feature Id="App1" Level="32767" Title="App1" TypicalDefault="install">
            <ComponentRef Id="App1.exe" />
        </Feature>
        <Feature Id="App2" Level="32767" Title="App2" TypicalDefault="install">
            <ComponentRef Id="App2.exe" />
        </Feature>
        <UI>
        </UI>
        <WixVariable Id="WixUIBannerBmp" Value="$(var.src)/bannerapp.bmp"/>
        <WixVariable Id="WixUIDialogBmp" Value="$(var.src)/dialogapp.bmp"/>
        <UIRef Id="WixUI_FeatureTree_NoLicense"/>    
    </Product>
</Wix>
于 2014-07-22T08:37:46.733 回答