Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:03:35+00:00 2026-06-01T08:03:35+00:00

I have a number of build definitions that get executed based upon a single

  • 0

I have a number of build definitions that get executed based upon a single branch in TFS (eg Main).

I’d like to (somehow) query TFS to find all builds containing a specific changeset number that I supply, and return a list of string of the names of the builds that TFS contains. Any kind of app (VS extension, CLI app, winforms, whatever) will do.

Note: this isn’t a ‘plz give me the code’ request; I’m willing to hoof it and do serious work on this. Any pointers to documentation on how to query the database or SDK, or an example of how to query builds; just some place to start looking would be extremely helpful. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:03:36+00:00Added an answer on June 1, 2026 at 8:03 am

    The following snippet will crawl all Build Definitions of all Team Project of a Collection, and will check each and every build for an Association to the input changeset number:

    using System;
    using System.Linq;
    using Microsoft.TeamFoundation.Build.Client;
    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.VersionControl.Client;
    
    namespace FindChangesetInBuild
    {
        class Program
        {
            static void Main(string[] args)
            {
                TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs:8080/tfs/collectionName"));
    
                var versionControl = teamProjectCollection.GetService<VersionControlServer>();
                var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));
    
                var teamProjects = versionControl.GetAllTeamProjects(true);
                foreach (var teamProject in teamProjects)
                {
                    var buildDefinitions = buildService.QueryBuildDefinitions(teamProject.Name);
                    foreach (var buildDefinition in buildDefinitions)
                    {
                        var builds = buildService.QueryBuilds(buildDefinition);
                        foreach (var buildDetail in builds)
                        {
                            var changesets = InformationNodeConverters.GetAssociatedChangesets(buildDetail);
                            if (changesets.Any(changesetSummary => changesetSummary.ChangesetId == Convert.ToInt32(args[0])))
                            {
                                Console.WriteLine("Changeset was build in "+buildDetail.BuildNumber);
                            }
                        }
                    }
                }
            }
        }
    }
    

    Needless to say, this is a brute force attack.
    You can further refine the code if you narrow down the list of buildDefinition, make focus on specific teamProjects etc. In any case I can hardly imagine the above to be useful as-is!

    Apart from (obviously) MSDN, a great resource for TFS-SDK is Shai Raiten’s blog.
    For Build-Speficic examples, check also here & here for some possibly interesting SO posts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script that basically should work like below: get build number
Using TFS 2010. I have created a number of new Build Definitions. I also
I have a build process that does the following: Runs TLBIMP on a number
Can I reset build number in TFS 2010. And another question. If Project have
I have a header file that has a number of declarations like this: extern
I have a number of scripts used to build a database. These need to
I have a CruiseControl build server running a large number of projects. On one
I have a multi-project C++ Gradle build, which produces a number of libraries and
We have a number of AS/Flex components that we've built over time and improved
Does Actionscript have a built-in function that accepts a number and can return a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.