使用ExternalUI的安装程序事务会破坏我的日志文件

时间:2011-02-15 10:31:25

标签: wix windows-installer

安装程序事务和ExternalUI的奇怪行为会破坏我的日志文件。

我在此交易中链接了三个MSI。 我为每个安装程序创建了一个详细的日志文件。 最后,我的“最后”详细日志将被删除。 它始终是“最后一个”。

我做错了什么? 如何避免这种行为?

在我提交交易

之后会发生这种情况
transaction.Commit();

正好在这里:

 private void End(bool commit)
 {
     uint ret = NativeMethods.MsiEndTransaction(commit ? 1 : 0);
 }

我的上一个日志文件将被删除并替换为这个镜头:

=== Verbose logging started: 15.02.2011  10:58:16  Build type: SHIP UNICODE 5.00.7600.00  Calling process: \\olli\Public\Hin und her\Kai-Uwe\InstallWizard.exe ===
MSI (s) (08:30) [10:58:16:631]: User policy value 'DisableRollback' is 0
MSI (s) (08:30) [10:58:16:631]: Machine policy value 'DisableRollback' is 0
MSI (s) (08:30) [10:58:16:631]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (08:30) [10:58:16:631]: MSCOREE not loaded loading copy from system32
MSI (s) (08:30) [10:58:16:959]: Note: 1: 2318 2:  
MSI (s) (08:30) [10:58:16:975]: Note: 1: 2318 2:  
MSI (s) (08:30) [10:58:16:975]: Note: 1: 2318 2:  
MSI (s) (08:30) [10:58:16:975]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied.  Counter after decrement: -1
MSI (s) (08:30) [10:58:16:990]: Restoring environment variables
MSI (s) (08:30) [10:58:16:990]: Calling SRSetRestorePoint API. dwRestorePtType: 0, dwEventType: 103, llSequenceNumber: 12, szDescription: "".
MSI (c) (E0:0C) [10:58:16:990]: Cloaking enabled.
MSI (s) (08:30) [10:58:16:990]: The call to SRSetRestorePoint API succeeded. Returned status: 0.
MSI (c) (E0:0C) [10:58:16:990]: Attempting to enable all disabled privileges before calling Install on Server

来自我的班级:

using (Transaction transaction = new Transaction("Install", TransactionAttributes.None))

foreach (MsiPackage package in _availableMsiPackages.Values){

  Installer.EnableLog(InstallLogModes.Verbose, LogPath);
  Installer.SetInternalUI(InstallUIOptions.Silent);
  ExternalUIRecordHandler _processMessageHandler = new ExternalUIRecordHandler ProcessMessage);
  ExternalUIRecordHandler result = Installer.SetExternalUI(_processMessageHandler, InstallLogModes.Verbose);

  Installer.InstallProduct(fi.FullName, _commandLine);
}

transaction.Commit();

1 个答案:

答案 0 :(得分:1)

您是否尝试过调用EnableLog()的四参数版本?在该版本中,第三个参数允许您将其置于追加模式,第四个参数启用刷新。我猜测不附加模式适用于在Commit()期间重新打开日志文件。如果您仍想在开头截断,可以在开始安装之前删除任何现有文件。

Installer.EnableLog(InstallLogModes.Verbose, LogPath, true, true);