如何重现MSI安装错误 [英] How to Reproduce MSI Install Error

查看:62
本文介绍了如何重现MSI安装错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有某种方法可以重现/注入一些MSI安装错误吗?

我希望我的安装会因错误1xxx / 2xxx而失败。.( msi错误代码),无论哪个错误代码,在MSI日志中,我将看到 Retun value 3是什么重要。


*我正在使用WIX

There is some way to reproduce/Inject some MSI install error?
I would like my install will fail with some error 1xxx/2xxx.. (msi error codes) it doesn't matter which error code, What important that in the MSI logs I will see "Retun value 3".

* I am using WIX

推荐答案

不是100%确定您需要什么。您是否正在测试 Windows Installer回滚,并希望通过自定义操作触发它?或者,也许您只想在不触发回滚的情况下将某些内容写入MSI日志文件?我想您可能两者都想,但是听起来好像您只想写日志。

Not 100% sure what you need. Are you testing Windows Installer rollback and wanting to trigger it from your custom action? Or maybe you just want to write something into your MSI log file without triggering rollback? I suppose you might want both, but it sort of sounds like you may just want to write to the log.

您基本上可以通过在自定义操作中返回错误代码,然后将自定义操作设置为 检查退出代码 来触发MSI中的回滚。

You can basically just trigger rollback in your MSI by returning an error code from your custom action and set the custom action to "check exit code". See below for a note on deferred versus immediate mode custom actions.

此外:仅在需要时检查退出代码并可以处理它,否则您的设置可能会意外失败-通常是由于一些微不足道的错误(可能会破坏您的主要升级-或更糟糕的是-例如完全卸载。有几种意外情况。请始终测试包括升级在内的所有安装模式)。

Also: only check exit code when you need to and can handle it, or else your setup could fail unexpectedly - often for some insignificant and obscure error (which then may break your major upgrade - or worse - for example your uninstall entirely. There are several unexpected scenarios. Always test all installation modes including upgrades).

WiX util扩展中还有一个功能,可让您触发延迟的失败:> WixFailWhenDeferred 。我从未尝试过说实话。 标准化的WiX自定义操作列表(并参见 使用标准链接自定义操作)。 在此查看Bob Arnson的博客

There is also a feature in the WiX util extension that allows you to trigger a deferred failure: WixFailWhenDeferred. I have never tried it to be honest. List of standardized WiX custom actions (and see link to "Using Standard Custom Actions" in there). See Bob Arnson's blog on this.

对于初学者来说,这是一个有关如何实际操作的链接写入日志文件本身: 从自定义写入日志文件动作 。这来自Flexera(Installshield的制造商),但它涵盖了一般情况下以及其专有方式下来自不同类型的自定义操作的日志记录。我不知道您使用什么类型的动作。它是由 Robert Dickau (前Installshield / Flexera高级技术培训师)编写的,尽管具有高级主题,但他具有使事情保持尽可能简单的强大能力。这是一本快速阅读的书。

Here is a link, for starters, on how to actually write into the log file itself: Writing to the Log File from a Custom Action. This is from Flexera (makers of Installshield), but it covers logging from different types of custom actions in general as well as their proprietary ways. I don't know what type of action you use. It is written by Robert Dickau (former Installshield / Flexera Senior Technical Trainer) and features his great ability to keep things as simple as possible despite the advanced topic. It is a quick read.

也许有更好的方法可以从我从未使用过的托管代码中做到这一点。让我们拭目以待,看看 Chris Painter 是否在此处返回了一些信息(WiX / MSI专家-特别是关于托管代码)。

There may be better ways to do this from managed code that I haven't used. Let's wait and see if Chris Painter comes back with some info here (WiX/MSI expert - on managed code in particular).

它具有已经有很多年了,但是我想我实际上是在从事此类工作的那一天最终登录到事件日志,而不是登录日志文件。它仅供企业使用,事件日志得到了广泛使用。恐怕现在一切都变得模糊了,我没有可用的示例代码。

It has been ages, but I think I actually ended up logging into the event log instead of the log file back in the day when I was working on things like this. It was for corporate use, and the event log was used extensively. It is all a blur now I am afraid, and I don't have sample code for this available.

题外话:请注意,在立即模式中不会发生任何回滚(例如,当您在安装程序的用户界面中单击时)。在即时模式下,没有变更事务可以回滚,您基本上只是结束执行。因此,不得使用即时模式自定义操作对系统进行任何更改-不能回滚(它们也不能提升运行-尽管它们可以使用真正的管理员权限运行,从而使更改看似成功,但这总是错误的设计,并会引起您的悲伤。

Digression: Note that no rollback will happen in immediate mode (for example when you are clicking through the setup's user interface). In immediate mode there is no change transaction to roll back, you just end execution basically. No changes should ever be made to the system using immediate mode custom actions for this reason - they can't be rolled back (and they don't run elevated either - though they can run with real admin rights and hence make changes seemingly successfully, but this is always wrong design and will cause you grief). This is very important, hence this mention.

对于它的价值:这使我感到惊讶,为什么立即模式自定义操作不仅会在尝试写到任何地方时崩溃。崩溃错误不可忽视,我们会更好吗?也许我缺少了一些东西。

For what it is worth: it beats me why immediate mode custom actions don't just crash if attempting to write anywhere. Crash bugs can't be ignored, and we would have been better off? Maybe I am missing something.

这篇关于如何重现MSI安装错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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