我正在尝试从MS Build中获取Build Warning,(在Build中包含或包含许多解决方案)
是否可以使用TERY API或任何使用QUERY的TFS DB进行提取?
答案 0 :(得分:1)
您可以使用TFS版本的此TFS REST API to get logs。要获取这些日志,您需要自己获取这些警告。没有API只能获得警告。
Http method: GET
http:/servername"8080/tfs/DefaultCollection/teamproject/_apis/build/builds/391/logs?api-version=2.0
您还可以安装TFS ExtendedClient Nuget package以使用TFS对象模型API。
以下是代码段:
与上述评论一样,使用旧版API无法达到VNext构建定义信息。使用以下方法为您的项目安装此TFS ExtendedClient Nuget包,以获取所有构建定义。
using Microsoft.VisualStudio.Services.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Operations;
private static void GetBuildWarnings()
{
var u = new Uri("http://v-tinmo-12r2:8080/tfs/MyCollection/");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.WindowsCredential(new NetworkCredential("username", "password", "domain")));
var connection = new VssConnection(u, c);
BuildHttpClient buildServer = connection.GetClient<BuildHttpClient>();
List<BuildLog> logs = buildServer.GetBuildLogsAsync("teamprojectname",buildId).Result;
foreach (BuildLog log in logs)
{
var list = buildServer.GetBuildLogLinesAsync("A92FB795-A956-45B5-A017-7A7DFB96A040",buildId,log.Id).Result; //A92FB795-A956-45B5-A017-7A7DFB96A040 is the team project Guid
foreach (var line in list)
{
if (l.Contains("[Warning]"))
{
Console.WriteLine(line);
}
}
}
Console.ReadLine();
}