I have a basic setup project in Visual Studio 2010, and I am struggling with setting up custom actions. I have 3 Installer classes in a separate assembly.
The 3 classes do the following things:
Install
method)BeforeInstall
event) BeforeInstall
eventThe problem is the last one, it seems the BeforeInstall
event is never triggered. I've tried to make it create a file on disk, and displaying a MessageBox
. It never triggers.
The "Primary output from SetupActions" has been added to the "Install" section in the Custom Actions editor. My Installer classes all have [RunInstaller(true)]
.
Code that does not work:
[RunInstaller(true)]
public partial class InstallerStopProgram : System.Configuration.Install.Installer
{
public InstallerStopProgram()
{
InitializeComponent();
}
private void InstallerStopProgram_BeforeInstall(object sender, InstallEventArgs e)
{
MessageBox.Show("This is never displayed during the install");
}
}
Problem with this approach is that you want to run something before installation and that something resides in the dll/exe that gets onto the target machine only as a part of installation. So unless installation is done, you will not have your BeforeInstall code on the disk to run (and then you can make it run only as post install).
To my knowledge, what you want to achieve is not possible VS 2010 setup project. Perhaps, you should use Wix (or NSIS)!