Squirrel.Windows: Inconsistent config file after update.
I update my app with Squirrel and I call RestartApp()
.
Since the old installation folder is left intact and a new one is created inside the rootAppDirectory
, the config file is written from scratch. As a result, any settings retained in the old installation’s config file, don’t migrate to the new config file. This is a problem if the app makes use of Properties.Settings
to keep application settings.
I should either create some logic myself to port the settings I want to the new config file, or dump the Application settings and use a custom settings file, probably saved in AppData\MyAppData
.
Am I missing something?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 19 (7 by maintainers)
Indeed you can use the methods below to backup your settings, typically just after your update has completed, so just after your call to
await mgr.UpdateApp();
You want to restore them at the very beginning of your program, like just after Squirrel’s event handler registration. Don’t try doing a restore from the onAppUpdate it won’t work. By the look of it onAppUpdate is executing from the older app process as it would not get access to the newer app data folder.Agreed, this is the best solution I have found for using
Properties.Settings
with Squirrel. Thanks, @Silon. One thing I had to be sure to do after callingRestoreSettings()
is make a call toProperties.Settings.Default.Reload()
before attempting to use any of the settings.I just implemented @Slion’s solution in Visual Basic. The translation was straightforward. Its a very simple and slick way to solve the problem.
Wow, thanks for this. Worked perfectly for me. Although, like others have said, after restoring the file you need to refresh settings.
Thanks, @Silon. I stumbled over this as well and used your solution. It has its pros and cons the way Squirrel installs an app. I understand the problem with have the same install folder, but have a new folder each time has it problems to.