Reputation: 38346
Say, you have a custom Windows service installed on a server. The service is written using .NET, and it is installed using either InstallUtil, an MSI package or the ManagedInstallerClass (if it makes a difference, pick the one that solves the problem). Regularly, you will need to deploy changes to the service, and of course you want to make this as easy as possible.
Is it "safe" to just stop the service, replace the .exe file and restart the service? Or would you have to uninstall and reinstall with the new .exe file? Would it be easier if the "evolving" part of the service was split into a separate assembly? Are there any tools or APIs that might be of help in either development or deployment of the service?
Upvotes: 8
Views: 5394
Reputation: 176219
For updating services we either use MSI packages (in case we provide an installer to our customers anyway) or a short script that handles stopping and uninstalling the old version of service, and then copies, installs and starts the new version.
For scripting the deployment of local services you can use standard Windows commands such as net start
and net stop
in combination with installutil
, for remote deployment you could e.g. use psexecute
and psservice
from SysInternals.
Upvotes: 2
Reputation: 29051
Just stop the service, replace the EXE and restart it. This should probably be part of your installer. Separating it into separate assemblies just for the sake of reinstall is a rabbit hole.
Upvotes: 5
Reputation: 55112
I just stop the service and replace the exe; it's safe to do that.
You can have it so that your service begins to load modules, and you develop your system that way; it would work, but it may be overly complicated, or not, depending on what exactly you're wanting to do.
Upvotes: 12