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

时间:2015-04-16 16:21:52

标签: wix wix3.9

我迫切需要帮助。我已经被困在这个问题上好几天了,一直在寻找互联网,你是我最后的希望。

我一直在尝试使用WIX创建一个Windows Installer,直到我尝试自定义标准UI(最小化为特定用户界面)时,一切似乎都很好。

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

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

Product.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>

的compile.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或Dialog之前,只说这一切都有效。感谢您的帮助 - 提前。

1 个答案:

答案 0 :(得分:0)

在您的片段中,您正在引用

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

我相信这是抱怨,因为你后来也会这样说。

<UIRef Id="WixUI_Common" />

如果您使用的是公共参考,则不需要top属性。