Continuous TFS Deployment for Windows Service?

I was able to perform a continuous deployment for my web project using TFS Msbuild.

I looked for several hours but could not find a relative link to achieve continuous deployment for the Windows service.

Can I make a CD for a Windows service using TFS build definitions? ie for each check in the following steps, I have to use TFS2010 with Windows Server 2008 R2

1] Stop the service,

2] Copy the appropriate Project folder from the (Source) Build server to the "staging server" server "staging server1" or "staging server2"

3] Start the services (wanting to do this step manually)

Any blog links to tutorials to achieve this? I assume you need to use Power shell scripts, but not sure.

+6
source share
1 answer

It should be fine, you need to install the agent in the field in which you are deploying. And you will need to be able to exit the XAML templates (you probably want to copy the existing template that makes your assembly, and just add the stop / copy / start stuff to the end).

After building the CI, you will need to edit it (the XAML template) to start and stop the service, which you can use for the invoke process operation (you probably want to do something like make it shared and pass in the name services as an argument - note that you can change the display names, etc. in the metadata argument so that it looks meaningful in the definition of your assembly).

As for copying files through files, you can do this quite easily by accessing properties such as the delete location.

It should be pretty straight forward - as soon as you start changing templates!

Edit:

It’s a pity that I didn’t answer before, I would have to reconsider my previous comment, it’s not as straightforward as it seems, if you really don’t know what you want, I thought about it and, like cat-skins, there is more than one way to achieve this. .. I have rewritten this several times, so I hope that editing makes sense :)

Resets to the following value:

1) Go to your assembly / machine agent template for which you want to run it (this can be done as a simple line or as the AgentReservationSpec tool is up to you), since this is unlikely to be the machine that you are running your actual CI built. This is done in the XAML Arguments section, as noted earlier, if you want to edit the display name / description, you can edit the Metadata Argument. Of course, a TFS agent is required for this machine.

2) Run the task on the remote computer, this is done by adding the Scope agent activity to your template, you will need to use the information from step 1 to get the ReservationSpec (so it would be easier if you added the argument as AgentReservationSpec, or you need to allow this is in the template)

2.1) Run stop / uninstall, this is done by resetting (actually) the Invoke Process Activity, the Invoke Process can take arguments, and you need to point it to the executable that you are running, so you'll want to use this: one for the command NET (i.e. .NET STOP) and one for InstallUtil.exe.

2.2) Copy the files from your CI to the remote server, for this you can use the “Copy directory” operation, it needs several parameters, the main of which is the source location, you should be able to delete GetBuildDetail, give it a name and then a .DropLocation link to get this destination, wherever you are.

2.3) Install the new service as step 2.1, you need to use the Invoke Process to install the service, then you can use another to start the service.

I did not cover everything, but I did not ask it myself, so I am sure that there are several pitfalls or things that I did not have. From the top of my head it makes sense, but maybe someone who knows better can push a few holes in it :)

+3
source

All Articles