10

As part of a continuous delivery pipeline I'd like to install an msi on a given machine. msiexec plus psexec does this perfectly, but it seems that msiexec can only log to a file and I need it to log to stdout/stderr.

Right now, to get the output back into our CI software I'll have to add a second step to echo the contents of the log, which seems a bit pointless.

Has anybody faced this issue before (and overcome it?)

Thanks in advance for any help here.

Mark

mrmrcoleman
  • 101
  • 1
  • 4
  • Use msiexec's built in file logging, and read back from disk. Several msiexec.exe processes can be launched during installation, and I think you'd be hard pressed to redirect the output of all of them. You may see automatically spawned msiexec.exe processes running in different security contexts and also in order to run custom actions. A can of worms I'd say to deal with. – Stein Åsmul Jan 24 '14 at 08:59

4 Answers4

5

I checked this again, and here is some updated information:

It is possible to suppress the MSI GUI and set an external GUI implemented by a third party. This external GUI is able to receive messages from msiexec.exe as it performs the installation. This is mostly to implement a custom progress bar, but it seems you can also intercept most other error messages and status messages: MsiSetExternalUI function.

The interesting parameter is the dwMessageFilter. By setting this you can, for example, receive only the error messages that occur during the installation - or so it would seem. I suppose this can be enough for most purposes.

INSTALLUI_HANDLER MsiSetExternalUI(
  _In_  INSTALLUI_HANDLER puiHandler,
  _In_  DWORD dwMessageFilter,
  _In_  LPVOID pvContext
);

Regrettably I do not have sample code for this at the moment. I will test this later, when I get my system set up properly. The MsiEnableLog function is a related function call that will enable logging to file. Update: Here is what looks like a working SDK example.

At the command line interface level, you can also set logging to flush its buffer immediately to file by adding the ! parameter:

msiexec.exe /I "IsWiX.msi" /QN /L*V! "C:\msilog.log" 

This means the log file is written continuously so no log buffer is lost if msiexec.exe crashes. The cost is a significantly slower installer due to the IO overhead.

Stein Åsmul
  • 2,566
  • 4
  • 25
  • 38
3

MsiExec can only log to a file, so you will have to keep echoing the content of that file after the installer finished.

Ansgar Wiechers
  • 4,197
  • 2
  • 17
  • 26
2

I would rather cache the MSI log file on the local system permanently in a common location for each install, and then just register the exit code of the whole setup. If the setup reports success, the log file is pretty uninteresting? Just more "noise"?

Other than that there are several software delivery systems that will capture the log information for an MSI install and store it centrally. One example is SCCM (Microsofts renamed Systems Management Server - SMS).

Setting up logging for all MSI files, see section "Globally for all setups on a machine": http://www.installsite.org/pages/en/msifaq/a/1022.htm

Stein Åsmul
  • 2,566
  • 4
  • 25
  • 38
1

I use the following powershell script. It still requires writing the log to a file but it also writes the contents live to stdout:

$main_process = Start-Process -FilePath ".\installer.exe" -ArgumentList "/S /V`"/qn /l*! output.log`"" -NoNewWindow -PassThru
$log_process = Start-Process "powershell" "Get-Content -Path output.log -Wait" -NoNewWindow -PassThru
$main_process.WaitForExit()
$log_process.Kill()
exit $main_process.ExitCode
inkychris
  • 111
  • 1