Sunday, August 31, 2014

Setup project user logging

When working with Visual Studio Installer projects (vdproj project files) it's possible to create a class like this skeleton to perform custom actions during installer processing:

[RunInstaller(true)]
public class MyCustomActions : Installer
{
  public override void Install(IDictionary stateSaver)
  {
    // Custom install processing here
  }
  protected override void OnBeforeUninstall(IDictionary savedState)
  {
    // Custom uninstall processing here
  }
  // Other overrides are available
}

In the Setup project you open the Custom Actions Editor window and add the assembly containing the custom class to the event nodes. The methods will then be called at the appropriate points in installer processing.

It's possible to add custom dialogs to the install sequence, name the input fields and associate them with properties passed to the custom action events. This simple pre-packaged process is described in other web articles and is not the subject of this post.

An Installer derived class inherits the LogMessage method, but the output from this method does not seem to appear in the installer log. If you run msiexec.exe over an MSI file with the /L*v switch to produce the maximum possible verbose output, you will not see the LogMessage output.

For a long time I wondered where the LogMessage output went. Early last year I found an obscure hint in a web page (that I have lost) that says you can add something like this to the CustomActionData in the custom actions designer:

/logfile="C:\temp\custom-log.txt"