wix - 在回滚情况下将文件保留在 TEMP 中
在执行自定义操作之前,我需要从目标计算机中删除文件。如果操作结果不成功,我应该回滚所有更改。因此,我应该将文件替换为临时目录,并在回滚时将文件移回,并清除临时目录。
我该怎么做?
I need to delete a file from the target machine before an execution of my custom action. In case unsuccessful result of action I should rollback all the changes. So I should replace file to the temp directory, and on rollback move the file back, and clear the temp.
How can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你不应该这样做。 Windows Installer 将为您完成此操作。
只需在删除文件之后安排您的自定义操作,对其进行适当的调节(例如仅在卸载时运行,这取决于您的要求)并确保它被推迟。就是这样!如果卸载被回滚,Windows Installer 知道如何回滚RemoveFiles 操作,并且您的文件将回到那里。
I don't think you SHOULD do this. Windows Installer will do this for you.
Just schedule your custom action after RemoveFiles, condition it appropriately (e.g. run on uninstall only, it depends on your requirements) and make sure it is deferred. And that's it! If the uninstall is rolled back, Windows Installer knows how to rollback RemoveFiles action, and your file will be back there.