Windows Installer XML (WiX):添加自定义对话框

Posted

技术标签:

【中文标题】Windows Installer XML (WiX):添加自定义对话框【英文标题】:Windows Installer XML (WiX): adding custom dialog 【发布时间】:2015-04-16 16:21:52 【问题描述】:

我急需帮助。我已经被这个问题困扰了好几天,并且一直在寻找整个互联网,你是我最后的希望。

我一直在尝试使用 WIX 创建一个 Windows 安装程序,在我尝试自定义标准 UI 之前一切似乎都很好(具体而言,最小化)。

我正在尝试创建一个自定义对话框,该对话框将进入最小 UI 集,允许用户选择不同类型的安装 - 这似乎是一项不可能完成的任务。

当我尝试自定义时,编译会带来错误。请帮忙。

产品.wxs

<?xml version="1.0" encoding="UTF-8"?>

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

<?define vendor="Vendor" ?>
<?define productName="Product Name" ?>
<?define vendorAndProductName="$(var.vendor) $(var.productName)" ?>

<!--
    The language 1033 and codepage 1252 refer to 'English, US'
    See:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/localizing_the_error_and_actiontext_tables.asp
-->

    <Product Id="*"
                    Name="$(var.vendorAndProductName)"              
                    Language="1033"
                    Codepage="1252"
                    Version="$(var.version)"
                    Manufacturer="$(var.vendor)"
                    UpgradeCode="c338cb1c-8a1d-44e4-9aff-b2ad82f095fb">
                    <!--GUID defines product family, installed newer product versions in the same family will replace older versions-->

    <Package Id="*" 
                      Keywords="$(var.vendor) atm vm"
                      Description="$(var.vendorAndProductName) installer"
                      Manufacturer="$(var.vendor)"
                      InstallerVersion="110"
                      Platform="x86"
                      Languages="1033"
                      Compressed="yes"
                      SummaryCodepage="1252"
                      InstallScope="perMachine" />                       

    <!-- the property creates a help link -->
    <Property Id="ARPHELPLINK" Value="www.google.com" />

    <!-- the type of interface used; minimal -->
    <UIRef Id="WixUI_AAAMinimal" />

    <!-- this action executes the application at the end of the install -->
    <CustomAction Id="LaunchApplication" 
                               FileKey="fil6D1977925280798FCA16255AB9A3BF63"                               
                               ExeCommand="" 
                               Execute="immediate" 
                               Impersonate="yes" 
                               Return="asyncNoWait" />

    <!-- these properties illustrate the 2 options for execuating/ not the application at the end of installiation -->
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.productName)" />
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />

    <!-- the install wizard interface customization -->
    <UI>
        <Publish Dialog="ExitDialog" 
                     Control="Finish" 
                     Event="DoAction" 
                     Order="1" 
                     Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>

    </UI>

    <!-- these varaiables are used within the install interface -->
    <WixVariable Id="WixUILicenseRtf" Value="include\License.rtf" />
    <WixVariable Id="WixUIDialogBmp" Value="include\dialog.jpg"/>
    <WixVariable Id="WixUIBannerBmp" Value="include\banner.jpg"/>

    <MajorUpgrade DowngradeErrorMessage="A newer version is already installed." />

    <!--Require admin priviliges-->
    <Condition Message="This software must be installed with administrative priviliges.">Privileged</Condition>

    <Media Id='1' Cabinet='xfsconfigsetupinstaller.cab' EmbedCab='yes'/>

    <!--Defines folders-->
    <Directory Id="TARGETDIR" Name="SourceDir">

        <Directory Id="AAA" Name="vendor" />

    </Directory>

    <!-- creates the system variables on the computer -->
    <Component Id="sysVar" Directory="TARGETDIR" Guid="30a5b0a5-3c88-40df-ba87-6d8e2bb4afa7">
        <Environment Id="systemVariable1" Name="PATH" Value="C:\Vendor" Permanent="no" Part="last" Action="set" System="yes" />
        <Environment Id="systemVariable2" Name="PATH" Value="C:\Vendor\bbbbbb" Permanent="no" Part="last" Action="set" System="yes" />
    </Component>

    <!--Reference all components and component groups in a Feature-->
    <Feature Id="Complete" 
                    Display="expand"
                    Level="1"
                    ConfigurableDirectory="C2P"
                    Title="Test0.0.0"
                    Description="Test Copy File">
        <ComponentGroupRef Id="VirutalMachine" />
        <ComponentRef Id="sysVar" />
    </Feature>  

    </Product>
</Wix>

编译.bat

@echo off
setlocal

rem Set the WiX tools path
set wixTools="C:\Program Files (x86)\WiX Toolset v3.9\bin"

rem Heat.exe is used to harvest the directory and generate components
%wixTools%\heat.exe dir "C:\program\VirtualMachine" -dr C2P -cg VirtualMachine -gg -scam -sreg -sfrag -srd -out "%~dp0\heat.wxs" || goto installer_failure

rem Generate the msi file
%wixTools%\candle.exe Installer.wxs heat.wxs WixUI_AAAMinimal.wxs -dversion=%version% -ext WiXUIExtension
%wixTools%\light.exe Installer.wixobj heat.wixobj WixUI_AAAMinimal.wixobj -out Installer.msi -ext WiXUIExtension
echo Successfully created installer XFSConfigInstaller.msi.
pause
exit /b 0

:installer_failure
exit /b 1

WixUI_AAAMinimal.wxs

<?xml version="1.0" encoding="UTF-8"?>
<!--
  <copyright file="WixUI_Minimal.wxs" company="Outercurve Foundation">
    Copyright (c) 2004, Outercurve Foundation.
    This software is released under Microsoft Reciprocal License (MS-RL).
    The license and further copyright text can be found in the file
    LICENSE.TXT at the root directory of the distribution.
  </copyright>
-->

<!--
First-time install dialog sequence:
 - WixUI_WelcomeEulaDlg

Maintenance dialog sequence:
 WixUI_MaintenanceWelcomeDlg
 - WixUI_MaintenanceTypeDlg
 - WixUI_VerifyReadyDlg

Patch dialog sequence:
 - WixUI_WelcomeDlg
 - WixUI_VerifyReadyDlg
-->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <UI Id="WixUI_C2PMinimal">
            <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
            <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
            <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

            <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
            <Property Id="WixUI_Mode" Value="Minimal" />

            <DialogRef Id="ErrorDlg" />
            <DialogRef Id="FatalError" />
            <DialogRef Id="FilesInUse" />
            <DialogRef Id="MsiRMFilesInUse" />
            <DialogRef Id="PrepareDlg" />
            <DialogRef Id="ProgressDlg" />
            <DialogRef Id="ResumeDlg" />
            <DialogRef Id="UserExit" />
            <DialogRef Id="WelcomeDlg" />
            <DialogRef Id="WelcomeEulaDlg" />

            <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

            <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

            <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
            <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
            <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>

            <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
            <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>

            <InstallUISequence>
                <Show Dialog="WelcomeDlg" Before="WelcomeEulaDlg">Installed AND PATCH</Show>
                <Show Dialog="WelcomeEulaDlg" Before="ProgressDlg">NOT Installed</Show>
            </InstallUISequence>

            <Property Id="ARPNOMODIFY" Value="1" />
        </UI>

        <UIRef Id="WixUI_Common" />
    </Fragment>
</Wix>

输出

Duplicate symbol 'ControlEve
nt:WelcomeDlg/Next/NewDialog/VerifyReadyDlg/Installed AND PATCH' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique.

error LGHT0091 : Duplicate symbol 'Property:WixUI_Mode' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique

在我尝试自定义 UI 或对话框之前,这一切都有效。感谢您的帮助 - 提前。

【问题讨论】:

【参考方案1】:

在您引用的片段中

<Property Id="WixUI_Mode" Value="Minimal" />

我相信它是在抱怨,因为您稍后也会调用它。

<UIRef Id="WixUI_Common" />

如果您使用的是通用 ref,则不需要 top 属性。

【讨论】:

以上是关于Windows Installer XML (WiX):添加自定义对话框的主要内容,如果未能解决你的问题,请参考以下文章

windows installer删除

win7怎样删除windows installer服务

安装python失败,报错0X80070641 无法访问Windows Installer服务,已经确认启动了Windows Installer服务

有没有办法在没有卸载注册表或 C:\Windows\Installer 的情况下检测安装位置?

打开Windows Installer Clean Up,怎么也没看到注册表呢,那些事注册表啊?谢谢!打开Windows Installer Cl

Windows下通过MySQL Installer安装MySQL服务