Skip to content

davidpricedev/SampleSelfUpdatingWindowsService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SampleSelfUpdatingWindowsService

Testing a TopShelf service that can update itself

To test:

  1. Build one version. Copy the binaries to the run folder.
  2. Build another version (different version number). Copy the binaries to the upgrade folder.
  3. Install the service in the Run folder SampleTopshelfSvc.exe install
  4. Start the service net start SampleTopshelfSvc
  5. Wait a while and check the version number of the executable in the run folder, it should be the upgraded version.

Note

Obviously this code is a sample of what can be done and is in no way ready for any production environment.

Other options for self-updating windows service

  • Run two windows services - one that does the updating and the other that does the functionality you really want.
  • Primary service is just a container that loads the real functionality as a plugin into a separate AppDomain. As long as you turn on shadow-copy when importing the real functionality, the functionality plugin should be able to update itself (to take effect next time the service starts or if the container is set to restart on file changes).
  • PendingFileRenameOperations - tie into the same thing used by windows update, so next time the system restarts, windows will replace files for you.
  • Have the service simply do Process.Start on any executable that stops the service, updates it, and starts it again.

It seems to me that the last option - to simply Process.Start an updater is vastly simpler than any of the other options. This doesn't come with any baggage code that can't be updated. It also doesn't require a reboot for things to take effect. The only slight downside is the need to have the updater know how to stop/start the service - not exactly a huge problem.

About

Testing a TopShelf service that can update itself

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published