public BuildDefinitionInfo(TeamCollectionInfo teamCollectionInfo, IBuildDefinition buildDefinition) { this.BuildDefinition = buildDefinition; this.TeamCollection = teamCollectionInfo; this.ReferencedAssemblies = new HashSet<string>(); this.Solutions = new List<SolutionInfo>(); }
public void Init() { var teamCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://logpmtfs01v:8080/tfs/Logitravel")); var buildServer = teamCollection.GetService<IBuildServer>(); var commonStructureService = teamCollection.GetService<Microsoft.TeamFoundation.Server.ICommonStructureService>(); var buildDefinitionResults = Helpers.QueryBuildDefinitions(commonStructureService, buildServer, buildName: ""); var buildDefinition = buildDefinitionResults.FirstOrDefault().Definitions.FirstOrDefault(bd => bd != null && bd.QueueStatus == DefinitionQueueStatus.Enabled); Graph = new DependencyGraph<ProjectInfo>(); var ti = new TeamCollectionInfo(teamCollection); var bi = new BuildDefinitionInfo(ti, buildDefinition); var si = new SolutionInfo(bi, "S1"); var pA = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "A", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pB = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "B", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pC = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "C", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pD = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "D", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pE = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "E", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pF = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "F", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pG = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "G", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; var pH = new ProjectInfo(si) { ProjectGuid = Guid.Empty, GeneratedAssembly = "H", ReferencedProjects = new System.Collections.Generic.HashSet<Guid>() }; Graph.Nodes.Add(pA); Graph.Nodes.Add(pB); Graph.Nodes.Add(pC); Graph.Nodes.Add(pD); Graph.Nodes.Add(pE); Graph.Nodes.Add(pF); Graph.Nodes.Add(pG); Graph.Nodes.Add(pH); Graph.AddDependency(pA, pC); Graph.AddDependency(pA, pF); Graph.AddDependency(pA, pD); Graph.AddDependency(pD, pF); Graph.AddDependency(pD, pG); Graph.AddDependency(pB, pD); Graph.AddDependency(pB, pG); Graph.AddDependency(pE, pG); Graph.AddDependency(pG, pF); Graph.AddDependency(pG, pH); }
public AssembliesInfo Process(IEnumerable<string> teamCollections) { var assembliesInfo = new AssembliesInfo(); // Process each collection, build definition, solution, project and assembly foreach (var teamCollection in teamCollections) { var tfsTeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(teamCollection)); Console.WriteLine($"Collection '{tfsTeamProjectCollection.DisplayName}'"); var teamCollectionInfo = new TeamCollectionInfo(tfsTeamProjectCollection); var buildDefinitions = SearchBuildDefinitions(tfsTeamProjectCollection, BuildNameFilter); if (FilterTeamProjects.Any()) buildDefinitions = buildDefinitions.Where(x => FilterTeamProjects.Contains(x.TeamProject)); foreach (var buildDefinition in buildDefinitions.Where(x => !ExcludeBuildDefinitions.Contains(x.Name))) { var buildDefinitionAssembliesInfo = ProcessBuildDefinition(teamCollectionInfo, buildDefinition); teamCollectionInfo.BuildDefinitions.Add(buildDefinitionAssembliesInfo); } Console.WriteLine(); assembliesInfo.TeamCollections.Add(teamCollectionInfo); } return assembliesInfo; }
private BuildDefinitionInfo ProcessBuildDefinition(TeamCollectionInfo teamCollectionInfo, IBuildDefinition buildDefinition) { if (Verbose) Console.WriteLine($"Build definition: '{buildDefinition.Name}'"); var buildDefinitionInfo = new BuildDefinitionInfo(teamCollectionInfo, buildDefinition); try { var paramValues = WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters); //if (!paramValues.ContainsKey(SharedAssembliesParamName)) continue; //var sharedAssemblies = (string)paramValues[SharedAssembliesParamName]; if (!paramValues.ContainsKey(Constants.ProjectsToBuildParamName)) Console.WriteLine("Build definition '{0}' does not compile any project.", buildDefinition.Name); else { var solutionFiles = (string[])paramValues[Constants.ProjectsToBuildParamName]; foreach (var solutionFile in solutionFiles.Where(x => x.EndsWith(".sln"))) { var assembliesInfo = ProcessSolution(buildDefinitionInfo, solutionFile); buildDefinitionInfo.Solutions.Add(assembliesInfo); buildDefinitionInfo.ReferencedAssemblies.UnionWith(assembliesInfo.ReferencedAssemblies); } } } catch (Exception ex) { Console.WriteLine("Could not process build definition '{0}'. {1}", buildDefinition.Name, ex.Message); } if (Verbose) Console.WriteLine(); return buildDefinitionInfo; }