Create a custom action which msiexec will ignore its' error code
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.
开发者_如何学GoHowever, 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.
You can try this:
- open the MSI with Orca
- go to CustomAction table and find your custom action
- add the msidbCustomActionTypeContinue flag to the existing value in Type column
- save the changes
Visual Studio doesn't support this directly.
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
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.
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.
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)"
精彩评论