I am trying to make an application using windows installer as it's install method. When the installation succeeds I want to get the path where the primary output is located that I configured in the installer. In my case the primary output is in the folder [ApplicationData(Installroot)]\Bin\
.
I also have a custom settings file called App.Settings in 1 my Class Library which controls several settings like file locations who are relative to the install location.
So the idea is that when the installation succeeds it should call the App.Settings and save the install folder to the settings file.
I already made an Install class and put it inside the Class Library. I am not sure if it is supposed to be in that project though. This is the code of the Install Class:
using System.Collections;
using System.ComponentModel;
namespace WaspbaneModels
{
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
public Installer()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
SettingsControl.BaseURL = Context.Parameters["assemblypath"];
SettingsControl.Save();
}
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall(savedState);
}
}
}
In this code SettingsControl is the class that takes care of the Settings simply with some properties. I used this class so that my Windows Forms project also can access these settings.
In the Custom Actions tab I also added the Primary Output to everything. I am also not sure if this is correct because I think the Primary Output contains all .dll files including the Class Libraries.
I am not really sure where to continue from this point however because the Settings are not saved. I simply check this by putting up a messagebox at the startup of the application giving me the value of the setting.
Anyone interested in more data of the project just ask. I just won't post everything at once yet.
EDIT:
After some more testing I managed to find out that the Installer class isn't being called upon. I added something that would write out to a file when the method would've been called but nothing happened.
Therefore my question now is: How do I add the Custom Action to the Setup project properly?
You can add the custom action class (.dll) to the Setup project. You have to add the InstallerActions.dll to the Install and Commit actions.
To add the custom action