I've made an simple installation class:
[RunInstaller(true)]
public class MyCustumAction : Installer
{
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string value = Context.Parameters["targetdir"];
throw new Exception("Contact?? " + value);
WriteLog(value);
}
private void WriteLog(string message)
{
using(FileStream f = File.Create(@"C:\ik ben nieuw.txt"))
{
using (StreamWriter w = new StreamWriter(f))
{
w.WriteLine("Dag van installatie: " + DateTime.Now.ToString());
w.WriteLine(message);
}
}
}
}
In my Setup project I've done the following:
- Add project output - primary output of my assembly
- Add a Custom Action on the Install directory (Custom Actions view)
- Set CustumActionData to '/targetdir="[TARGETDIR]\"'
- Build my assembly and build the setup project
During the installation, the Exception is not thrown. Why not? It seems that my class isn't invoked. What am I doing wrong here?
UPDATE
When I create a seperate project with only the installer class in it and add this ont to my project ouput and set the custum action properly, I do get the exception!
Now I am wondering why this same file doesn't get invoked in my own (winforms) assembly..