WiX。取消安装时回滚自定义操作 [英] WiX. Rollback custom action when is canceled installation

查看:148
本文介绍了WiX。取消安装时回滚自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义操作

<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />

<InstallExecuteSequence>
      <Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>

我的自定义操作确实备份并解析了数据库。取消安装时,我需要回滚(删除数据库)。
我做了:

My custom action does backup and resolved database. I need to do rollback (drop database) when is canceled installation. I did:

<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="rollback" Return="check" />

<InstallExecuteSequence>
      <Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
      <Custom Action="myActionRollbackId" Before="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>

但是我遇到了错误。

如果我这样做:

<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />
<CustomAction Id="myActionRollbackId" BinaryKey="myActionRollback" DllEntry="MySimpleAction" Execute="immediate" Return="check" />

<InstallExecuteSequence>
      <Custom Action="myActionId" After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
      <Custom Action="myActionRollbackId" After="myActionId">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>

我的自定义操作myActionRollbackId有效。

My custom action myActionRollbackId works.

取消安装时如何运行rolback?
有人可以帮助我吗?

How to run rolback when is canceled installation? Someone can help me?

推荐答案

安装始终在事务中完成。当您启动安装程序时,它首先会创建一个称为安装脚本的内容,类似于安装过程中要做的事情的待办事项清单。
当我们将某些自定义操作设置为 Execute = immediate 时,它将立即执行,但是当我们将操作设置为 Execute = deferred 时,它将获得添加到安装脚本中,因此回滚变得很容易。
现在要注意的一件事是,我们可以以 Execute = immediate 模式访问会话,但是我们不能以 Execute = deferred 访问会话模式。
如果我们尝试访问会话,它将给出错误,在这种情况下,这可能是您出错的原因...

Installation is always done in transaction. when you launch an installer, it first creates something called installation script which is like a to do list of what it will do while installation. When we set some custom action as Execute="immediate", it gets executed immediately but when we set our action as Execute="deferred", it gets added in the installation script, hence rollback becomes easy for this. Now one thing to note here is that we get access to session in Execute="immediate" mode, but we cannot access session in Execute="deferred" mode. If we try to access session it will give error, which in this case might be the reason for your error...

这篇关于WiX。取消安装时回滚自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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