Click here to Skip to main content
15,077,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have created a window service using C#.NET and want to create its automatic updater service. My service will be installed from my custom msi windows installer. I start browsing and found wybuild is tool which will help you to do so, but will work only with services installed as LocalSystem.

Here my window service will run under context of a user credentials.

These are my queries, if I think of creating it manually -

1) Is there any other package available to do this task?

2) If I will develop this updater service manually, How I need to proceed? Like one major query I have is - Should Uninstall and install service from scratch so that will have proper version when I will try to uninstall it from Program and Feature. Or should I just replace files and start service? Will this create any issues in versioning, when I will try to uninstall it from Program and Feature?

3) On server how files should be placed, zip or normal. If zip, what if any errors came while extracting or something?

Like these kind of 'n' number of issues I am worried about.

Any help.

Thanks
Posted
Comments
Zoltán Zörgő 3-Jul-12 3:30am
   
Simplest way (not applicable in complex dependency cases) stop the service, replace assamblies that need to be replaced and restart the service. This won't cause problems when uninstalling only if you change file names, add files. In other cases you should uninstall the previous version, but don't forget not to delete configuration, and upgrade configuration if needed. You can interact with MSI service from code, but you also can install or uninstall service from code.
sunder.tinwar 3-Jul-12 4:28am
   
thanks for reply, I know that if I stop service replace exe and dlls and start service app will work great. But only doubt I had is I installed version 1.0.0.0 from MSI installer and updated exe and dlls to version 1.0.0.1. When I try to uninstall it from program and feature will it work? Still have that doubt
Zoltán Zörgő 3-Jul-12 4:57am
   
The installer is not dealing with assambly versions. The installer itself publishes it's own version, and that is linked with product GUID (kind of). Of course, by replacing the files only, the system will not know about the version change. You can alter it in the registry if you want. Look here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
sunder.tinwar 3-Jul-12 5:01am
   
how the files on server should be? In zip or what? and what if any error while extraction?
Zoltán Zörgő 3-Jul-12 5:36am
   
If you have bandwidth, you can even copy files one-by one. But having a store-level zip is giving you more consistency.
But: there is a toolset in .net that might be considered: ClickOnce [see: 1, 2, 3] - but it is not for services...
sunder.tinwar 3-Jul-12 5:39am
   
thanks for information, ClickOnce dont work well with windows service. Its good for windows or wpf applications.
sunder.tinwar 3-Jul-12 5:42am
   
so except HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall this location when we install product MSI dont write information anywhere else? I though it might be maintaining a local db? anyhow, that was important information I browsed registry and verified that.
Zoltán Zörgő 3-Jul-12 5:53am
   
Registry is the local db. If you dig more deeply, it is not that simple (see 1, 2). But in practice, for general cases you don't have to deal with these.
But if you have doubts, make your service download the msi, make call to the infrastructure to uninstall the old version and install the new one. This is also not really complicated.
sunder.tinwar 3-Jul-12 6:45am
   
Its will become complicated for me in that case as mine MSI is not normal windows msi setup, It run my custom installer and accept input from user.
Zoltán Zörgő 3-Jul-12 8:05am
   
Change it to accept parameters, or set defaults. You made the installer or not? If you replace assamblies, user input is of no use either...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900