I have written below code to queue a build via api. team project collection, workitem store and version control server works fine, but i am not getting buildserver object. its always returning null. am i missing any other configuration
using (TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsserver:8080/tfs/DefaultCollection")))
{
tpc.EnsureAuthenticated();
// i am getting workitemstore object here
var wiStore = tpc.GetService<WorkItemStore>();
....
....
// i am getting version control server object here as well
var vcs = tpc.GetService<VersionControlServer>();
....
....
// but here i get a null object
var bs = tpc.GetService<IBuildServer>();
//this is what i want to do with buildserver object
var buildDefinition = bs.GetBuildDefinition("aaa", "bbb");
var buildRequest = buildDefinition.CreateBuildRequest();
bs.QueueBuild(buildRequest);
}
any idea?
This can happen if you reference the wrong version of Microsoft.TeamFoundation.Build.Client for the TFS that you're trying to connect to. Check that you're referencing the correct version for TFS2010 (10.0.0.0 I believe).
http://pmichaels.net/2015/03/20/unable-to-get-ibuildserver-always-returning-null/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With