title: Change userSettings during MSI installation
body: <p>I am trying to modify the userSettings section (Properties.MyApp.Default) in the MyApp.exe.config file during the installatio of my WPF application using an MSI installer.</p>
  
  <p>I basically implemented it like in this excellent article: <a href="http://raquila.com/software/configure-app-config-application-settings-during-msi-install/" rel="nofollow noreferrer">http://raquila.com/software/configure-app-config-application-settings-during-msi-install/</a></p>
  
  <p>The difference is that I am not editing the appSettings but the userSettings section. </p>
  
  <p>The problem is that although the code runs fine, the settings are not saved. After the installation the config file contains the old settings I use in my development environment. 
  I also tried to override OnAfterInstall(System.Collections.IDictionary stateSaver) instead of Install(System.Collections.IDictionary stateSaver) but it doesn't make a difference.</p>
  
  <p>Here is the code that should change the config values:</p>
  
  <pre><code>protected override void OnAfterInstall(IDictionary savedState)
  {
      base.OnAfterInstall(savedState);
  
      string targetDirectory = Context.Parameters["targetdir"];
      string tvdbAccountID = Context.Parameters["TVDBACCID"];
      // read other config elements...
  
      Properties.Settings.Default.Tvdb_AccountIdentifier = tvdbAccountID;
      // set other config elements
  
      Properties.Settings.Default.Save();
  }
  </code></pre>
  
  <p>Any idea how to persist these changes? I already read about Wix but that seems like an overkill to me. </p>
  
  <p>Thanks in advance!</p>