如何修改内容/替换.msi文件的二进制文件作为构建后步骤?
在x64系统上使用CustomAction构建Visual Studio 2010安装项目时,Visual Studio包含错误版本的
InstallUtilLib.dll
:它安装32位垫片,这对于编译为64位的CustomActions不起作用(在我的情况下是一个要求,因为它取决于64位本机dll)。
安装这样的.msi
会导致System.BadImageFormat
异常。
根据这篇文章(使用Visual Studio进行64位托管自定义操作),解决方案是在orca.exe
中打开生成的.msi
并替换二进制“InstallUtil”。
我想自动化这个。有任何想法吗?
编辑:根据mohlsen提供的答案,我在解决方案中添加了以下脚本(不是安装项目本身,因为添加到安装项目的文件进入了msi ...):
Option Explicit
rem -----------------------------------------------------------
rem Setup_PostBuildEvent_x64.vbs
rem
rem Patch an msi with the 64bit version of InstallUtilLib.dll
rem to allow x64 built managed CustomActions.
rem -----------------------------------------------------------
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyAssign = 3
rem path to the 64bit version of InstallUtilLib.dll
Const INSTALL_UTIL_LIB_PATH = "C:WindowsMicrosoft.NETFramework64v2.0.50727InstallUtilLib.dll"
Dim installer : Set installer = Wscript.CreateObject("WindowsInstaller.Installer")
Dim sqlQuery : sqlQuery = "SELECT `Name`, `Data` FROM Binary"
Dim database
Set database = installer.OpenDatabase(Wscript.Arguments(0), msiOpenDatabaseModeTransact)
Dim view : Set view = database.OpenView(sqlQuery)
Dim record : Set record = installer.CreateRecord(2)
record.StringData(1) = "InstallUtil"
view.Execute record
record.SetStream 2, INSTALL_UTIL_LIB_PATH
view.Modify msiViewModifyAssign, record
database.Commit
Set view = Nothing
Set database = Nothing
接下来,我编辑了安装项目属性:我将PostBuildEvent
属性设置为:
wscript.exe "$(ProjectDir)..Setup_PostBuildEvent_x64.vbs" $(BuiltOuputPath)
注意:右键单击解决方案资源管理器中的安装项目,然后选择“属性”将打开错误的对话框(“属性页”)。你想要“属性窗口”(CTRL + W,P)。
没有找到相关结果
已邀请:
1 个回复
好按紊叉
希望这可以帮助!