我们现有的批处理构建脚本包含一个URL,用于从中获取最新的产品构建(具有另一个构建定义)。

如何访问TFS Team Build的lattest build drop文件夹?

我正在寻找访问最新的\buildserver\builddrop\Project-2010MMDD.N\的内容

最佳答案

使用API​​,您可以从构建中获取放置位置。下面的代码获取给定项目的最新版本,并返回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;
    }
}

10-08 15:41