Monthly Archives: September 2010

Using the TFS source control provider in CCNET v1.5 with 2010

Recently I helped a client of Falafel’s get up and running with Continuous Integration using CCNET v1.5. They’re running Team Foundation Server 2010 using TFS for their source repository and fortunately CruiseControl.NET includes a source control provider for TFS. Having tried this configuration and successfully we configured the server but ran into the following error:
Source control failure (GetModifications): Unable to find TF.exe and it was not defined in Executable Parameter
TFSError
Reviewing the code for the TFS plugin we can see why this happens for 2010:

private string ReadTFFromRegistry()
{
    string registryValue = null;
    registryValue = registry.GetLocalMachineSubKeyValue(VS2008_64_REGISTRY_PATH, VS_REGISTRY_KEY);
    if (registryValue == null)
    {
        registryValue = registry.GetLocalMachineSubKeyValue(VS2005_64_REGISTRY_PATH, VS_REGISTRY_KEY);
    }
    if (registryValue == null)
    {
        registryValue = registry.GetLocalMachineSubKeyValue(VS2008_32_REGISTRY_PATH, VS_REGISTRY_KEY);
    }
    if (registryValue == null)
    {
        registryValue = registry.GetLocalMachineSubKeyValue(VS2005_32_REGISTRY_PATH, VS_REGISTRY_KEY);
    }
    if (registryValue == null)
    {
        Log.Debug("Unable to find TF.exe and it was not defined in Executable Parameter");
        throw new Exception("Unable to find TF.exe and it was not defined in Executable Parameter");
    }
    return Path.Combine(registryValue, TF_EXE);
}

As of this writing the CCNET documentation does not include the Executable parameter for this source control provider though the fix is easy enough.

Building a TFS project using CruiseControl.NET v1.5

While setting up a continuous integration (CI) build in CruiseControl.NET on a project checked into Team Foundation Server (TFS) I had to make several “adjustments” to get the build working properly. This post documents the errors and what I did to get a successful build.

First, in VS.NET 2010 I created a simple WPF test project and checked it into TFS. Next, updated my CCNET server to v1.5 (v1.5.72256.1 to be exact) and edited the ccnet.config file to point to my project which looks like:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
    <project name="WPFTest">
        <sourcecontrol type="vsts" autoGetSource="true" applyLabel="true">
          <server>http://myserver-tfs:8080/</server>
          <username>_username</username>
          <password>_password</password>
          <domain>DREAMTEAM</domain>
          <project>$/CI WPF Test</project>
          <workingDirectory>c:\projects\Foobar</workingDirectory>
          <cleanCopy>false</cleanCopy>
        </sourcecontrol>
        <tasks>
            <msbuild>
              <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
              <workingDirectory>C:\projects\foobar\WpfApplication2</workingDirectory>
              <projectFile>WpfApplication2.sln</projectFile>
              <buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
              <targets>Build</targets>
              <timeout>900</timeout>
              <logger>C:\Sandbox\ccnet\deployed\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
            </msbuild>
        </tasks>
        <publishers>
          <xmllogger />
          <statistics />
          <modificationHistory  onlyLogWhenChangesFound="true" />
        </publishers>
    </project>
</cruisecontrol>

At that point I fired up the CCNet server from the command line and hit the Web Dashboard to force a build of the project which resulted in the error “Team Foundation Server myserver-tfs does not exist or is not accessible at this time.
Technical information (for administrator)
The request failed with HTTP status 404: Not found”

CCNET Console

The problem was the <server> tag from the ccnet.config file was missing part of the URL which should have included “/tfs” on the end. My bad.

After correcting the server URL I ran into the next error “TFS30063: You are not authorized to access http://myserver-tfs:8080/tfs.” A bit of research and I found this issue in the CCENT Jira bug database regarding a bug (and patch) for an issue in CCNET’s VS TFS source control plugin. My search also lead me to a post titled CCNET 1.5 and TFS 2010 Integration that mentions the same problem with a workaround which is to run the CCNET server under the account that has access to the TFS server.

TFS Not authorized

I fired up a new console window using my TFS account credentials with the runas.exe command as follows:

C:\Windows\System32\runas.exe /netonly /user:MYDOMAIN\STrefethen cmd.exe

I then updated my ccnet.config file removing the <username> and <password> settings from the <sourcecontrol> block. After forcing yet another build the next problem I encountered read:

“Team Foundation Server http://myserver-tfs:8080/tfs does not exist or is not accessible at this time. Technical Information (for administrator):

Team Foundation services are not available from the server.

Technical Information (for administrator):

TF253022: You must update your client with the Forward Compatibility Update in order to connect to the Team Foundation Server that you selected. To obtain this update, go to the Microsoft Web site: http://go.microsoft.com/fwlink/?LinkID=166481

Here are more explicit details of that update:

Visual Studio Team System 2008 Service Pack 1 Forward Compatibility Update for Team Foundation Server 2010 (Installer)

http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=cf13ea45-d17b-4edc-8e6c-6c5b208ec54d

After downloading and installing the update then forcing yet another build all is now working:

CCNET Web Dashboard

Hope this helps you in the event you’ve run into similar problems.