TFS 2010: How to deploy a Windows service as part of an assembly?

We need to be able to deploy a couple of Windows services on a remote computer as part of the assembly. This is a nightly build that deploys the entire application in a TEST environment, so it needs to be automated in some way.

For a web project, MSDeploy can be used, as well as for database servers. But what about windows services? They must be stopped (if they are already installed) on the target machine, then binary files must be copied, the service must be registered (if it is not installed earlier), etc. Etc.

+4
source share
3 answers

You can use MSDeploy for this. There is a runCommand provider that runs the specified command on the destination computer.

msdeploy.exe -verb:sync -source:runCommand="net start MyService" -dest:auto 

You can read more here: http://technet.microsoft.com/en-us/library/ee619740(WS.10).aspx

+1
source

Our way to achieve this is the litte web service, which runs on our servers, which controls a specific directory for new files. Our assembly deploys the Windows services in this folder with a temporary name and then renames them to the tracked name template ("servicename.deployservice.zip"), the deployment service will take such a file, unzip it to a temporary location and perform the necessary steps for deployment (for example, stop the old service, delete the old service, install the new service, start the new service). If you need to move special actions, you can add the deployment DLL or "build script" to the deployment ZIP file.

The easiest way to execute such deployment code with most common ones is to use a service that just waits for the installation (msi or something else) in the zip file and does it. That way, you can just add the deployment setup to your project and make very less in your Teambuild ...

+1
source

Assuming you are using VS 2010 and TFS 2010, you can modify the build workflow to add an ExecuteProcess activity (inside the AgentScope agent for the target server) to start svcutil.exe with your service name.

+1
source

Source: https://habr.com/ru/post/1309492/


All Articles