nutdotnet / WinNUT-Client

WinForms-based client for monitoring your Uninterruptible Power Supply (UPS) connected to a Network UPS Tools (NUT) server.
GNU General Public License v3.0
209 stars 19 forks source link

Program settings not carrying over to new versions #135

Closed gbakeman closed 7 months ago

gbakeman commented 7 months ago

The default form of Application Settings (File) will only automatically upgrade when using a pure ClickOnce installation. In order to have a smooth user experience, we need to manually call the Upgrade method to carry over the old version of Settings.

Todo

Notes

Data directory and application versions

When a new version of an application is installed, ClickOnce will copy all the existing data files from the previous version's Data Directory into the new version's Data Directory—whether they were included in the original deployment or created by the application.

It seems that this copy operation is not happening. Most likely because we are still using the MSI for deployment rather than true ClickOnce.

If you need finer-grained migration of data, you can use the ClickOnce Deployment API to perform custom migration from the old Data Directory to the new Data Directory. You will have to test for an available download by using IsFirstRun, download the update using Update or UpdateAsync, and do any custom data migration work in your own after the update is finished.

In the meantime, figure out how to do this custom data migration work.

ClickOnce and application settings

When your user upgrades to a later version of your application, application settings compares most recent (highest-numbered) version's settings against the settings supplied with the updated version and merges the settings into a new set of settings files. ... If you have created your own application settings wrapper class and wish to customize the update logic, you can override the Upgrade method.

Even though we are using the standard application settings class, we may need to either call or modify the Upgrade method.

According to the Upgrade method of the LocalFileSettingsProvider...

This way this method is called depends on the type of application that is being upgraded:

As long as we deploy the Setup Project MSI type, we'll need to manually run the Upgrade method with Default settings to try and detect a previous version, unless the Setup project is modified to run this procedure manually.

Alternate solution - trigger settings upgrade from MSI upgrade

It seems that detecting an upgrade installation from the MSI its self is difficult and requires modifying the MSI post-build. May be best to stick to the previous suggestion from Microsoft - use a persisted property in the Settings.

masterwishx commented 7 months ago

same for me , i installed new version on 2.3.8800 where was setting backup and moved , but now again its asking for setting to backup and move ...

gbakeman commented 7 months ago

@masterwishx Looks like this may be fixed now, go ahead and update WinNUT and your settings should carry over now. Let me know in here if the issues persist.

masterwishx commented 7 months ago

@masterwishx Looks like this may be fixed now, go ahead and update WinNUT and your settings should carry over now. Let me know in here if the issues persist.

Working Fine now