带有通用组件的 wix 安装程序 [英] wix installers with common component

查看:23
本文介绍了带有通用组件的 wix 安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have web app, which I want to install on IIS. This app supports plugins architecture. It consists of:

  1. 核心部分
  2. 插件 A
  3. 插件 B

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

I want to have 2 installers (msi). One for plugin A and other for plugin B. Each installer should also install Core Part. So if I run installer for plugin A it should install Core Part and Plugin A binaries. Then if I run Installer for plugin B it should install only Plugin B binaries. But if run installer for Plugin B as first it should install Core Part and Plugin B binaries.

我为 Core Part 使用了 WiX 合并模块项目,并为每个安装程序创建了 2 个 WiX 项目.但它不能如我所愿.

I used WiX Merge Module project for Core Part and created 2 WiX projects for each installer. But it does not work as I want.

这是它的工作原理:

  1. 我为插件 A 运行安装程序(工作正常)
  2. 我为插件 B 运行安装程序,它检测到产品已安装,显示删除、修复、更改页面
  3. 我选择了更改,我在功能树上看到了插件 A"而不是插件 B"

您可以在此处查看示例解决方案:https://github.com/bwojdyla/wixplugins在调试配置中工作.维克斯 3.9,VS2012

You can see sample solution here: https://github.com/bwojdyla/wixplugins Works in Debug configuration. Wix 3.9, VS2012

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

My merge module (Core part):

<?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 功能来实现这一点?

Or maybe there is other wix feature, which I should use, to achieve this?

推荐答案

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

Windows Installer identifies and reference counts components by their GUID; so basically what you need to do is to make sure that the common part components ("core") is included in both products with the same component guids. I.e. in principle you could achieve this not necessarily by creating a merge module, but for example by #including the code for the "core" part into both modules. Anyways, merge module is fine - it basically does more or less the same thing.

重要的是,PluginA 和 PluginB 应该有不同的产品 ID 和包 ID,否则它们在 Windows 安装程序中看起来是一样的(它通过它的 guid 标识正在安装的产品).现在,当您尝试安装 B 时,它认为实际上是在卸载 A,因此您会收到此消息.

What is important, you should have different product ids and package ids for the PluginA and PluginB, otherwise they look the same to the Windows Installer (it identifies the product being installed by it's guid). Now when you try to install B it thinks that it's actually A being uninstalled, thus you get this message.

因此您可以尝试像这样更改您的产品 A/B 文件(请注意,我还省略了packageid"——它是自动生成的,基本上所有 MSI 都应该具有不同的包 ID).

So you could try to change your product A/B files like this (note that I have omitted also the "packageid" - it is auto-generated, and basically all MSIs should have different package ids).

产品 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 引用计数:两个产品安装相同的 MSI

Here the reference counting is it explained in details: MSI Reference Counting: Two products install the same MSIs

这篇关于带有通用组件的 wix 安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆