web-setup-projectmanagedinstallerclass

Problems using an installclass in a web setup for a web site


I am trying to create a web setup for my web site, and I want to use an installer class to do some custom stuff. I am using VS 2010, and the web site and installer is .NET 3.5.

I have added reference to the installer class project output in the Install section under Custom Actions:
Custom Actions

I have also set /targetdir="[TARGETDIR]/" on the CustomActionData for this action.

The InstallScript project is a standard class library (dll).
There is a public class that inherits from Installer class. It overrides the Install method as I have seen been done in several online examples:

using System.Collections;
using System.Windows.Forms;

namespace InstallScript
{
  public class MyWebInstaller : System.Configuration.Install.Installer
  {
    public override void Install(IDictionary stateSaver)
    {
      base.Install(stateSaver);
      var targetDir = Context.Parameters["targetdir"];
      if(targetDir==null) targetDir = "No TARGETDIR!";
      MessageBox.Show("TARGETDIR:\t" + targetDir);
    }
  }
}

I would think there should be shown a message box here som time during the install, but it seems like it is never called. No error is shown either. The setup just runs through as if this code was never called.

Anyone have idea of what is wrong?


Solution

  • OK, I found out what was missing.

    You need to specify the class with the class attribute RunInstaller(true) for the setup to pick up and actually run the code.

    So the class needs to be declared like this:

    [System.ComponentModel.RunInstaller(true)]   
    public class MyWebInstaller : System.Configuration.Install.Installer   
    {
      ...