Question

I've been googling and can't find any solid examples how this is done, or if it even can be done. I assume it can. Can anyone point me in the right direction?

So far I've been looking under the TFS namespace documentation on msdn. My goal is to be able to fully automate and track our builds in TFS from an intranet web application.

Was it helpful?

Solution

Richard pointed me in the right direction, so I'm going to answer my own question with what I've found.

Yes, you can use the TFS SDK to create, queue, and track builds. The interfaces/classes you want are located in the Microsoft.TeamFoundation.Build.Client namespace. IBuildServer, IBuildDefinition, and IBuildDetail are particularly useful.

TFS 2010 UPDATE: Here is an example program using the TFS 2010 SDK, found here:

using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow;
using Microsoft.TeamFoundation.Client;

namespace ManageBuildTemplates
{
    class Program
    {
        static void Main(string[] args)
        {
            TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://jpricket-test:8080/tfs/collection0"));
            IBuildServer buildServer = collection.GetService<IBuildServer>();

            IBuildDefinition definition = buildServer.GetBuildDefinition("UnitTests", "Definition1");

            IBuildRequest request = definition.CreateBuildRequest();
            request.ProcessParameters = UpdateVerbosity(request.ProcessParameters, BuildVerbosity.Diagnostic);

            buildServer.QueueBuild(request);
        }

        private static string UpdateVerbosity(string processParameters, BuildVerbosity buildVerbosity)
        {
            IDictionary<String, Object> paramValues = WorkflowHelpers.DeserializeProcessParameters(processParameters);
            paramValues[ProcessParameterMetadata.StandardParameterNames.Verbosity] = buildVerbosity;
            return WorkflowHelpers.SerializeProcessParameters(paramValues);
        }
    }
}

OTHER TIPS

Look at tfsbuild.exe (in the .../Common9/IDE folder of the VS install).

This references assemblies Microsoft.TeamFoundation.Build.Client and Microsoft.TeamFoundation.Build.Common which look helpful, ... and contain namespaces which are not documented with the other TFS cient assembliies, but are on MSDN here http://msdn.microsoft.com/en-us/library/cc339575.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top