It’s pretty simple but I’m bound to forget (again).

  • Click on the Setup Project (the one that’s generating the msi installation file) and in the Solution Explorer menu bar click on the Custom Actions Editor,
  • Right click on the Commit folder (Commit actions run after the install has completed) and choose Add Custom Action. In the dialog box select Application Folder (which is the destination application folder on the client performing the install) and press Ok. The Primary output should already be in the dialog box, if not add it by clicking Add Output button and selecting the appropriate project (the one that will hold the custom execution class) and choose Primary Output,
  • Add a new Installer class (that’s a specific type of Visault Studio class not a normal class caleld installer) to the Primary Output assembly,
  • Right click on the new installer class and select view code and add whatever is required to it. An example for a commit action is below.
  • public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
        string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        System.Diagnostics.Process.Start("cmd", "/c certutil -f -p password -importpfx \"" + path + "\"\\cert.p12");
    }
    

    Advertisement