Search code examples
c#c#-4.0tfstfsbuildtfs-2015

TFS can't find BuildDefinition


I am working on a solution where I want to get parameters from a Builddefinition per Code. When I hit it, I get an error message "No build definition was found for team project ToyStory with name Spass-mit-Flaggen."

Failed Build

The used code is written below:

var tfsCreds = new TfsClientCredentials(new WindowsCredential(), false);
var tpc      = new TfsTeamProjectCollection(new Uri(options.CollectionUri), tfsCreds);

var buildServer     = (IBuildServer)tpc.GetService(typeof(IBuildServer));
var buildDetail     = buildServer.GetBuild(new Uri(options.BuildUri));
var buildDefinition = buildServer.GetBuildDefinition(
                        buildDetail.TeamProject,
                        options.BuildDefinition);

The options object contains all program parameters. In this case they are the following strings:

options.CollectionUri  == "http://tfs-test:8080/tfs/Test/"
options.BuildUri       == "vstfs:///Build/Build/85"
options.BuildDefiniton == "Spass-mit-Flaggen"

Has someone an idea what's going wrong here?

Thanks in advance


Solution

  • You're using the old SOAP API for accessing builds. The new build system introduced in TFS 2015 doesn't use SOAP messaging, it has a totally separate REST API. You'll need to use the REST API, available in easily-consumable object model form on NuGet.