Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tfs 通过API获取有关Web样式构建的信息_Tfs_Tfs 2015 - Fatal编程技术网

Tfs 通过API获取有关Web样式构建的信息

Tfs 通过API获取有关Web样式构建的信息,tfs,tfs-2015,Tfs,Tfs 2015,我们正在转向基于TFS 2015的web样式构建(更新4) 我始终能够使用下面的代码检索有关构建的信息,但这并不是检索通过web界面创建的新构建 是否有一种合理的方法来修改我的代码,以引入旧版本和新样式的版本 如果不是的话,我想现在是时候弄清楚如何使用RESTAPI了。如果您有任何关于类似问题的建议,我们将不胜感激 TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://SERVERINFO"));

我们正在转向基于TFS 2015的web样式构建(更新4)

我始终能够使用下面的代码检索有关构建的信息,但这并不是检索通过web界面创建的新构建

是否有一种合理的方法来修改我的代码,以引入旧版本和新样式的版本

如果不是的话,我想现在是时候弄清楚如何使用RESTAPI了。如果您有任何关于类似问题的建议,我们将不胜感激

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri("http://SERVERINFO"));
IBuildServer buildServer = (IBuildServer) tfs.GetService(typeof (IBuildServer));

var buildDetail = buildServer.CreateBuildDetailSpec("*");
buildDetail.MinFinishTime = DateTime.Now.Date.AddDays(-1);
buildDetail.InformationTypes = null;
buildDetail.QueryDeletedOption = QueryDeletedOption.IncludeDeleted;
buildDetail.MaxBuildsPerDefinition = 1; //Only return the most recent of each build type...or comment out to return all builds with this definition

var builds = buildServer.QueryBuilds(buildDetail).Builds.Select(....

旧的XAML构建系统使用SOAP API。基于任务的新vNet构建系统没有SOAP API。它正在使用RESTAPI。恐怕你不能仅仅修改代码来获得新的版本。它们不支持构建vNext,因为它们是在使用之前编写的

此外,SOAP API正在慢慢地被REST API取代,特别是在一些新特性中。强烈建议您使用RESTAPI

您可以通过查询或使用从C代码访问它。样本:

使用系统;
使用System.Collections.Generic;
使用Microsoft.TeamFoundation.Client;
使用Microsoft.TeamFoundation.Build.WebApi;
命名空间控制台应用程序1
{
班级计划
{
静态void Main(字符串[]参数)
{
Uri tfsurl=新Uri(“http://xxxx:8080/tfs/CollectionName");
TfsTeamProjectCollection ttpc=新的TfsTeamProjectCollection(tfsurl);
BuildHttpClient bhc=ttpc.GetClient();
列表构建=bhc.GetBuildsAsync(“ProjectName”).Result;
foreach(内部构建bu)
{
控制台写入线(bu.BuildNumber);
}
Console.ReadLine();
}
}
}
通过在上述库中使用RESTAPI,您可以同时获得XAML和vNext构建

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri tfsurl = new Uri("http://xxxx:8080/tfs/CollectionName");
            TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(tfsurl);
            BuildHttpClient bhc = ttpc.GetClient<BuildHttpClient>();
            List<Build> builds = bhc.GetBuildsAsync("ProjectName").Result;
            foreach (Build bu in builds)
            {
                Console.WriteLine(bu.BuildNumber);
            }
            Console.ReadLine();
        }
    }
}