1

我使用收获创建了一个 MyProjectOutput.wxs 文件并在其上应用 xml 转换以在该文件中创建一个 UI 片段以填充 ComboBox。我还有一个单独的 UI wxs 文件,我在其中定义了一个使用此 ComboBox 的 CustomDialog.wxs。但是,除非我将此组合框定义放在 CustomDialog.wxs 文件中,否则它会给我 2205(数据库错误)。以下是我的文件

MyProjectOutput.wxs - 在这个文件中,UI 的最后一个片段是通过在这个文件上应用 xml 转换,通过读取文件节点的源属性生成的。

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="CONFIGFILES">
            <Component Id="cmp7562915D30BE22E32E71CF7CD6CBAB77" Guid="{86AC4144-0BE0-476E-923B-B44436F8829E}">
                <File Id="fil9E9BBB7231B6BD796147C7D0AE291065" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Dev1.config" />
            </Component>
            <Component Id="cmp6C3AFA41B8BBCF9D0DF28242C6B429D1" Guid="{BD2E6990-13A8-44EA-9DAA-20CBEC67482F}">
                <File Id="fil5B747B1CE3640230ED3789B3F4E05C3C" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Dev2.config" />
            </Component>
            <Component Id="cmp9998AAEE2DED02EF9A0712D074E9C8FC" Guid="{B790866E-C07F-45DD-8C63-627DBED78A40}">
                <File Id="fil755065F43A05FE597055F31A20242E72" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Dev3.config" />
            </Component>
            <Component Id="cmp9130D649B8658E7957A82AE58D8820BC" Guid="{EC6D020B-F2D9-490E-B70A-05A956E8111F}">
                <File Id="filD6D44C4AE3547883AE37DCF2C0322608" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Integration-Dev.config" />
            </Component>
            <Component Id="cmp7DC1EB525FA874FEDD5FDEE84DFFD787" Guid="{04E1BF0D-C879-4845-91E6-E4F469D9C688}">
                <File Id="fil6EDE1F9E7394B049CE4B88F3670AE891" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Integration-Main.config" />
            </Component>
            <Component Id="cmpFCB72E3C787BFAA9304121A8F37006F7" Guid="{5A17F58F-D206-4482-9DB4-44DACBA49019}">
                <File Id="filCEFACF9829EBAB61DDFB303933AFD489" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Local-Dev.config" />
            </Component>
            <Component Id="cmpD5E1D9120D86A34424CBA0918AEBA73E" Guid="{8A79CEB6-3075-4B97-9555-253D1701D88E}">
                <File Id="fil444F50F7AF28DF82052DDC1626A45398" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Local-Main.config" />
            </Component>
            <Component Id="cmp061DAE6DDCA07E4424FBBF175772A0B2" Guid="{74156629-516A-4E78-ADD0-498309EBB95D}">
                <File Id="fil6F7713DFE7490535719BE8B04C835B3D" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.Prod.config" />
            </Component>
            <Component Id="cmpADCB9112292B28FFC0E91215127D2A58" Guid="{1875243D-10C9-4B59-917C-4E315A508AFA}">
                <File Id="filAE0C330E233428662B044F5912A00E62" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.QA-Dev.config" />
            </Component>
            <Component Id="cmpC5C9EA61F18F501EB6E7603AE2B1CD30" Guid="{4810C5F7-7ABF-4923-AC94-57159231F516}">
                <File Id="filFDB550D00B6BCBE7BA48D88EDE8B74A7" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.QA-Main.config" />
            </Component>
            <Component Id="cmp172C61070E786846F0A44679222C79F5" Guid="{A1A90FF7-40CF-471E-A8B8-65E205B9452B}">
                <File Id="fil114E22D9F022C977458C29000645C1F6" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.QA1.config" />
            </Component>
            <Component Id="cmp552464D37F0921636903B5A62C290CF3" Guid="{4FFF8BE5-D74E-4B1A-BD02-270B3A4F219C}">
                <File Id="fil8A2CAFEF430811850DB7B42887D44A52" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.QA2.config" />
            </Component>
            <Component Id="cmpB6506383D32CDB0027F8CD3C7CBE94FB" Guid="{FD09FF40-1BD8-4117-A0D1-D445CDF6CCA2}">
                <File Id="filB6E5A82CD73E75255FE6B3C3BF20D1B0" KeyPath="yes" Source="$(var.ConfigFilesDir)\Web.QA3.config" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="WebConfigFiles">
            <ComponentRef Id="cmp7562915D30BE22E32E71CF7CD6CBAB77" />
            <ComponentRef Id="cmp6C3AFA41B8BBCF9D0DF28242C6B429D1" />
            <ComponentRef Id="cmp9998AAEE2DED02EF9A0712D074E9C8FC" />
            <ComponentRef Id="cmp9130D649B8658E7957A82AE58D8820BC" />
            <ComponentRef Id="cmp7DC1EB525FA874FEDD5FDEE84DFFD787" />
            <ComponentRef Id="cmpFCB72E3C787BFAA9304121A8F37006F7" />
            <ComponentRef Id="cmpD5E1D9120D86A34424CBA0918AEBA73E" />
            <ComponentRef Id="cmp061DAE6DDCA07E4424FBBF175772A0B2" />
            <ComponentRef Id="cmpADCB9112292B28FFC0E91215127D2A58" />
            <ComponentRef Id="cmpC5C9EA61F18F501EB6E7603AE2B1CD30" />
            <ComponentRef Id="cmp172C61070E786846F0A44679222C79F5" />
            <ComponentRef Id="cmp552464D37F0921636903B5A62C290CF3" />
            <ComponentRef Id="cmpB6506383D32CDB0027F8CD3C7CBE94FB" />
        </ComponentGroup>
    </Fragment>
    <Fragment>
        <UI>
            <ComboBox Property="ENV">
                <ListItem Value="Dev1" Text="Dev1" />
                <ListItem Value="Dev2" Text="Dev2" />
                <ListItem Value="Dev3" Text="Dev3" />
                <ListItem Value="Integration-Dev" Text="Integration-Dev" />
                <ListItem Value="Integration-Main" Text="Integration-Main" />
                <ListItem Value="Local-Dev" Text="Local-Dev" />
                <ListItem Value="Local-Main" Text="Local-Main" />
                <ListItem Value="Prod" Text="Prod" />
                <ListItem Value="QA-Dev" Text="QA-Dev" />
                <ListItem Value="QA-Main" Text="QA-Main" />
                <ListItem Value="QA1" Text="QA1" />
                <ListItem Value="QA2" Text="QA2" />
                <ListItem Value="QA3" Text="QA3" />
            </ComboBox>
        </UI>
    </Fragment>
</Wix>

CustomDialog.wxs - 这个不起作用。它不包含 ComboBox 定义。运行安装程序后,它给了我 MSI 数据库的 2205 错误。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI>
      <Dialog Id="EnvironmentSelectionDlg"  Width="370" Height="270" Title="!(loc.EnvironmentSelectionDlg_Title)">
        <Control Id="EnvironmentCombo" Type="ComboBox" X="18" Y="82" Width="200" Height="20" Property="ENV" TabSkip="yes" Sorted="yes" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
      </Dialog>
    </UI>
  </Fragment>
</Wix>

CustomDialog.wxs - 这个工作。它包含 ComboBox 定义。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI>
      <ComboBox Property="ENV">
        <ListItem Value="Dev1" Text="Dev1" />
        <ListItem Value="Dev2" Text="Dev2" />
        <ListItem Value="Dev3" Text="Dev3" />
        <ListItem Value="Integration-Dev" Text="Integration-Dev" />
        <ListItem Value="Integration-Main" Text="Integration-Main" />
        <ListItem Value="Local-Dev" Text="Local-Dev" />
        <ListItem Value="Local-Main" Text="Local-Main" />
        <ListItem Value="Prod" Text="Prod" />
        <ListItem Value="QA-Dev" Text="QA-Dev" />
        <ListItem Value="QA-Main" Text="QA-Main" />
        <ListItem Value="QA1" Text="QA1" />
        <ListItem Value="QA2" Text="QA2" />
        <ListItem Value="QA3" Text="QA3" />
      </ComboBox>
      <Dialog Id="EnvironmentSelectionDlg"  Width="370" Height="270" Title="!(loc.EnvironmentSelectionDlg_Title)">
        <Control Id="EnvironmentCombo" Type="ComboBox" X="18" Y="82" Width="200" Height="20" Property="ENV" TabSkip="yes" Sorted="yes" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
      </Dialog>
    </UI>
  </Fragment>
</Wix>

请建议我是否需要做任何其他事情才能不在 CustomDialog.wxs 中定义 ComboBox 元素来完成这项工作。

4

1 回答 1

2

您需要将生成的 UI 标记更改为具有 Id 属性:

<UI Id='ComboBox'>
    <ComboBox Property="ENV">
        <ListItem Value="Dev1" Text="Dev1" />
        <ListItem Value="Dev2" Text="Dev2" />
        <ListItem Value="Dev3" Text="Dev3" />
        <ListItem Value="Integration-Dev" Text="Integration-Dev" />
        <ListItem Value="Integration-Main" Text="Integration-Main" />
        <ListItem Value="Local-Dev" Text="Local-Dev" />
        <ListItem Value="Local-Main" Text="Local-Main" />
        <ListItem Value="Prod" Text="Prod" />
        <ListItem Value="QA-Dev" Text="QA-Dev" />
        <ListItem Value="QA-Main" Text="QA-Main" />
        <ListItem Value="QA1" Text="QA1" />
        <ListItem Value="QA2" Text="QA2" />
        <ListItem Value="QA3" Text="QA3" />
    </ComboBox>
</UI>

然后添加<UIRef Id='ComboBox' />到 CustomDialog.wxs 中,以便它可以“看到”它。

于 2013-03-12T18:29:45.497 回答