How to update the “updater”? (C#)

2020-07-18 03:59发布

问题:

I have a program that consists of two programs: Updater and WorkMaker. Whenever there is an update for WorkMaker - Updater kills it, downloads updates, and runs it again. But say I came up with new Updater program. How do I update it? Through WorkMaker? Through the third program? Thanks.

回答1:

The simplest solution IMHO is:

  • At the moment was requested update MainProgram downloads Updater, along with updates, after launches Updater.

  • Updater closes MainProgram, makes update and relaunch MainProgram, or simply exit.

In this way you have flexible way to update your program (MainProgram), but also Updater itself, when its required.

Hope this helps.



回答2:

I'm not sure how far along your application's architecture is, but as a total replacement for "Updater" have you considered using ClickOnce for managing the deployment of "WorkMaker"?

It will ensure that it's running the latest patch on startup. If the application is a long running one, then you can also manually kick off upgrades too.



回答3:

I use a similar setup to run our msi and msp files when necessary. The solution consists of a small executable that loads a worker DLL in a second AppDomain using Shadow Copying. The executable is so simple that I've never needed to change it. However, I can now easily patch my worker DLL as I please since it's not locked in its original location on disk.



回答4:

You could have your updater dowload the update, run it with some parameters and have the new updater delete the original.

You could also have WorkMaker act as the updater for your Updater program.