title: TFS Get all build definitions
body: <p>Good afternoon, I was scrolling here, reading questions and trying different code on how to get builds and all the definitions from them, however, whenever I try to execute code and get builds definitions it returns nothing, even though I for sure know there are both successful and unsuccessful builds in there. However I get nothing.</p>
  
  <pre><code>private static void Main(string[] args)
      {
          NetworkCredential credential = new NetworkCredential("MyUsername", "MyPassword");
          VssBasicCredential basicCred = new VssBasicCredential(credential);
  
          TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://tomheza.visualstudio.com/DefaultCollection"), basicCred);
  
          tpc.Authenticate();
  
          CatalogNode catalogNode = tpc.CatalogNode;
          ReadOnlyCollection&lt;CatalogNode&gt; collectionNodes = tpc.CatalogNode.QueryChildren(new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None);
  
          foreach (CatalogNode collectionNode in collectionNodes)
          {
              Console.WriteLine(collectionNode.Resource.DisplayName);
          }
  
          var buildServer = (IBuildServer)tpc.GetService(typeof(IBuildServer));
          var vcs = tpc.GetService&lt;VersionControlServer&gt;();
          var teamProjects = vcs.GetAllTeamProjects(true);
  
          foreach (TeamProject proj in teamProjects)
          {
              var defs = buildServer.QueryBuildDefinitions(proj.Name);
  
              Console.WriteLine(string.Format("Team Project: {0}", proj.Name));
  
              foreach (IBuildDefinition def in defs)
              {
                  IBuildDetailSpec spec = buildServer.CreateBuildDetailSpec(proj.Name, def.Name);
                  spec.MaxBuildsPerDefinition = 1;
                  spec.QueryOrder = BuildQueryOrder.FinishTimeDescending;
  
                  var builds = buildServer.QueryBuilds(spec);
  
                  if (builds.Builds.Length &gt; 0)
                  {
                      var buildDetail = builds.Builds[0];
  
                      Console.WriteLine(string.Format("   {0} - {1} - {2}", def.Name, buildDetail.Status.ToString(), buildDetail.FinishTime));
                  }
              }
  
              Console.WriteLine();
          }
      }
  </code></pre>
  
  <p>I am using VS2017 community version</p>