[英]How to log custom messages in Wix Installer code?
Here is my Wix code in .wxs
file这是我在.wxs
文件中的 Wix 代码
<Component Id="MyRootCA.cer" Guid="*" Permanent="yes">
<File Id="MyRootCAFile.cer" Name="MyRootCA.cer" Source="Assets\Certificates\MyRootCA.cer" />
<iis:Certificate Id="Certificate.MyRootCA"
Name="MyRootCA.cer"
Request="no"
StoreLocation="localMachine"
StoreName="root"
Overwrite="no"
BinaryKey="MyRootCABinary"/>
</Component>
The certificate is successfully installed on the machine after installation.安装后证书在机器上成功安装。 Now, how do I log the message about this operation?现在,我如何记录有关此操作的消息?
I am executing below command, and it generates log file我正在执行下面的命令,它生成日志文件
msiexec /i installer.msi /L*vx c:\work\Test2.log /q
How do I add, custom messages to this log file?如何向此日志文件添加自定义消息? I would like to add a success message for adding a certificate to the system我想为系统添加证书添加成功信息
I am trying to add custom action
我正在尝试添加custom action
<CustomAction Id="CA.LogCertificateInstallation"
BinaryKey="BI.CA"
DllEntry="LogCertificateInstallation"
Execute="deferred"
Return="check"
Impersonate="no"/>
How do I link this custom action to above Component
?如何将此自定义操作链接到上面的Component
?
Vital : You can make a setup fail if a vital file is not correctly installed by setting the
Vital attribute
to yes in WiX in this fashion:重要:如果重要文件未正确安装,您可以通过在 WiX 中以这种方式将Vital attribute
设置为 yes 使安装失败:<File Source="MyFile.exe" Vital="yes" />
"If the installation of a file with the
msidbFileAttributesVital
attribute fails, the installation stops and is rolled back" . “如果具有msidbFileAttributesVital
属性的文件安装失败,安装将停止并回滚” 。 FileTable - see"Attributes"
section. FileTable - 请参阅"Attributes"
部分。
Default Logging : I don't use the IIS / Certificate element
regularly, but I would be very surprised if it didn't do any logging.默认日志记录:我不经常使用IIS / Certificate element
,但如果它不进行任何日志记录,我会感到非常惊讶。 I would try to read the log again.我会尝试再次阅读日志。 That log command should do, please check more on logging (section: "Interpreting MSI Log Files"
).该日志命令应该执行,请检查更多关于日志记录(部分: "Interpreting MSI Log Files"
)。
Custom Logging : This document from Robert Dickau shows valid custom action code for any tool that can create MSI custom actions.自定义日志记录: Robert Dickau 的这份文档显示了任何可以创建 MSI 自定义操作的工具的有效自定义操作代码。 He shows VBScript
, C++
and Installscript
custom actions.他展示了VBScript
、 C++
和Installscript
自定义操作。 I don't have any sample code for C#
, but the WiX custom action templates do.我没有C#
任何示例代码,但 WiX 自定义操作模板有。
WiX CA Project : WiX Quick Start Links (including downloads) . WiX CA 项目: WiX 快速入门链接(包括下载) 。 In Visual Studio, go to "Add new project..." and select "C# Custom Action Project for WiX v3" .在 Visual Studio 中,转到“添加新项目...”并选择“C# Custom Action Project for WiX v3” 。 The entry looks something like this:该条目如下所示:
Once you have the Custom Action project, the logging code is something like this:一旦你有了自定义操作项目,日志代码是这样的:
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
return ActionResult.Success;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.