Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best method for implementing Self-Updating Software

We have a minimal 'updater' exe that checks a remote URL for updates, downloads them and replaces files on disk prior to launching the real application. However if we want to replace the updater EXE then AFAIK we have two options:

  1. Shadow Copying Assemblies whereby .Net will create a shadow copy of the EXE (and any referenced assemblies) and load those assemblies, such that the non-shadow assemblies can be replaced and will be used when the application is next launched.

  2. Identify which files are replaced and rename/move them on disk. Windows seems to allow the renaming/moving of locked files, so we can move the files and copy in the new assemblies. Again, on next launching the application we will be launching the new assemblies. This approach is mentioned here

Is this second method a recommended method? Are there any pitfalls to this approach?

like image 831
redcalx Avatar asked Jul 31 '09 11:07

redcalx


People also ask

How do you implement software update?

For example, provide criteria that retrieves all security or critical software updates that are required on more than 50 clients. Create a software update group that contains the software updates. Download the content for the software updates in the software update group. Manually deploy the software update group.

Is automatic updates good?

It's generally better to keep auto-updates on so that you can get a timely security fix in case there's a vulnerability found in an app you're using—but whether you should enable or disable auto-updates comes down to personal preference.

What is automatic system update?

If the automatic update feature is enabled, your applications get updated without being asked, so you may not realize that large volumes of data are being downloaded. You can disable the automatic update feature to avoid potentially high data transfer costs.

Why are automatic updates important?

Updates can prevent security issues and improve compatibility and program features. Software updates are necessary to keep computers, mobile devices and tablets running smoothly -- and they may lower security vulnerabilities. Data breaches, hacks, cyber attacks and identity theft have all been in the news.


4 Answers

Another option: when the main application wants to update itself, it spawns a new updater process and then closes itself. The spawned process in the meantime waits for the main application to close (the process to disappear) and then updates all of the necessary files (including the .exe). After that it simply restarts the main application and exits the updater process.

like image 145
Igor Brejc Avatar answered Nov 07 '22 10:11

Igor Brejc


Im using the second method without any problems. Just make sure the downloaded assembly was correctly downloaded. ;)

Run Update.exe and let it do this:

  1. download the new update.exe as update.ex_
  2. rename the update.exe to update.bak (you can rename it, but not overwrite it)
  3. rename the update.ex_ to update.exe
  4. restart update.exe

Im doing this with no problems at all so its tested and are running in live environment in about 400 customers as we speak.

like image 43
Stefan Avatar answered Nov 07 '22 12:11

Stefan


What about ClickOnce deployment?

like image 43
Tadas Šukys Avatar answered Nov 07 '22 10:11

Tadas Šukys


In a project i worked on, there where 2 executables. Let's call them A and B.

The only reason A existed was to start B. So, when B (the 'real' application) downloaded an update, it was able to replace A if neccesary.

If the application was restarted (via A), A checked if B downloaded some files and replaced them before it started B.

like image 3
sloth Avatar answered Nov 07 '22 10:11

sloth