Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the easiest way to update a .NET Windows service in production?

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?

like image 836
Jørn Schou-Rode Avatar asked Jan 20 '10 22:01

Jørn Schou-Rode


People also ask

How do you update Windows services?

To check for updates manually, select the Start button, then select Settings > Update & Security > Windows Update >, and then select Check for updates. Learn more about keeping Windows 10 up to date.

How do you deploy a Windows service to a production server?

Answers. You can add a installer class to your project, and the add your project outputs to a setup project, then you can use this installer install your windows service. For more details you can look into the steps in the MSDN document.

Can a Windows service update itself?

You can't have a service update itself because the . dll that is running will not stop. Seperating the business logic layer would be a good option. You could also rewrite the main service to run under reflection by a master or control service.

Does .NET core support Windows service?

NET Core and . NET 5+, developers who relied on . NET Framework could create Windows Services to perform background tasks or execute long-running processes. This functionality is still available and you can create Worker Services that run as a Windows Service.


1 Answers

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.

like image 172
Noon Silk Avatar answered Oct 12 '22 17:10

Noon Silk