EmmittJ/PoESkillTree — pull request #53 by l0g0sys (2014-12-01 14:20:47+00:00)
Title: Update mechanism from Git releases

Finaly figured out how to make self-updating possible, i.e. how to allow overwriting of DLLs and exe files while application is running.
All magic is done in Bootstrap class which is now new application entry class with Main method.
The whole trick is to not run application from main exe directly, but from its copy, and run this copy and all DLLs of assembly in application domain with shadow copying enabled.

It has 2 drawbacks atm:
* Update process cannot be debugged as all this messing with processes doesn't work well with VS debugger (so when launched in Debug mode, it simply runs from main exe and without any copying to allow debugging in VS).
* Only 1 application instance (process) can run at a time (if application is already running and you start exe again it won't do anything).

I've made also example of update process UI integration (without actual UI elements) in MainWindow class.
* The initial method for update process is mnuCheckForUpdates which could be invoked from menu and it just checks for latest release on Git.
There is no version name comparsion, it's simply current version string != lastest release version string on Git, then it's considered a new release.
*Updater.CheckForUpdates* method used here, returns null if there is no update or Updater.Release object with info about release if its version differs from running one.
* btnUpdateInstall method can be invoked on some Install button press in dialog showing new release informations.
*Updater.Download(downloadCompleteHandler, downloadProgressChangedHandler)* starts downloading of new release which was last checked.
This could show some progress bar as downloading is asynchronous and can even be canceled like it's in example code (*btnUpdateCancel* method).
* *UpdateDownloadCompleted* checkes for cancellation, error or download completeness.
If download finished without issues it invokes Updater.Install and Updater.RestartApplication to extract and copy files from package and restart application.
* *UpdateDownloadProgressChanged* just reports download progress change.

Update process can be implemented in many ways, due to Updater class holding update process status until it's told to dispose it.
For example, it could be implemented like Windows Updates works (i.e. when you open updates dialog it would always show last step of update process, install step could be separate as well as application restart).
But, the one i showed in MainWindow example looked simple to do.