Alexey Raga
Alexey Raga

Reputation: 7525

TFS 2010: How to deploy a windows service as a part of a build?

We need to be able to deploy a couple of windows services to the remote machine as a part of a build. This is a nightly build which deploys the whole application to the TEST environment so it has to be automated somehow.

For the Web project MSDeploy can be used, as well as for the DB servers. But what about windows services? They have to be stopped (if already installed) on the target machine, then binaries need to be copied, the service has to be registered (if not previously installed), etc, etc...

Upvotes: 4

Views: 3218

Answers (3)

Hakan Forss
Hakan Forss

Reputation: 596

You can use MSDeploy to do 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

Upvotes: 1

Pete Stensønes
Pete Stensønes

Reputation: 5665

Assuming you are using VS 2010 and TFS 2010 then you could modify the build workflow to add a ExecuteProcess activity (inside an AgentScope actiivty for the target server) to run svcutil.exe specifying the name of your service.

Upvotes: 1

eFloh
eFloh

Reputation: 2158

Our way to accomplish this is a litte web service running on our servers which monitors a certain directory for new files. Our build deploys the windows services to that folder with a temp name and then renames them to a monitored name pattern ("servicename.deployservice.zip") the deployment service will take such a file, unzip it to a temp location and performs the neccesary steps for deployment (e.g. stop old service, uninstall old service, install new service, start new service). If you need to transport special actions, you could add a deployment code DLL or "build script" in the deployment ZIP file.

The easiest way to accomplish such deployment code with most generic is a service that simply expects an (msi or whatever) setup in the zip file and executes that. This way, you can simply add an deployment setup to your project and have very less to do in your Teambuild...

Upvotes: 1

Related Questions