Wix:有条件的延迟自定义操作

发布于 2024-10-05 09:52:10 字数 1166 浏览 1 评论 0原文

我们有一个自定义操作,我们只想在重大升级时运行。问题是,CA 被推迟,因为它需要访问系统文件(它从 INI 文件中删除程序的旧版本)。由于 CA 是延迟的,因此它只能访问 CustomActionData 属性。

因此,我的第一次尝试是在 UPGRADINGProductCODE 为 true 的情况下设置 CustomActionData,然后对实际对 CustomActionData 进行升级的 CA 进行条件限制。失败了——我认为未设置 CustomActionData,因为它仅在自定义操作内可见,并且不能用作自定义操作的条件。

以下是我定义的 CA:

  <CustomAction Id="MyCA.SetProperty" Return="check" Property="MyCA"
    Value="[UPGRADINGPRODUCTCODE]" />

  <CustomAction
      Id="MyCA"
      BinaryKey="MyIniProcessingProgram"
      ExeCommand="MyArgs"
      Execute="deferred"
      Impersonate="no"
  Return="ignore"/>

这是我的 InstallExecuteSequence:

<RemoveExistingProducts After="InstallValidate" />
<Custom Action="MyCA.SetProperty" Before="InstallFinalize"/>
<Custom Action="MyCA" After="MyCA.SetProperty">
    CustomActionData
</Custom>

我也尝试过:

  • 在 UPGRADINGProductCODE 上设置 MyCA.SetProperty 为条件,然后在其之后调度 MyCA - 不起作用,因为即使 MyCA.SetProperty 不运行,“之后”行动就完成了。

如果我们能够避免 JavaScript/VBScript 操作,或者在 INI 更新程序本身中检查 CustomActionData 的值,那就最好了;我们的想法是让 CA 本身有条件,因此除非条件(主要升级)为真,否则我们不会启动它。

We have a custom action that we want to run ONLY on a major upgrade. Trouble is, the CA is deferred because it needs access to system files (it removes the old version of the program from an INI file). Because the CA is deferred, it only has access to the CustomActionData property.

So my first attempt was to set CustomActionData if UPGRADINGPRODUCTCODE was true, and then condition the CA that actually did the upgrade on CustomActionData. That failed--CustomActionData was not set, I assume because it's only visible within the custom action and not usable as a condition for the custom action.

Here are the CA's I defined:

  <CustomAction Id="MyCA.SetProperty" Return="check" Property="MyCA"
    Value="[UPGRADINGPRODUCTCODE]" />

  <CustomAction
      Id="MyCA"
      BinaryKey="MyIniProcessingProgram"
      ExeCommand="MyArgs"
      Execute="deferred"
      Impersonate="no"
  Return="ignore"/>

And here is my InstallExecuteSequence:

<RemoveExistingProducts After="InstallValidate" />
<Custom Action="MyCA.SetProperty" Before="InstallFinalize"/>
<Custom Action="MyCA" After="MyCA.SetProperty">
    CustomActionData
</Custom>

I have also tried:

  • Making MyCA.SetProperty conditional on UPGRADINGPRODUCTCODE, then scheduling MyCA after it--doesn't work because even if MyCA.SetProperty doesn't run, the "After" action does.

It would be best if we could avoid JavaScript/VBScript actions, or resort to checking the value of CustomActionData within the INI-updating program itself; the idea is to make the CA itself conditional, so we don't launch it unless the condition (major upgrade) is true.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耳根太软 2024-10-12 09:52:10

为什么不使用此自定义操作:

<CustomAction
      Id="MyCA"
      BinaryKey="MyIniProcessingProgram"
      ExeCommand="MyArgs"
      Execute="deferred"
      Impersonate="no"
Return="ignore"/>

通过此 InstallExecuteSequence?

<Custom Action="MyCA" After="InstallValidate">
      UPGRADINGPRODUCTCODE
</Custom>

请注意,UPGRADINGProductCODE是在正在升级的包中设置的,因此它仅在旧版本的卸载过程中可用。

如果要检测新版本中的升级,可以使用升级表中的 ActionProperty 列:
http://msdn.microsoft.com/en-us/ library/aa372379(VS.85).aspx

基本上,您需要定义旧版本和新版本的升级规则:
http://wix.sourceforge.net/manual-wix2/wix_xsd_upgradeversion.htm

这样您就可以通过自定义属性检测旧版本。然后可以使用此属性来调节您的自定义操作。

Why not use this custom action:

<CustomAction
      Id="MyCA"
      BinaryKey="MyIniProcessingProgram"
      ExeCommand="MyArgs"
      Execute="deferred"
      Impersonate="no"
Return="ignore"/>

with this InstallExecuteSequence?

<Custom Action="MyCA" After="InstallValidate">
      UPGRADINGPRODUCTCODE
</Custom>

Please note that UPGRADINGPRODUCTCODE is set in the package which is being upgraded, so it's available only in the uninstall process of the old version.

If you want to detect an upgrade in your new version, you can use the ActionProperty column in Upgrade table:
http://msdn.microsoft.com/en-us/library/aa372379(VS.85).aspx

Basically, you need to define the upgrade rules for older and newer versions:
http://wix.sourceforge.net/manual-wix2/wix_xsd_upgradeversion.htm

This way you can detect older versions through a custom property. This property can then be used to condition your custom action.

世界如花海般美丽 2024-10-12 09:52:10

用于控制任何操作(包括延迟)的条件是立即序列的条件。这意味着您甚至可以直接使用 UPGRADINGProductCODE 作为延迟操作条件的一部分。

当安装程序在立即阶段达到此序列时,它将评估条件,并在条件为真时安排延迟执行。然后,当它运行延迟序列时,它将只运行立即阶段安排的所有操作。

The conditions used to gate any action (deferred included) are those of the immediate sequence. That means you could use UPGRADINGPRODUCTCODE directly as part of the condition on even your deferred action.

When the installer reaches this sequence during the immediate phase, it will evaluate the condition, and schedule the deferred execution if the condition is true. Then when it runs the deferred sequence, it will just run all the actions that were scheduled during the immediate phase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文