具有通用组件的wix安装程序

时间:2015-01-31 14:16:15

标签: wix windows-installer

我有网络应用,我想在IIS上安装。此应用程序支持插件架构。 它包括:

  1. 核心部分
  2. 插件A
  3. 插件B
  4. 我想要2个安装程序(msi)。一个用于插件A,另一个用于插件B. 每个安装程序还应安装Core Part。因此,如果我为插件A运行安装程序,它应该安装Core Part和Plugin A二进制文件。然后,如果我为插件B运行安装程序,它应该只安装插件B二进制文件。但是如果首先运行Plugin B的安装程序,它应该安装Core Part和Plugin B二进制文件。

    我为Core Part使用了WiX Merge Module项目,并为每个安装程序创建了2个WiX项目。但它不能按我的意愿工作。

    这是它的工作原理:

    1. 我为插件A运行安装程序(工作正常)
    2. 我运行插件B的安装程序,它检测到产品已经安装,显示删除,修复,更改页面
    3. 我选择更改,我在功能树上看到“插件A”,而不是“插件B”
    4. 您可以在此处查看示例解决方案:https://github.com/bwojdyla/wixplugins 适用于Debug配置。 Wix 3.9,VS2012

      我的合并模块(核心部分):

      <?xml version="1.0" encoding="UTF-8"?>
      <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
          <Module Id="CoreModule" Language="1033" Version="1.0.0.0">
              <Package Id="751e70eb-cf76-413b-b8c8-231a31f9c946" Manufacturer="test" InstallerVersion="200" />
      
          <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="INSTALLFOLDER" Name="PluginInstaller">
              <Component Id="CoreComp" Guid="{161F78E1-0ABD-4FCD-92FC-6095A45F78B3}">
                <File Id="CoreFile" KeyPath="yes" Source=".\Core.txt" />
              </Component>
            </Directory>
          </Directory>
          </Module>
      </Wix>
      

      插件A:

      <?xml version="1.0" encoding="UTF-8"?>
      <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
          <Product Id="{8E93D1E7-C05F-40A0-B737-C053C1EE3E0A}" Name="PluginInstaller" Language="1033" Version="1.0.0.0" Manufacturer="test" UpgradeCode="eed33233-e773-45c2-87a1-ab349191a30a">
              <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Id="{9C7D28B4-FBAD-4FE6-A204-8F6A11D89792}"/>
      
              <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
              <Media Id="1" Cabinet="Cab1.cab" EmbedCab="yes" />
      
          <UIRef Id="WixUI_FeatureTree"/>
      
          <FeatureRef Id="ProductFeature">
            <Feature Id="PluginA" Title="Plugin A" Level="1" AllowAdvertise="no">
              <ComponentGroupRef Id="ProductComponents" />
            </Feature>
          </FeatureRef>
          </Product>
      
          <Fragment>
              <Directory Id="TARGETDIR" Name="SourceDir">
                  <Directory Id="ProgramFilesFolder">
                      <Directory Id="INSTALLFOLDER" Name="PluginInstaller" />
              <Merge Id="CoreModule" Language="1033" SourceFile="..\CoreModule\bin\Debug\CoreModule.msm" DiskId="1" />
                  </Directory>
              </Directory>
          </Fragment>
      
          <Fragment>
              <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="PluginAComp" Guid="{7641AF10-B2EF-4639-A0B4-34AE819CAD38}">
              <File Id="PluginAFile" KeyPath="yes" Source=".\PluginA.txt" />
            </Component>
              </ComponentGroup>
          </Fragment>
      </Wix>
      

      插件B:

      <?xml version="1.0" encoding="UTF-8"?>
      <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
        <Product Id="{8E93D1E7-C05F-40A0-B737-C053C1EE3E0A}" Name="PluginInstaller" Language="1033" Version="1.0.0.0" Manufacturer="test" UpgradeCode="eed33233-e773-45c2-87a1-ab349191a30a">
          <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Id="{9C7D28B4-FBAD-4FE6-A204-8F6A11D89792}"/>
      
          <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
          <Media Id="1" Cabinet="Cab1.cab" EmbedCab="yes" />
      
          <UIRef Id="WixUI_FeatureTree"/>
      
          <FeatureRef Id="ProductFeature">
            <Feature Id="PluginB" Title="Plugin B" Level="1" AllowAdvertise="no">
              <ComponentGroupRef Id="ProductComponents" />
            </Feature>
          </FeatureRef>
      
        </Product>
      
        <Fragment>
          <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
              <Directory Id="INSTALLFOLDER" Name="PluginInstaller" />
              <Merge Id="CoreModule" Language="1033" SourceFile="..\CoreModule\bin\Debug\CoreModule.msm" DiskId="1" />
            </Directory>
          </Directory>
        </Fragment>
      
        <Fragment>
          <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <Component Id="PluginBComp" Guid="{D11704D9-9911-483A-B204-B2171DCB0E67}">
              <File Id="PluginBFile" KeyPath="yes" Source=".\PluginB.txt" />
            </Component>
          </ComponentGroup>
        </Fragment>
      </Wix>
      

      或许还有其他的wix功能,我应该用它来实现这个目标?

2 个答案:

答案 0 :(得分:0)

Windows Installer通过GUID识别和引用计数组件;所以基本上你需要做的是确保公共部件组件(“核心”)包含在具有相同组件guid的两个产品中。即原则上你可以通过创建合并模块来实现这一点,但是例如通过#include两个模块中“核心”部分的代码。无论如何,合并模块很好 - 它基本上或多或少都是一样的。

重要的是,您应该为PluginA和PluginB提供不同的产品ID和包ID,否则它们看起来与Windows Installer相同(它标识由其guid安装的产品)。现在,当您尝试安装B时,它认为它实际上是A正在卸载,因此您收到此消息。

所以你可以尝试更改你的产品A / B文件(注意我也省略了“packageid” - 它是自动生成的,基本上所有的MSI都应该有不同的包ID。)

产品A

  <Product Id="{4D7828A0-F55C-4D26-9AA9-914FF646C55E}" Name="PluginInstallerA" Language="1033" Version="1.0.0.0" Manufacturer="test" UpgradeCode="eed33233-e773-45c2-87a1-ab349191a30a">
      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

产品B

<Product Id="{E052B5C0-BB4D-4848-844C-2293059E9465}" Name="PluginInstallerB" Language="1033" Version="1.0.0.0" Manufacturer="test" UpgradeCode="eed33233-e773-45c2-87a1-ab349191a30a">
  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

这里引用计数是详细解释的: MSI Reference Counting: Two products install the same MSIs

答案 1 :(得分:0)

在这些情况下,两个包都始终安装核心部件。这是正常情况。您不希望处于安装A和核心然后在没有核心的情况下安装B的情况,因为卸载A将删除B正在使用的核心。核心在两者中,因此引用计数意味着您可以安装两个然后卸载一个,核心仍将存在。当B安装在A上时发生的一切都没有(因为文件版本相同而且它们位于相同的位置)或者某些文件被更新(因为最后安装的插件具有公共位置中文件的更新版本)。正如Nikolay所说,你通过拥有一个核心部分(如在两个MSI中添加了一个合并模块)或者通过其他方式确保基于组件guid的共享是正确的来安排所有这些工作。

相关问题