I\'m having a problem retrieving build information from a Visual Studio Online project through the TFS API. I can connect to the project, it seems, and find the expected tea
You can utilize the BuildHttpClient to make similar requests as you would with the 2.0 REST API.
This sample on GitHub is a pretty good resource, if you would rather poll a single project it should look something more like this:
using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Build.WebApi;
using Microsoft.VisualStudio.Services.Client;
static void GetBuildStatus()
{
var tfsUrl = "http://<tfs url>:<port>/tfs/<collectionname>";
var buildClient = new BuildHttpClient(new Uri(tfsUrl), new VssAadCredential());
var definitions = buildClient.GetDefinitionsAsync(project: "<projectmame>");
var builds = buildClient.GetBuildsAsync("<projectname>";
foreach (var build in builds.Result)
{
Console.WriteLine(String.Format("{0} - {1} - {2} - {3}", build.Definition.Name, build.Id.ToString(), build.Status.ToString(), build.StartTime.ToString()));
}
}
I believe you are right I have just tested your code against my own VSO on a GIT project and I cannot retrieve any build.vNext builds, however I can retrieve old XAML build definitions.
I then tried using the REST API and it too could only return the old style XAML builds until I got it to use version 2 of the REST API and then the XAML and build.vNext style builds came back. Here is an example string I tried in my browser (make sure you are logged into VSO first to test it)
https://[vsoname].visualstudio.com/defaultcollection/[project]/_apis/build/definitions?api-version=2.0