The following snippet scans all assembly definitions for all Team Project Collection and checks each assembly for association for the number of input change set:
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 refine the code by narrowing the list of buildDefinition
, focus on specific teamProjects
, etc. In any case, I can hardly imagine the above to be useful as it is!
Besides (obviously) MSDN , a great resource for the TFS-SDK is the Shai Raiten blog . For Build-Speficic examples, also check here and here for some possibly interesting SO posts.
source share