禁用 InstallFiles 的自动回滚 [英] Disable automatic rollback of InstallFiles

查看:62
本文介绍了禁用 InstallFiles 的自动回滚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 WIX-Toolset 3.6 实现了我的第一个 MSI 安装程序,其中包括用于 BackupInstallation 的自定义操作回滚.

I've implemented my first MSI-Installer with WIX-Toolset 3.6 which includes Custom Actions for Backup, Installation and Rollback.

备份和安装工作正常,但我的回滚自定义操作有问题.我已经像这样定义了我的自定义操作:

The Backup and Installation works fine, but I have a problem with my Rollback Custom Action. I have defined my Custom Actions like this:

<!-- Custom actions -->
<CustomAction Id="CA_Install" Return="check" BinaryKey="BIN_CaLibrary" Execute="deferred" DllEntry="CaInstall" />
<CustomAction Id="CA_Rollback" Return="check" BinaryKey="BIN_CaLibrary" Execute="rollback" DllEntry="CaRollback" />
<CustomAction Id="CA_Backup" Return="check" BinaryKey="BIN_CaLibrary" Execute="immediate" DllEntry="CaBackup" />
<CustomAction Id="CA_SetTargetDir" Return="check" BinaryKey="BIN_CaLibrary" Execute="immediate" DllEntry="CaSetTargetDir" />
<CustomAction Id="CA_SetTargetDirAndInstallTypeForInstall" Return="check" Property="CA_Install" Value="InstallType=[INSTALLTYPE];TargetDir=[TARGETDIR]" />
<CustomAction Id="CA_SetTargetDirForRollback" Return="check" Property="CA_Rollback" Value="TargetDir=[TARGETDIR]" />

<!-- Linking custom actions to the install sequence -->
<InstallExecuteSequence>
  <Custom Action="CA_SetTargetDir" Before="AppSearch" />
  <Custom Action="CA_Backup" After="CA_SetTargetDir" />
  <Custom Action="CA_SetTargetDirForRollback" Before="CA_Rollback" />
  <Custom Action="CA_SetTargetDirAndInstallTypeForInstall" Before="CA_Install"/>
  <Custom Action="CA_Rollback" Before="CA_Install"/>
  <Custom Action="CA_Install" Before="InstallFinalize" />
</InstallExecuteSequence>

在我的 CA_Backup 中,我总是使用旧版本的应用程序创建一个备份目录(即使安装成功).当我的 CA_Install 遇到异常时,安装程​​序会跳转到我自己的回滚自定义操作 CA_Rollback.在此自定义操作中,我删除 TARGETDIR 中的所有文件并从备份目录中复制这些文件.它完成了它应该做的事情,但是在 CA_Rollback 之后,Wix-Installer 会自动回滚其他自定义操作,例如 InstallFiles.因此它删除了之前从我的 CA_Rollback 中的备份目录中复制的所有文件.

In my CA_Backup I always create a Backup-Directory with the old version of the application (even if the installation is successful). When my CA_Install runs into an exception the Installer jumps to my own Rollback Custom Action CA_Rollback. In this Custom Action I delete all files in TARGETDIR and reproduce the files from Backup-Directory. It does exactly what it should do but after the CA_Rollback the Wix-Installer automatically rollback the other Custom Actions like InstallFiles. And so it deletes all the files that are reproduced from the Backup-Directory in my CA_Rollback before.

是否可以禁用 InstallFiles 自定义操作的自动回滚?或者我的问题有其他解决方案吗?

Is it possible to disable the automatic rollback of the InstallFiles Custom Action? Or is there an other solution for my problem?

同样奇怪的是,CA_Rollback 的ProgressText 并不是我定义的,而是WiX-Framework 的标准文本.

It's also strange that the ProgressText of the CA_Rollback is not what I've defined, but the standard text of WiX-Framework.

<ProgressText Action="CA_SetTargetDir">Getting Installation-Type...</ProgressText>
<ProgressText Action="CA_Backup">Creating Backup-Directory...</ProgressText>
<ProgressText Action="CA_Install">Updating Application...</ProgressText>
<ProgressText Action="CA_Rollback">Rollback the Application...</ProgressText>

因此,当安装程序跳转到 CA_Rollback 时,ProgressText 不是 回滚应用程序...",而是在其他自定义操作(CA_SetTargetDir、CA_Backup、CA_Install)中,ProgressText 显示为定义.

So, when the Installer jumps to the CA_Rollback the ProgressText is NOT "Rollback the Application..." but in the other Custom Actions (CA_SetTargetDir, CA_Backup, CA_Install) the ProgressText is shown as defined.


我找到了 DisableRollback Action我想在我的 InstallExecuteSequence 中像这样使用它:


I've found the DisableRollback Action and I'd like to used it like this in my InstallExecuteSequence:

<DisableRollback After="CA_Rollback" />

所以我想运行我自己的回滚 CA_Rollback,但想禁用其他自定义操作的自动回滚.但是当我包含这个时,根本没有回滚.

So I'd like to run my own Rollback CA_Rollback, but want to disable the automatic rollback of the other Custom Actions. But when I include this, there is no Rollback at all.

推荐答案

你的问题对我来说有点不清楚 - 我很困惑你真正问的是什么,以及你为什么以这种方式实现回滚.但是,这里有一个通用的答案:

Your question is a bit unclear to me - I am quite confused as to what you are really asking, and why you have implemented rollback this way. However, here is a general answer:

回滚支持Windows Installer 的内置功能,您根本不需要实现此功能.您可能需要一个回滚自定义操作来补充对目标系统进行更改的自定义操作.请参阅下面的信息.

Rollback support is a built-in feature of Windows Installer and you don't need to implement this feature at all. What you might need is a rollback custom action to complement a custom action that makes changes to the target system. See info below.

在安装软件期间替换的文件,以及注册表项、ini 文件设置和 MSI 表中正确定义的其他设置,都直接存储在系统驱动器上的隐藏文件夹中(通常为 C:\Config.MSI) 在安装过程中.这些文件具有扩展名 .RBS.RBF - 回滚脚本文件 - 如果在安装过程中发生错误,可以将系统恢复到以前的状态,除非在自定义操作中进行任何更改.

Files replaced during the installation of your software, as well as registry keys, ini file settings, and other settings properly defined in the MSI tables, are all stored in a hidden folder directly on the system drive (generally C:\Config.MSI) during installation. The files have extensions .RBS and .RBF - Rollback Script Files - that restore the system to the previous state should an error occur during installation, barring any changes done in custom actions.

自定义操作 是特殊的,因为它们被定义为非标准的,因此没有对它们的回滚的内置支持.为了回滚这些更改,您需要编写一个免费的回滚自定义操作来撤消原始自定义操作所做的操作.这可能非常复杂,需要仔细安排、实施和测试.请注意,执行检查、属性检索或其他任务而不进行任何系统更改的只读自定义操作不需要回滚.使用这些非侵入性自定义操作可能非常有效.我特别喜欢使用这些自定义操作在一个脚本中收集许多操作,以便其他设置开发人员更容易检查.MSI 的运行时行为就像一个复杂的手表 - 许多交互和计时问题都是可能的,这使得快速概览变得困难.可能需要在 2-3 个不同的、看似无关的地方进行更改以获得您需要的行为.脚本是连续的,可以进行注释以便于理解,并且可以在一个位置进行重大更改.对于团队合作,我发现这些脚本必不可少.

Custom actions are special in the sense that they are by definition non-standard, and hence there is no built-in support for their rollback. In order to roll back changes for these, you need to write a complimentary rollback custom action to undo what the original custom action did. This can be highly complex, and requires careful scheduling, implementation and testing. Note that a read-only custom action that performs checking, property retrieval or other tasks without making any system changes does not require rollback. Use of these non-invasive custom actions can be very effective. I am particularly fond of using these custom actions to gather many operations in one script for easier inspection by other setup developers. MSI's runtime behavior is like a complex watch - many interactions and timing issues are possible and this makes it difficult to get a quick overview. Changes may be required in 2-3 different, seemingly unrelated places to get the behavior you need. Scripts are sequential and can be commented for easier comprehension and crucially changed at a single location. For team work I find these scripts essential.

必须指出的是,自定义操作往往是不必要的,因为已经使用内置的 Windows Installer 功能或 WIX 功能以更可靠的方式实现了相同的功能. Wix 是一个基于 XML 的工具包,允许编译 MSIXML 源文件中的文件.该工具包由 Rob Mensching 编写,他曾是 Microsoft 的 Windows Installer 团队的成员,并且高度可靠、高度可定制,并且充满了高级和简单的功能.

It is crucial to point out that custom actions tend to be unnecessary since the same feature has been implemented already in much more reliable ways using built-in Windows Installer features, or WIX features. Wix is an XML based toolkit allowing the compilation of MSI files from XML source files. The toolkit is written by Rob Mensching - a member of the Windows Installer team from Microsoft at one point - and is highly reliable, highly customizable, and full of advanced and simple features alike.

尽可能避免不必要的自定义操作的重要性怎么强调都不过分.检查 Windows Installer 或 Wix 是否支持它.

The importance of avoiding unnecessary custom actions if at all possible, can not be overstated. Check whether Windows Installer or Wix has support for it.

MSI 完全支持处理 ini 文件设置、字体、环境变量、注册表项、COM 信息、快捷方式、文件扩展名、启动条件、GAC 安装、ODBC 等的合并...

MSI features full support for handling merging of ini file settings, fonts, environment variables, registry keys, COM information, shortcuts, file extensions, launch conditions, GAC installation, ODBC, etc...

WIX 进一步支持非常高级的功能,例如 SQL 服务器扩展、IIS 安装和配置、性能计数器、DirectX 检查和其他游戏相关任务、.NET 本机图像生成、COM+、驱动程序、防火墙规则、PowerShell 扩展、应用程序关闭、用户、组、共享等管理.有点需要处理,但比您自己的自定义操作可靠得多.下载最新版本的WIX并阅读帮助文件Wix.chm - Wix 架构参考部分.

WIX goes further with support for very advanced features such as SQL server extensions, IIS installations and configuration, performance counters, DirectX checking and other game related tasks, .NET native image generation, COM+, drivers, firewall rules, PowerShell extensions, application closing, management of users, groups, shares and much more. Somewhat involved to deal with, but much more reliable than your own custom actions. Download the latest version of WIX and read the help file Wix.chm - the Wix Schema References section.

这篇关于禁用 InstallFiles 的自动回滚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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