在使用WiX Burn MBA软件包的MajorUpgrade中,如何检测当前安装的功能? [英] How do I detect the currently installed features during a MajorUpgrade using WiX Burn MBA Bundles?

查看:70
本文介绍了在使用WiX Burn MBA软件包的MajorUpgrade中,如何检测当前安装的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WiX 3.7的Burn/Managed Bootstrapper应用程序功能来创建基于MBA的自定义安装程序.对于捆绑包链中的每个软件包,在执行MinorUpdate时,我可以通过使用引导程序的WiX基类中提供的这些事件,轻松地检测到哪些软件包功能已安装,以确保在升级期间维护这些功能选择.: DetectPackageComplete DetectMsiFeature DetectRelatedBundle DetectRelatedMsiPackage DetectComplete .

I'm using WiX 3.7's Burn/Managed Bootstrapper Application features to create a custom MBA-based installer. For each of the packages in my bundle's chain, when performing a MinorUpdate, I can easily detect which of the package features are already installed to ensure I maintain those feature selections during the upgrade by using these events provided in the WiX base class for the bootstrapper: DetectPackageComplete, DetectMsiFeature, DetectRelatedBundle, DetectRelatedMsiPackage, DetectComplete.

但是,在MajorUpgrade期间,我只看到一种确定已安装哪些软件包的方法,而没有看到如何确定已安装哪些功能的方法,因为DetectMsiFeature事件不会触发.我尝试在产品的配置上使用 MigrateFeatures 标志,但这似乎不起作用(或者我没有正确使用).

However, during a MajorUpgrade, I'm only seeing a way to determine which package(s) are installed, but am not seeing how to determine which features are installed, as the DetectMsiFeature event does not fire. I tried using the MigrateFeatures flag on the product's configuration, but that doesn't seem to work (or I'm not using it right).

在WiX中使用自定义托管引导程序应用程序执行MajorUpgrade时,检测/迁移现有功能的正确方法是什么?


注意:如果有帮助,我可以提供一个包含所有代码的完全可用的VS解决方案.

Note: I can provide a fully working VS Solution with all code if that is helpful.

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
    <Bundle Name="Bootstrapper1"  Version="1.1.0.0" Manufacturer="Knights Who Say Ni" UpgradeCode="e6fbf160-d1d9-4b38-b293-94d60eae876f" Compressed="yes">    
        <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
          <Payload SourceFile="$(var.ManagedBootstrapperApplication.TargetPath)" />
          <!-- other files here -->
        </BootstrapperApplicationRef>
        <Chain>      
          <PackageGroupRef Id="NetFx40Web" />
          <MsiPackage SourceFile="$(var.SetupProject1.TargetPath)" EnableFeatureSelection="yes" Vital="yes"  Compressed="yes" />
        </Chain>
    </Bundle>
</Wix>

Product.wxs:

Product.wxs:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="SetupProject1" Language="1033" Codepage="1252"
           Version="1.1.0.0" Manufacturer="Knights Who Say Ni" 
           UpgradeCode="5fcd463a-3287-4fdf-bf00-d5d74baeccda">

        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <MajorUpgrade AllowSameVersionUpgrades="no" AllowDowngrades="no" MigrateFeatures="yes" DowngradeErrorMessage="Bring me a shrubbery!" />
        <MediaTemplate EmbedCab="yes" />

        <Feature Id="feature_one" Title="Primary Feature" Level="1">      
          <Component Id="CMP_emptyFile1" Guid="{1740AFA6-A98F-482A-B319-A153AA1BEF10}" Directory="INSTALLFOLDER">
            <File Id="file_emptyFile1" Checksum="yes" KeyPath="yes" Source="TextFile1.txt" />
          </Component>      
        </Feature>
        <Feature Id="feature_Two" Title="Optional Feature" Level="2">
          <Component Id="CMP_emptyFile2" Guid="{F0831C98-AF35-4F5E-BE9A-2F5E3ECF893C}" Directory="INSTALLFOLDER">
            <File Id="file_emptyFile2" Checksum="yes" KeyPath="yes" Source="TextFile2.txt"  />
          </Component>
        </Feature>    
    </Product>
</Wix>

CustomBootstrapper.cs

CustomBootstrapper.cs

public class CustomBootstrapperApplication : BootstrapperApplication {        
    protected override void Run() {
            DetectPackageComplete += HandlePackageDetected;
            DetectMsiFeature += HandleFeatureDetected;
            DetectRelatedBundle += HandleExistingBundleDetected;
            DetectRelatedMsiPackage += HandleExistingPackageDetected;
            DetectComplete += HandleDetectComplete;
            this.Engine.Detect();
            //blocks here until DetectComplete fires...
    }

    private void HandleExistingPackageDetected(object sender, DetectRelatedMsiPackageEventArgs e) {
        Log(string.Format("Detected Related Package {2} ({1}) at version {3} which is a {0}",
            e.Operation, e.PackageId, e.ProductCode, e.Version));
    }

    private void HandleExistingBundleDetected(object sender, DetectRelatedBundleEventArgs e) {
        Log(string.Format("Detected Related {2} Bundle {0} at version {1} which is a {3}",
            e.ProductCode, e.Version, e.RelationType, e.Operation));
    }

    private void HandleFeatureDetected(object sender, DetectMsiFeatureEventArgs e) {
        Log(string.Format("Feature {0} from Package {1} detected in state {2}",
            e.FeatureId, e.PackageId, e.State));
    }

    private void HandlePackageDetected(object sender, DetectPackageCompleteEventArgs e) {
        Log(string.Format("Package {0} Detected in State {1}",
            e.PackageId, e.State));
    }

    private void HandleDetectComplete(object sender, DetectCompleteEventArgs e)
    { /* release the main thread to continue with work */ }

}

升级后的输出:

请注意,该软件包和两个功能部件均已安装在v1.0.0上,并且在缺席状态下被检测到.检测到相关程序包",但不包括功能详细信息.

Note that the package and two features were both installed at v1.0.0 and detected in state Absent. The Related Package was detected, but no feature details are included.


Detected Related Upgrade Bundle {5eff0a3c-4b0d-4fd9-875f-05117c07f373) at version 1.0.0.0 which is a MajorUpgrade
Package NetFx4OWeb Detected in State Present
Detected Related Package {540AE32D-75C0-4BF3-A72D-ADBE97FSFF3E} (SetupProject1.msi) at version 1.0.0.0 which is a MajorUpgrade
Feature feature_one from Package SetupProjectl.msi detected in state Absent
Feature feature_Two from Package SetupProjecti .msi detected in state Absent
Package SetupProject1.msi Detected in State Absent

推荐答案

DetectMsiFeature告诉您新程序包的功能状态.它尚未安装,因此显然功能并未安装.DetectRelatedMsiPackage提供了使用(本机)MSI API函数MsiEnumFeatures和MsiGetFeatureState/MsiGetFeatureUsage查询已安装版本的功能状态所需的数据.

DetectMsiFeature is telling you the state of features for the new package; it's not installed, so obviously the features aren't. DetectRelatedMsiPackage gives you the data you need to query the feature states of the installed version using the (native) MSI API functions MsiEnumFeatures and MsiGetFeatureState/MsiGetFeatureUsage.

这篇关于在使用WiX Burn MBA软件包的MajorUpgrade中,如何检测当前安装的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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