Supporting ClickOnce Deployments using Team Build

A few weeks ago I was doing some work with a client in Sydney helping migrate their existing code base across to Team Foundation Server. One of the developers who also happens to play the build master/release manager role asked me if there was a better way of deploying their software.

Their current approach was copying the files onto a network share and adjusting the security policy of the user workstations to allow that code to execute with full trust. One of the problems that they were running into was that in order to update the program they had to rename all the files before deploying because they were locked by users who were currently using the software.

This was a fairly common approach back in the .NET 1.0/1.1 days, and if you wanted to get around it you had to build some kind of boot strapper that would set up an application domain and shadow copy the files, similar to the way that ASP.NET does to avoid file locking.

Fortunately, in a .NET 2.0+ world Microsoft has made our lives a little bit easier with the introduction of ClickOnce, although not everyone knows of its existence. I told the client about ClickOnce and they went off and did some experimentation.

The following week I visited the client again and I got the obvious question – how do we get ClickOnce working with Team Build?

The good news is that it isn’t that hard as Team Build has built-in support for working with ClickOnce enabled projects. The steps that you need to follow are:

  1. Enable ClickOnce in your application (you can do this via the properties window, or by doing step two below).
  2. Do one ClickOnce deployment manually to make sure all the appropriate configuration entries are written to the project file.
  3. Edit the TFSBuild.proj file and copy the “SolutionToBuild” line, and put it below, and rename it to “SolutionToPublish”. The screen show below provides an example. 

Sample from the configuration file.

Team Build will then build the code and place a versioned ClickOnce directory in the drop folder that you can then copy over to your deployment location. If you are feeling adventurous you could even use TFS Deployer to automate this step.


4 thoughts on “Supporting ClickOnce Deployments using Team Build

  1. Pingback: Team System News : VSTS Links - 08/31/2007

  2. Neil

    I think I’m missing something. This doesn’t seem to really solve the problem of building ClickOnce deployments for mulitple servers (i.e. dev, beta, production). How would you change the necessary paramaters in the build to do that?

  3. Mitch Denny Post author

    Hi Neil,

    No – its not designed to address that, its just the help get the basic click once deployment configuration into the drop folder. You could use something like TFS Deployer to tweak the configuration files as it pushes them to the staging location.

  4. Smruti Ranjan

    i am working on click once application with out connecting to tfs.. but when i connected to tfs, the application is not showing error in my pc, but when developers are connecting the application it is showing error in all pages…

    so, please give me a solution how can i connect to tfs with out error in my application.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s