I simply want to create a custom installer to run code after installation which requires the path of the installed application.
I read about how to create a custom installer and Custom Actions, as well as what properties are available in the installer, but I don't quite get how to access those properties from inside the custom installer code. (Don't even get me started on the complexity of Windows Installer documentation.)
The best answer would be full code for a custom installer using the app path. This is what I've got so far:
using System;
using System.ComponentModel;
namespace Hawk
{
[RunInstaller(true)]
public class Installer : System.Configuration.Install.Installer
{
public Installer()
{
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
try
{
//TODO Find out installer path
string path = (string)stateSaver["TARGETDIR"]; // Is this correct?
// Environment.CurrentDirectory; // What is this value?
MyCustomCode.Initialize(path);
}
catch (Exception ex)
{
// message box to show error
this.Rollback(stateSaver);
}
}
}
}