WIX破碎的快捷方式图标

时间:2016-10-16 03:24:48

标签: wix

我有一个简单的wix设置安装可执行文件和几个dll。一切正常,除了桌面快捷方式不是C:\ Program Files中可执行文件的常规链接,但隐藏可执行位置的一些奇怪的registry-guid-type链接。最重要的是,此快捷方式的图标来自安装程序文件夹,而不是可执行文件本身的图标。

如何创建c:\ program files \ mycompany \ myproduct.exe的常规普通旧简单快捷方式,而不是这个奇特的快捷方式?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="MyProduct" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="11111111-1111-1111-1111-111111111111">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

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

        <Feature Id="ProductFeature" Title="MyCompany.Desktop.Setup" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
            <ComponentRef Id='ProgramMenuDir' />
        </Feature>
        <Icon Id="MyProduct.ico" SourceFile="MyProduct.ico" />

        <UI>
            <UIRef Id="WixUI_Minimal" />
            <Publish Dialog="ExitDialog"
                Control="Finish"
                Event="DoAction"
                Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
        </UI>
        <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open MyProduct now" />
        <Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Success! MyProduct is now installed." />

        <CustomAction Id="CA_Set_WIXUI_EXITDIALOGOPTIONALTEXT" Property="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Oops! Unfortunately, the installer ran into a problem and MyProduct was not installed."/>
        <InstallUISequence>
            <Custom Action="CA_Set_WIXUI_EXITDIALOGOPTIONALTEXT" After="FindRelatedProducts">Installed</Custom>
        </InstallUISequence>

        <Property Id="WixShellExecTarget" Value="[#MyProductEXE]" />
        <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="MyProduct">
                </Directory>
            </Directory>

            <Directory Id="ProgramMenuFolder" Name="Programs">
                <Directory Id="ProgramMenuDir" Name="MyProduct">
                    <Component Id="ProgramMenuDir">
                        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
                        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
                    </Component>
                </Directory>
            </Directory>

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

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="MainExecutable">
                <File Id='MyProductEXE' Source='$(var.MyCompany.Desktop.TargetPath)' KeyPath='yes'>
                    <Shortcut Id="startmenuMyProduct" Directory="ProgramMenuDir" Name="MyProduct" WorkingDirectory='INSTALLDIR' Icon="MyProduct.ico" IconIndex="0"  Advertise="yes" />
                    <Shortcut Id="desktopMyProduct" Directory="DesktopFolder" Name="MyProduct" Description="MyProduct Description" WorkingDirectory='INSTALLDIR' Icon="MyProduct.ico" IconIndex="0" Advertise="yes" />
                </File>
            </Component>
            <Component Id='CommonLibrary'>
                <File Id='CommonDLL' Source='$(var.MyCompany.Desktop.TargetDir)\MyCompany.Common.dll' KeyPath='yes' />
            </Component>
            <Component Id='CSVLibrary'>
                <File Id='CSVDLL' Source='$(var.MyCompany.Desktop.TargetDir)\CsvHelper.dll' KeyPath='yes' />
            </Component>
            <Component Id='InputLibrary'>
                <File Id='WinInpDLL' Source='$(var.MyCompany.Desktop.TargetDir)\WindowsInput.dll' KeyPath='yes' />
            </Component>
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <Component Id="DesktopShortcut" Directory="APPLICATIONFOLDER" Guid="*">
            <RegistryValue Id="RegShortcutDesktop" Root="HKCU" 
                    Key="Software\[Manufacturer]\[ProductName]" Name="DesktopSC" Value="1" 
                    Type="integer" KeyPath="yes" />
            <Shortcut Id="desktopSC" Target="[APPLICATIONFOLDER]MyCompany.Desktop.exe"
                    Directory="DesktopFolder" Name="MyProduct" 
                    Icon="MyProduct.ico" IconIndex="0"
                    WorkingDirectory="APPLICATIONFOLDER" Advertise="no"/>
        </Component>
    </Fragment>
</Wix>

1 个答案:

答案 0 :(得分:2)

产品功能中缺少对DesktopShortcut组件的组件引用。您的ProductFeature应如下所示:

    <Feature Id="ProductFeature" Title="MyCompany.Desktop.Setup" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
        <ComponentRef Id='ProgramMenuDir' />
        <ComponentRef Id='DesktopShortcut' />
    </Feature>

将DesktopShortcut组件修改为:

    <!--DesktopShortcut-->
<DirectoryRef Id="DesktopFolder">  
  <Component Id="DesktopShortcut" 
             Guid="GENERATE A GUID FOR THIS COMPONENT">

    <Shortcut Id="desktopSC" 
              Name="MyProduct" 
              Description="MyProduct description" 
              Target="[APPLICATIONFOLDER]MyCompany.Desktop.exe"
              Icon="MyProduct.ico">
    </Shortcut>
    <RemoveFolder Id="RemoveDesktopFolder" 
                  Directory="DesktopFolder" 
                  On="uninstall" />
    <RegistryValue Root="HKCU" 
                   Key="Software\[Manufacturer]\[ProductName]" 
                   Name="installed" 
                   Type="integer" 
                   Value="1" 
                   KeyPath="yes" />
  </Component>
</DirectoryRef>

这应该为您的应用程序提供简单,陈旧,简单的桌面快捷方式。 值得一提的几点:

  • 添加了RemoveFolder标记。这将确保在卸载应用程序时也删除桌面快捷方式。
  • 确保为DesktopShortcut组件生成不变的GUID。这可以保证在安装/卸载过程中文件的一致性和可管理性。
  • 请注意,桌面文件夹的目录引用包含在DesktopShortcut组件中。这将确保将快捷方式放在适当的位置。 在这种情况下,桌面。

希望这有帮助!