我无法执行 Wix 自定义操作。即使自定义操作返回 ActionResult.Success,安装程序也会不断地自行回滚。
自定义操作 (C#)
[CustomAction]
public static ActionResult SetPermissionsToAppDataFolder(Session session)
{
return ActionResult.Success;
}
Wix 中的自定义操作定义
<!-- Custom Action -->
<Binary Id="CustomActionLibrary" SourceFile="$(var.CustomActionFolder)InstallerCustomActions.CA.dll" />
<CustomAction Id="CustomActionInstallDirectoryPermission"
BinaryKey="CustomActionLibrary"
DllEntry="SetPermissionsToAppDataFolder"
Execute="deferred"
Return="check" />
安装序列调用自定义操作
<!-- Install Sequences -->
<InstallExecuteSequence>
<Custom Action="CustomActionInstallDirectoryPermission" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
安装程序编译良好,因此找到自定义操作库文件没有问题。问题是安装程序在回滚之前进入了安装的最后阶段。当我们在安装序列中删除对自定义操作的调用时,安装程序完成。
据我了解,自定义操作 CA.dll 被嵌入到最终安装程序中。最初我认为 CA.dll 需要与安装程序一起分发,但后来发现安装程序将其编译成最终的 .msi。
我已经使用以下代码“连接”了自定义操作库:http: //www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed
无论我做什么,我都无法让安装程序完成,即使自定义操作返回“成功”。任何帮助表示赞赏。