如何仅在安装和修改时执行条件自定义操作? [英] How to execute conditional custom action on install and modify only?

查看:90
本文介绍了如何仅在安装和修改时执行条件自定义操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以正常运行的安装程序。我只想在安装和修改中运行自定义操作。这是我的自定义操作:

I have a installer which is working fine. I want to run custom action only in install and modify only. Here is my custom action:

<Custom Action="UpdateAPMDBAPasswordAndStoreInRegistry" After="InstallFinalize"><![CDATA[&BaseModel = 3 OR &FeaturePostMaster = 3]]></Custom>

修改安装程序时,上述自定义操作未运行。它仅在安装安装程序时运行。谷歌搜索后,我这样做了,但它也不起作用:

The above custom action is not running when modify the the installer. It runs only when install the installer. After googled, i did this but it is also not working:

<Custom Action="UpdateAPMDBAPasswordAndStoreInRegistry" After="InstallFinalize"><![CDATA[(&BaseModel = 3 OR &FeaturePostMaster = 3) AND (NOT Installed OR MaintenanceMode="Modify")]]></Custom>

它也仅在安装模式下运行。我在做什么错?

It also run only in install mode. What i am doing wrong?

推荐答案

InstallFinalize :您是否写到 HKCU HKLM ?在 InstallFinalize 之后排序的所有内容在托管环境中均不会提升运行,因此,如果尝试写入 <$ c,则在安装过程中将失败$ c> HKLM (除非您更改要写入的密钥的ACL-或从已经提升的cmd.exe中启动MSI-不推荐,否则该软件包是

InstallFinalize: Do you write to HKCU or HKLM? Anything sequenced after InstallFinalize will not run elevated in a managed environment and will hence fail during installation if you try to write to HKLM(unless you change the ACL for the key you write to - or you kick the MSI off from a cmd.exe that is elevated already - not recommended, the package is flawed).

MaintenanceMode :这种情况似乎是特定于Installshield的:未安装或MaintenanceMode =修改 。我认为Installshield本身会以专有方式设置 MaintenanceMode 属性。因此,它根本无法在WiX中使用。

MaintenanceMode: That condition looks like it is Installshield-specific: NOT Installed OR MaintenanceMode="Modify". I think Installshield itself sets that MaintenanceMode property in a proprietary fashion. Hence it is not available in WiX at all.

测试条件 :条件可能很难测试,您需要在许多安装模式下进行真实测试( install 卸载修复修改补丁重大升级自我修复等... ),以确保它们适合您的特定情况并按预期工作。人们对条件感到惊讶的典型场景是重大升级-卸载旧版本并安装新版本-根据我的经验,它往往会揭示条件方面的意外问题。通常是由于复杂的排序问题以及在升级过程中同时运行旧安装程序的卸载序列和新安装程序的安装序列的事实。因此,以错误为条件的自定义操作可能会在主要升级过程中运行几次,并造成真正的混乱。

Testing Conditions: Conditions can be hard to test and you need to do real-world testing in many installation modes (install, uninstall, repair, modify, patch, major upgrade, self-repair, etc...) to be sure they fit your particular case and work as expected. A typical scenario where people are surprised at conditioning is major upgrades - the uninstall of your old version and the installation of the new version - it tends to reveal unexpected problems with conditions in my experience. Often due to the complex sequencing issues and the fact that during such an upgrade both the old setup's uninstall sequence and the new setup's install sequence run. Hence erronously conditioned custom actions can run several times during the major upgrade process and cause a real mess.

测试提示 :要进行快速的重大升级,您需要更改产品代码并增加版本的前3位数字之一。并且您需要在其中具有MajorUpgrade元素。您可以通过将产品代码设置为 * 来将其设置为自动生成(我更喜欢手动更改)。编译一个MSI,在其后缀 _ Version1 ,然后进行上述更新并编译 _ Version2 。运行升级序列。您还应该通过更改源路径来指向版本2的更新文件,但是也可以不使用它来测试条件。

Testing Tip: To implement a quick major upgrade you need to change the product code and bump up one of the first 3 digits of the version. And you need to have the MajorUpgrade element in there. You can set the product code to auto-generate by setting it to * (I prefer to change it manually). Compile an MSI, suffix it with "_Version1" then do the updates mentioned and compile "_Version2". Run upgrade sequence. You should also point to the updated files for version 2 by changing the source path, but you can roll without it to test conditions.

修改 :根据您的情况,有一个 Installshield 在其 MSI条件备忘单


  • 已安装且未重新安装且未移除〜= ALL

  • 上述条件应使自定义操作只能在修改操作中运行。如果稍加更改,它仅适用于安装和修改:

  • 未安装或((已安装且未重新安装)且未移除〜= ALL)

  • Installed AND NOT REINSTALL AND NOT REMOVE~="ALL"
  • The above condition should enable the custom action to run in modify operations only. If you change it a little it should work for install and modify only:
  • NOT Installed OR ((Installed AND NOT REINSTALL) AND NOT REMOVE~="ALL")

我将不得不对最后一个条件进行额外的检查明天,但我只是发布此内容,以便您可以自己进行测试。我取出了PATCH,但也许我应该重新添加它以涵盖主要的升级补丁。您会交付补丁吗?

I will have to run an extra check on that last condition tomorrow, but I just post this so you can get testing yourself. I took out PATCH, but maybe I should add it back to cover major upgrade patches. Will you be delivering patches?

用于轻量状态测试的快速样机

Quick Mockup for Light-Weight Condition Testing:

VBScript

The VBScript:

注意! 请确保VBScript文件位于 UTF8 或<$ c $中c> ANSI 。 Unicode将不起作用。也许在记事本而不是Visual Studio中创建它。将VBScript文件创建为WiX文本文件,然后将其重命名为 *。vbs 格式时,遇到了问题。不要这样做。

Note! Make sure the VBScript file is in UTF8 or ANSI. Unicode will not work. Maybe create it in Notepad rather than Visual Studio. I have seen issues when creating the VBScript file as a WiX text file that I then rename to *.vbs format. Don't do that.

MsgBox "I run, therefore I am conditioned and sequenced"

WiX标记,自定义操作

WiX Markup, Custom Action:

<Binary Id='SayHelloMsgBox.vbs' SourceFile='SayHelloMsgBox.vbs' />
<CustomAction Id='SayHelloMsgBox.vbs' VBScriptCall='' BinaryKey='SayHelloMsgBox.vbs' Execute='immediate' Return='ignore' />

WiX标记,测序和条件

WiX Markup, Sequencing & Conditioning:

<InstallExecuteSequence>
   <Custom Action='SayHelloMsgBox.vbs' After='InstallInitialize'>NOT Installed OR ((Installed AND NOT REINSTALL) AND NOT REMOVE~="ALL")</Custom>
</InstallExecuteSequence>

写入日志 :您可以编写从VBScript到MSI日志,如本文所述: MSI提示:写入来自自定义操作的日志文件

更新 :您可以使用以下方法消除单独的VBScript文件,以进行条件调试方法

这篇关于如何仅在安装和修改时执行条件自定义操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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