gpt4 book ai didi

c# - CustomAction 被调用两次

转载 作者:太空宇宙 更新时间:2023-11-03 18:40:45 25 4
gpt4 key购买 nike

我使用 Wix,并且有一个 customAction 和一个 anb installSequence:

 <CustomAction Id='PreInstallAction' BinaryKey='PreInstallBinary' DllEntry='MyCustomAction1' Execute='immediate'
Return='check'/>
<Binary Id='PreInstallBinary' SourceFile='E:\...\MyCustomAction\bin\Release\MyCustomAction.CA.dll'/>

<InstallExecuteSequence>
<Custom Action='PreInstallAction' Before='InstallInitialize'/>
</InstallExecuteSequence>

问题是我的自定义操作被调用了两次 -(在自定义操作中我将内容打印到日志文件中并且我看到了两次)

我试着评论这行:

 <MajorUpgrade AllowDowngrades="no" AllowSameVersionUpgrades="yes" DowngradeErrorMessage="Can't downgrade from newer version"  />

它解决了这个问题。但我需要重大更新,所以我尝试取消注释上面的行并向 customAction 添加条件:

<InstallExecuteSequence>
<Custom Action='PreInstallAction' Before='InstallInitialize'>
NOT Installed AND NOT PATCH
</Custom>
</InstallExecuteSequence>

但是现在 ny customAction 又被调用了两次...我的情况有什么问题吗?还有其他解决办法吗?

最佳答案

您的自定义操作执行了两次,因为它在新旧安装的执行顺序中。当 RemoveExistingProducts 执行主要升级时,它实际上正在运行旧产品的卸载,因此两者都在范围内。您可以通过在自定义操作的顺序上放置一个条件表达式来解决此问题,以便它仅在旧的卸载或新的安装期间运行。

此外,根据该 CA 实际执行的操作,立即执行调度可能不是最佳选择。任何更改机器状态的自定义操作都必须安排在 InstallInitialize 和 InstallFinalize 之间,并延迟(通常是系统上下文)执行以确保属性(property)权和回滚行为(您还必须编写回滚和提交操作)。

关于c# - CustomAction 被调用两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9276293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com