如果回滚自定义操作失败,会发生什么情况?是否需要在Wix CustomAction元素中为回滚自定义操作指定CustomAction属性?
我做了个快速测试。我创建了一个二进制自定义操作:
这是一个C++代码:
UINT __stdcall ForceInstallFailure(MSIHANDLE hModule)
{
return ERROR_INSTALL_FAILURE;
}Wix代码:
<CustomAction Id="CA_ForceInstallFailure" BinaryKey="Bin_CAInst"
DllEntry="ForceInstallFailure"
Execute="rollback" Return="check" Impersonate="no" />Wix将其翻译为3329类型:
类型1(从通过入口点调用的二进制流生成的DLL)+
3328 (msidbCustomActionTypeInScript + msidbCustomActionTypeNoImpersonate + msidbCustomActionTypeRollback)
我用https://wixtoolset.org/docs/v3/customactions/wixfailwhendeferred/模拟了回滚
这就是我在MSI日志中得到的信息:
Rollback: CA_ForceInstallFailure
MSI (s) (90:B4) [02:18:54:053]: Executing op: ActionStart(Name=CA_ForceInstallFailure,,)
MSI (s) (90:B4) [02:18:54:053]: Executing op: CustomActionRollback(Action=CA_ForceInstallFailure,ActionType=3329,Source=BinaryData,Target=ForceInstallFailure,)
MSI (s) (90:14) [02:18:54:053]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIC523.tmp, Entrypoint: ForceInstallFailure
CustomAction CA_ForceInstallFailure returned actual error code 1603 but will be translated to success due to continue marking看起来Windows在回滚过程中不检查自定义操作返回值,尽管我没有将其具体标记为Return="ignore",这将转换为msidbCustomActionTypeContinue加法。
虽然从逻辑上看,这似乎是正确的行为,但我找不到任何官方文档来描述这一点。
发布于 2022-11-16 22:07:55
Windows安装程序没有用于回滚的回滚,因此它会忽略回滚期间的自定义操作失败。
https://stackoverflow.com/questions/74450829
复制相似问题