在自定义操作中检索 msi 错误代码和消息

问题描述 投票:0回答:1

我有一个报告 WIX 项目中安装失败的自定义操作。它的定义如下:

<CustomAction Id="ReportError" DllEntry="ReportError" BinaryKey="Actions.dll" Return="check" Execute="immediate" />
...
<InstallExecuteSequence>
  <Custom Action="ReportError" OnExit="error">NOT Installed</Custom>
  ...
</InstallExecuteSequence>

是否可以在

ReportError
代码中获取msi错误代码和消息?

例如我可以在 msi 日志文件中看到类似

Error 1327. Invalid Drive: E:\
的错误。如何检索错误代码 1327 和错误消息 无效驱动器:E:\

wix windows-installer custom-action
1个回答
0
投票

不确定获取错误文本和代码,但您可以在任何失败时显示自己的错误文本: 喜欢那个样本:

<CustomAction Id='AddComponent' Property='Component' Value='"!(wix.exeLocation)\sys-or-your.exe" /norestart /quiet' Execute='immediate'/>
<CustomAction Id="Component" DllEntry="WixQuietExec64" BinaryKey="WixCA" Execute="deferred" Return="check" Impersonate="no" />
<CustomAction Id="Error" Error="Sys or your Component not added."/>
<InstallExecuteSequence>
  <Custom Action="AddComponent" After="CostFinalize"></Custom>
  <Custom Action="Component" After="InstallInitialize"><![CDATA[(NOT Installed)]]></Custom>
  <Custom Action="Error" OnExit="error">NOT Installed</Custom>
</InstallExecuteSequence>
© www.soinside.com 2019 - 2024. All rights reserved.