0

我已使用 Visual Studio 安装项目来创建 MSI。我在 Orca 中编辑了 MSI,以便在首次打开时通过 DLL 执行自定义操作。当我运行 MSI 时,msiexec记录以下内容:

MSI (c) (E4:BC) [15:28:14:453]: Doing action: CustomAction1
Action 15:28:14: CustomAction1. 
Action start 15:28:14: CustomAction1.
MSI (c) (E4:BC) [15:28:14:453]: Note: 1: 2235 2:  3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'CustomAction1' 
MSI (c) (E4:BC) [15:28:14:453]: Creating MSIHANDLE (13) of type 790542 for thread 3260
MSI (c) (E4:B4) [15:28:14:453]: Invoking remote custom action. DLL: C:\DOCUME~1\USERNA~1\LOCALS~1\Temp\MSIA3.tmp, Entrypoint: SampleFunction
MSI (c) (E4:B4) [15:28:14:453]: Closing MSIHANDLE (13) of type 790542 for thread 3260
Action ended 15:28:14: CustomAction1. Return value 3.
MSI (c) (E4:BC) [15:28:14:468]: Doing action: FatalErrorForm
Action 15:28:14: FatalErrorForm. 
Action start 15:28:14: FatalErrorForm.
MSI (c) (E4:BC) [15:28:14:468]: Note: 1: 2235 2:  3: ExtendedType 4: SELECT `Action`,`Type`,`Source`,`Target`, NULL, `ExtendedType` FROM `CustomAction` WHERE `Action` = 'FatalErrorForm' 

然后安装程序向导会显示错误消息:The installer was interrupted before MyProduct could be installed. You need to restart the installer to try again.

自定义 DLL 是用 C++ 编写的。这是源代码:

MyCustomAction.cpp:

// MyCustomAction.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"

BOOL APIENTRY DllMain(HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

UINT __stdcall SampleFunction(MSIHANDLE hModule)
{
        //This is the function that is called by the MSI
        //It is empty because I just want to check that it can be called without interrupting the installer, then I will add the actual functionality
}

MyCustomAction.def:

; MyCustomAction.def
;
; defines the exported functions which will be available to the MSI engine

LIBRARY      "MyCustomAction" 
DESCRIPTION  'Custom Action DLL'

EXPORTS
    SampleFunction

msi.lib在 DLL 的附加依赖项中也有引用。当我目前没有明确告诉它做任何事情时,为什么自定义操作会中断安装?任何帮助,将不胜感激。

更新:

在 Orca 中,自定义操作在Binary表格中并且是表格中的类型 1 CustomAction。自定义操作在表格的前后Immediate发生。IsolateComponentsWelcomeFormInstallUISequence

4

1 回答 1

0

您应该更新您的代码和您的帖子,以表明您实际上正在返回 ERROR_SUCCESS。不管它是否解决了问题,关键是它是正确的做法。如果它不返回值,则调用序列将失败并出现错误。

由于缺少依赖项,您的 Dll 可能无法加载。如果您在代码中放置一个简单的消息框调用,您至少会看到代码是否真正开始运行。C++ 将需要运行时支持 Dll,这些 Dll 可能尚未在系统上。

如果事实证明您依赖于 C++ 运行时,那么您需要在运行 MSI 之前安装它们。这就是先决条件选择的用途——它会生成一个 setup.exe 来安装依赖项,然后安装您的 MSI。

于 2017-12-12T19:04:33.423 回答