我们在 c++ 中遇到了延迟自定义操作的问题。我们只想要一个 customactiondata 属性 'apacheconfpath' 的值,它目前具有一个虚拟值 test。
这是我们的 c++ 自定义操作:
UINT __stdcall AppendToApacheConfigFile(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
TCHAR sWord[100];
hr = WcaInitialize(hInstall, "AppendToApacheConfigFile");
ExitOnFailure(hr, "Failed to initialize");
TCHAR szActionData[MAX_PATH] = {0};
DWORD dActionDataLen = MAX_PATH;
MsiGetProperty (hInstall, TEXT("apacheconfpath"), TEXT(""), &dActionDataLen);
StringCbPrintf(sWord, 100, TEXT("%d"), dActionDataLen);
WcaLog(LOGMSG_STANDARD, "dActionDataLen = %s", sWord);
if (dActionDataLen > 0)
{
++dActionDataLen;
StringCbPrintf(sWord, 100, TEXT("%d"), dActionDataLen);
WcaLog(LOGMSG_STANDARD, "dActionDataLen(2) = %s", sWord);
MsiGetProperty (hInstall, TEXT("apacheconfpath"), szActionData, &dActionDataLen);
WcaLog(LOGMSG_STANDARD, "szActionData = %s", szActionData);
StringCbPrintf(sWord, 100, TEXT("%d"), dActionDataLen);
WcaLog(LOGMSG_STANDARD, "dActionDataLen(3) = %s", sWord);
//Do something with the value
}
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
该属性在我们的 wix 安装程序中设置:
<CustomAction Id="AppendToApacheConfigFile_Cmd" Property="AppendToApacheConfigFile" Value="/apacheconfpath=test;" />
<CustomAction Id="AppendToApacheConfigFile" BinaryKey="CustomActionDll" DllEntry="AppendToApacheConfigFile" Execute="deferred" />
<InstallExecuteSequence>
<Custom Action="AppendToApacheConfigFile_Cmd" Before="AppendToApacheConfigFile"><![CDATA[IIS_SELECTED <> 1]]></Custom>
<Custom Action="AppendToApacheConfigFile" After="DeployPhpRuntime"><![CDATA[IIS_SELECTED <> 1]]></Custom>
</InstallExecuteSequence>
我添加了许多日志记录以尝试查看发生了什么。似乎永远不会读取该属性,因为 dword 值始终为 0 并且数据始终为空。我们永远不会超过第一次阅读。
根据日志,值已设置
MSI (s) (80:C4) [20:59:30:210]: Executing op: CustomActionSchedule(Action=AppendToApacheConfigFile,ActionType=1025,Source=BinaryData,Target=AppendToApacheConfigFile,CustomActionData=/apacheconfpath=test;)
任何信息都将受到欢迎