是否有一个.NET API等同于TFS 2015的"Build 2.0"REST API?

dee*_*see 11 .net c# tfs team-build tfs-2015

VS Team Services和TFS页面的REST API参考分离了"Build 1.0"和"Build 2.0"API.

似乎.NET API中也存在这样的差异,因为运行以下代码只列出"旧"XAML构建定义而不是新定义.

var tpc = new TfsTeamProjectCollection(new Uri("http://tfsurl"));
var buildServer = tpc.GetService<IBuildServer>();
var def = buildServer.QueryBuildDefinitions("Project Name"); // Finds only XAML definitions
Run Code Online (Sandbox Code Playgroud)

是否有一个新的DLL我可以参考编写与新TFS一起使用的等效代码,或者是所有的Web API?

jes*_*ing 10

您正在寻找:

 Microsoft.TeamFoundation.Build.WebApi.BuildDefinition
Run Code Online (Sandbox Code Playgroud)

在:

 Microsoft.TeamFoundation.Build2.WebApi, Version=14.0.0.0
Run Code Online (Sandbox Code Playgroud)

可通过以下方式访问:

 Microsoft.TeamFoundation.Build.WebApi.BuildHttpClient
Run Code Online (Sandbox Code Playgroud)

将它添加到项目中的最简单方法是使用Nuget包:

PM> Install-Package Microsoft.TeamFoundationServer.ExtendedClient
Run Code Online (Sandbox Code Playgroud)

  • 添加它的最佳方式是通过新的nuget包.Microsoft.TeamFoundation.ExtendedClient (2认同)