In a Windows Service project, with a Project Installer I tried the following:
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
{
base.OnBeforeInstall(savedState);
Settings.Default.ASetting = "aValue";
Settings.Default.Save();
}
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
Settings.Default.ASetting = "aValue";
Settings.Default.Save();
}
}
But after the installation when I check the .config file, a older value is still there. There was no .config file in the usual [userfolder]\AppData\Local
For me is important to define this variable in installation time since I will receive its value from a user input in the Setup Project. The constant value here is used for testing purposes only.