创建一个 msiexec 将忽略其的自定义操作错误代码

发布于 2024-11-06 08:04:47 字数 436 浏览 0 评论 0 原文

我使用 Visual Studio 2010 为我的项目创建带有 .NET Framework 4.0 的安装包。我使用 Installer 类以及使用 .NET Framework 4.0 构建的 DLL 创建自定义操作。我的安装包已成功安装。

如果我删除我的包,然后删除 .NET Framework 4,一切都会正常。

但是,如果我删除 .NET Framework,然后删除安装包,则会收到错误:“1001 InstallUtilLib.dll 未知错误”。我认为我无法删除安装包的原因是 msiexec 将调用我的自定义操作,即使用 .NET Framework 4.0 的 Installer 类,而 .NET Framework 4.0 之前已被删除 ->无法调用安装程序 DLL 并返回错误 -> 删除 MSI 失败。

请帮助我如何避免此错误或如何忽略此自定义操作的错误代码。谢谢。

I use Visual Studio 2010 to create a setup package with .NET Framework 4.0 for my project. I create a custom action using Installer class with DLL built with .NET Framework 4.0. My setup package is installed successfully.

If I remove my package and after that removing .NET Framework 4, everything is ok.

However, If I remove .NET Framework, after that I remove my setup package, I get a error: "1001 InstallUtilLib.dll unknown erro" . I think the reason I can't remove my setup package because msiexec will call my custom action which is Installer class using .NET Framework 4.0 while .NET Framework 4.0 is removed before -> Installer DLL can't be called and return a error ->removing MSI failure.

Please help me how to avoid this error or how to ignore the error code of this custom action. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囚你心 2024-11-13 08:04:47

您可以尝试以下操作:

Visual Studio 不直接支持此操作。

You can try this:

Visual Studio doesn't support this directly.

七分※倦醒 2024-11-13 08:04:47

您可以通过设置 Framework 4.0 的启动条件来避免此错误,这样每当启动安装程序(用于安装或卸载)时,它都会首先检查 Framework 4.0

You can avoid this error by having a launch condition for Framework 4.0, so that when ever the setup is launched (for install or uninstall) it first checks for framework 4.0

思念满溢 2024-11-13 08:04:47

mrnx 的答案对我有帮助,但我想我会用我最终所做的事情来扩展这个答案。就我而言,我在多个程序中包含一个驱动程序,其中驱动程序始终返回 1 而不是 0。

  1. 基于 mrnx 打开 MSI 文件并查看 CustomAction 表,我发现我的自定义操作的类型都是“3090”。要设置 msidbCustomActionTypeContinue 标志,我必须添加 64,这意味着将值更改为 3154。

  2. 由于我想在构建过程中自动执行此操作,所以我发现了这个 问题,解释了如何创建 MSI 转换。此解决方案有效,但它无法在项目之间移植,因为转换仅适用于一个 MSI 文件。相反,我发现从设置项目构建后步骤调用的简单 VB 脚本适用于各种 MSI 项目:

Dim msiInstaller
Dim msiDatabase
Dim msiView
Dim pathToMsi

If WScript.Arguments.Count <> 1 Then
    WScript.Echo "Usage:" & vbCrLf & "  " & WScript.ScriptName & " <path-to-msi>"
    WScript.Quit 1
End If

pathToMsi = WScript.Arguments(0)
Set msiInstaller = CreateObject("WindowsInstaller.Installer")

Set msiDatabase = msiInstaller.OpenDatabase(pathToMsi, 1)
Set msiView = msiDatabase.OpenView("UPDATE CustomAction SET Type=3154 WHERE Type=3090")
msiView.Execute msiRecord

msiDatabase.Commit

用法(设置为项目属性的PostBuildEvent):

"$(ProjectDir)..\patchMsiForDriver.vbs" "$(BuiltOuputPath)"

mrnx's answer helped me, but I thought I would expand on that answer with what I ended up doing. In my case, I was including a driver in multiple programs, where the driver always returns 1 instead of 0.

  1. Based on the mrnx's procedure to open the MSI file and view the CustomAction table, I found that my custom actions all had the type "3090". To set the msidbCustomActionTypeContinue flag, I had to add 64, which meant changing the value to 3154.

  2. Since I wanted to automate this in my build process, I found this Question, which explained how to create an MSI transform. This solution works, but it wasn't portable between projects since the transform would only work for the one MSI file. Instead, I found that a simple VB script called from the setup project post-build step works for various MSI projects:

Dim msiInstaller
Dim msiDatabase
Dim msiView
Dim pathToMsi

If WScript.Arguments.Count <> 1 Then
    WScript.Echo "Usage:" & vbCrLf & "  " & WScript.ScriptName & " <path-to-msi>"
    WScript.Quit 1
End If

pathToMsi = WScript.Arguments(0)
Set msiInstaller = CreateObject("WindowsInstaller.Installer")

Set msiDatabase = msiInstaller.OpenDatabase(pathToMsi, 1)
Set msiView = msiDatabase.OpenView("UPDATE CustomAction SET Type=3154 WHERE Type=3090")
msiView.Execute msiRecord

msiDatabase.Commit

Usage (set to PostBuildEvent of Project Properties):

"$(ProjectDir)..\patchMsiForDriver.vbs" "$(BuiltOuputPath)"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文