Jul 25, 2007

Using TFS Source Control with CruiseControl.NET

Microsoft finally delivered a decent source control with the release of Team Foundation Server giving the thousands of development teams still using SourceSafe a way to move forward.

But what do you do it you've got CruiseControl.NET running against a VSS repository. Thankfully there is a way to hook CruiseControl.NET into a TFS source repository and it's fairly straightforward as well.

Instead of using the VSS source control block in your ccnet.config file, simply change to the VSTS source control block.

Here's what you'll need to do

1. Download the TFS Plugin for CCNet from CodePlex

2. Change your source control block in ccnet.config to look something like the following:

    <sourcecontrol type="vsts" autoGetSource="true" applyLabel="false">
<
server>http://TFSServer:8080</server>
<
project>$/MyProject/</project>
<
workingDirectory>c:\Projects\</workingDirectory>
<
cleanCopy>false</cleanCopy>
<
workspace>CCNET_MyProject</workspace>
</sourcecontrol>

3. Save ccnet.config and you're done :-)

So, what actually happens here?.


  • Firstly, we use the <server /> tag to define the location of the TFS server where we will get our source from.

  • Next we define which location in source control the code will be retrieved from using the <project /> tag. We also define where we will place the source on the build server using the <workingDirectory /> tag. Even though the CC.NET web site indicates that the workingDirectory tag is optional, I've found that it won't work without it.

  • We also define the workspace name to use when retrieving the source. If this isn't specified the server uses the name CCNET, however if you have multiple projects on your build server you will get name conflicts. It's better to specify a workspace name to avoid headaches.

  • Finally, the <cleanCopy /> tag is used to tell CCNet to only update files. If you want to re-get everything from source control each time, then you need to change this value to true.

The eagle-eyed among you may also note that we haven't specified the account to connect to TFS with. By default this will be the account that the CC.Net server runs under. If this is not the account you wish to connect to TFS with you can specify the user account (and password) to use, but having a user account and password in clear text in a config file is not a great security practice.


For more information have a look at the reference information.

A tip for first time players:


One of the things people do when setting up their server for the first time or when changing ccnet.config files is to run ccnet manually and then, after it's all working, start it as a service. In some situatuions you may find that after starting the service you have a workspace conflict error when trying to get source code from TFS. This can happen when the account you run the manual service under is different than the ccnet service account. If it does happen all you should need to do is delete the workspaces you created using Team Explorer. The VSTS plug in will recreate the workspaces the next time it queries the repository.

1 comment:

  1. Update for you Richard, CC.Net 1.5 has a TFS plugin built in :)

    ReplyDelete