views:

74

answers:

1

Hi,

Our existing batch build script contains an URL to get the latest product-build (of another build definition) from.

How can one access the lattest build drop folder of TFS Team Build?

I'm looking for something to access the latest \buildserver\builddrop\Project-2010MMDD.N\

A: 

Using the API, you can get the drop location from the build. The code below gets the most recent build for a given project, and returns the dropfolder.

    public string DropFolder(TeamFoundationServer tfs, string teamProject, string buildName)
    {
        IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));

        IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProject, buildName);

        buildDetailSpec.MaxBuildsPerDefinition = 1;
        buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending;
        buildDetailSpec.Status = BuildStatus.Failed | BuildStatus.PartiallySucceeded | BuildStatus.Stopped | BuildStatus.Succeeded;

        IBuildQueryResult results = buildServer.QueryBuilds(buildDetailSpec);

        if (results.Failures.Length != 0)
        {
            throw new ApplicationException("this needs to go away and be handled more nicely");
        }

        if (results.Builds.Length == 1)
        {
            results.Builds[0].DropLocation;
        }
        else
        {
            return null;
        }

    }
Robaticus
Also, if writing a small utility app to do this isn't in the cards, the same API is exposed to PowerShell.
Robaticus