如何在内置 InstallDir UI 中注入自定义 UI?

How can I inject my custom UI in the built-in InstallDir UI?

我想做的正是 Inserting a custom dialog into a built-in dialog set 中描述的内容: http://wixtoolset.org/documentation/manual/v3/wixui/wixui_customizations.html

上面链接的文档说我应该将 WixUI_InstallDir.wxs<Fragment> 之间的所有内容复制到我自己的源文件中。然后我可以调整 Publish 语句并插入我自己的 UI。 但是,当我尝试这样做时,我得到以下信息:

error LGHT0091: Duplicate symbol 'WixUI:WixUI_InstallDir' 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.

我想那是因为我的 Product.wxs:

<UIRef Id="WixUI_InstallDir" />

但是如果我删除它,我应该如何引用 InstallDir UI?因为当我删除它时,它会编译,但 InstallDir UI 不再显示。

我敢肯定我做错了什么,但这是我第一次弄乱 WiX,所以请放轻松 :)

供参考,这是我的完整 Product.wxs:

... 是 WixUI_InstallDir.wxs 的确切副本(从 <Fragment></Fragment>)所在的位置,我将其遗漏以防止此 post 获取太长了。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
  xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'
  xmlns:sql='http://schemas.microsoft.com/wix/SqlExtension'>
  <Product Id="*" Name="product" Language="1033" Version="1.0.0.0" Manufacturer="man" UpgradeCode="GUID">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

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

    <Feature Id="ProductFeature" Title="Shell.MACAM" Level="1">
      <ComponentRef Id="SqlComponent" />
    </Feature>

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
    <UIRef Id="WixUI_InstallDir" />

    <util:User Id='SQLUser' Name='[SQLUSER]' Password='[SQLPASSWORD]' />

    <UI>
      <Dialog Id="AskUserForSQLServer" Width="370" Height="270">
        <Control Type="Text" Id="SQLServerNameLabel" Width="50" Height="15" X="4" Y="8">
          <Text>SQL Server:</Text>
        </Control>
        <Control Type="Edit" Id="SQLServerName" Width="181" Height="15" X="60" Y="4">
        </Control>
      </Dialog>
    </UI>
    <UIRef Id="WixUI_Minimal" />
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="INETPUB" Name="Inetpub">
        <Directory Id="INSTALLFOLDER" Name="Shell.MACAM">
          <Component Id='SqlComponent' Guid='GUID'>
            <CreateFolder/>
            <sql:SqlDatabase Id='SqlDatabase' Database='[SQLDATABASE]' User='SQLUser' Server='[SQLSERVER]'
              CreateOnInstall='yes' DropOnUninstall='yes' ContinueOnError='yes'>
            </sql:SqlDatabase>
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
  ...
  </Wix>

您需要将对话框 "Id"(和文件名?)更改为不同的内容,以免发生 Id 冲突。然后您可以 include/reference 修改对话框的个人副本。

"Inserting" 对话框通过向 MSI 中的 ControlEvent table 添加行来工作。此 table 有一个 Order 列,可用于将您的 NewDialog 控件事件设置为 运行,其优先级高于现有事件。

我 运行 一个名为 IsWiX 的开源项目,它具有项目模板以加速设置开发。此模板的功能之一就是您要在此处执行的操作。 UI-CustomDialog.wxs 片段定义自定义对话框并插入行以将其置于循环中。 UI.wxs 片段引用了 WixUI_FeatureTree 对话框集,并且注释掉了对 UI-CustomDialog 片段的引用。取消注释,对话框变为活动状态。

不同的对话框集有不同的对话框,因此在引用不同的集时必须调整对话框前后的名称。

<!-- Insert into dialog sequencing by inserting control events on previous and next dialogs-->

<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="CustomDlg">1</Publish>

<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="CustomDlg" Order="3">NOT Installed</Publish>

http://iswix.codeplex.com/SourceControl/latest#main/Source/Application/IsWiXAddIn/SetupProjectTemplate/UI.wxs http://iswix.codeplex.com/SourceControl/latest#main/Source/Application/IsWiXAddIn/SetupProjectTemplate/UI-CustomDialog.wxs