vrijdag 23 oktober 2009

msiexec != installutil

Some months ago I've developed a custom install action which allows installation of BizTalk applications through an msi installation. To do this I derived a class from the Installer class.
When you do this you have the ability to log some actions by the use of:

base.Context.LogMessage("Installation started.");

At least, that was what I thought... When I supplied the neccesary parameters to enable logging to the msi (xxx.msi /l* log.txt) I got a nice log.txt with a lot of logging...but the logging I supplied was nowhere to see in the file! Strange, so I went to MSDN (http://msdn.microsoft.com/en-us/library/system.configuration.install.installcontext.logmessage.aspx) to lookup the use of this particular method. Didn't help me a lot to be honest.

So I fired up Reflector to see what this method does.

public void LogMessage(string message)
{
this.logFilePath = this.Parameters["logfile"];
if ((this.logFilePath != null) && !"".Equals(this.logFilePath))
{
StreamWriter writer = null;
try
{
writer = new StreamWriter(this.logFilePath, true, Encoding.UTF8);
writer.WriteLine(message);
}
finally
{
if (writer != null)
{
writer.Close();
}
}
}
if (this.IsParameterTrue("LogToConsole") || (this.Parameters["logtoconsole"] == null))
{
Console.WriteLine(message);
}
}


As you can see the method expects some parameters to be set. Especially the 'logtoconsole' parameter. So when I then added the custom action to a Visual Studio Setup project I did not have my customized logging.

I have not got it to work with my custom logging. Anyone has an idea of how to log your log entries from your custom action in the msi.log file? Now I do not have custom action logging in the log file, which is not good. Strange that Microsoft has no article about this problem. I hope they will fix this some time...