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...

2 opmerkingen:

  1. hi Tim, your reflected code helped me out, and maybe this will help you. I successfully got some context logging to work. All that was needed was on the custom action data property for the custom action you need to add

    /logfile="c:\context.log"


    now with the logging call you used a simple log file will be created. I added the same data for the unnstall as well to a differnt log file.

    BeantwoordenVerwijderen
  2. How to Bet the Game: Casino | Dr.MD
    In 진주 출장안마 Casino, the game takes the 삼척 출장안마 player 충청북도 출장샵 to a bet that pays out. The bet 목포 출장샵 has 경산 출장안마 two outcomes, a “push” or “push” (duel) where the bet is exactly

    BeantwoordenVerwijderen