parent
efdb625c03
commit
555f10b5f9
|
|
@ -239,7 +239,6 @@
|
||||||
Artifacts="@(ArtifactInfo);@(ShippedArtifactInfo)"
|
Artifacts="@(ArtifactInfo);@(ShippedArtifactInfo)"
|
||||||
Repositories="@(Repository);@(ShippedRepository)"
|
Repositories="@(Repository);@(ShippedRepository)"
|
||||||
Dependencies="@(ExternalDependency)"
|
Dependencies="@(ExternalDependency)"
|
||||||
StartGraphAt="$(BuildGraphOf)"
|
|
||||||
Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber);DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)">
|
Properties="Configuration=$(Configuration);BuildNumber=$(BuildNumber);DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath);DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath)">
|
||||||
<Output TaskParameter="RepositoryBuildOrder" ItemName="RepositoryBuildOrder" />
|
<Output TaskParameter="RepositoryBuildOrder" ItemName="RepositoryBuildOrder" />
|
||||||
</RepoTasks.AnalyzeBuildGraph>
|
</RepoTasks.AnalyzeBuildGraph>
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,6 @@ namespace RepoTasks
|
||||||
[Required]
|
[Required]
|
||||||
public string Properties { get; set; }
|
public string Properties { get; set; }
|
||||||
|
|
||||||
public string StartGraphAt { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The order in which to build repositories
|
/// The order in which to build repositories
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -270,14 +268,13 @@ namespace RepoTasks
|
||||||
return repo;
|
return repo;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var graph = GraphBuilder.Generate(repositories, StartGraphAt, Log);
|
var graph = GraphBuilder.Generate(repositories, Log);
|
||||||
var repositoriesWithOrder = new List<(ITaskItem repository, int order)>();
|
var repositoriesWithOrder = new List<(ITaskItem repository, int order)>();
|
||||||
foreach (var repository in repositories)
|
foreach (var repository in repositories)
|
||||||
{
|
{
|
||||||
var graphNodeRepository = graph.FirstOrDefault(g => g.Repository.Name == repository.Name);
|
var graphNodeRepository = graph.FirstOrDefault(g => g.Repository.Name == repository.Name);
|
||||||
if (graphNodeRepository == null)
|
if (graphNodeRepository == null)
|
||||||
{
|
{
|
||||||
// StartGraphAt was specified so the graph is incomplete.
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace RepoTools.BuildGraph
|
||||||
{
|
{
|
||||||
public static class GraphBuilder
|
public static class GraphBuilder
|
||||||
{
|
{
|
||||||
public static IList<GraphNode> Generate(IList<Repository> repositories, string root, TaskLoggingHelper log)
|
public static IList<GraphNode> Generate(IList<Repository> repositories, TaskLoggingHelper log)
|
||||||
{
|
{
|
||||||
// Build global list of primary projects
|
// Build global list of primary projects
|
||||||
var primaryProjects = repositories.SelectMany(c => c.Projects)
|
var primaryProjects = repositories.SelectMany(c => c.Projects)
|
||||||
|
|
@ -19,15 +19,9 @@ namespace RepoTools.BuildGraph
|
||||||
var graphNodes = repositories.Select(r => new GraphNode { Repository = r })
|
var graphNodes = repositories.Select(r => new GraphNode { Repository = r })
|
||||||
.ToDictionary(r => r.Repository);
|
.ToDictionary(r => r.Repository);
|
||||||
|
|
||||||
GraphNode searchRoot = null;
|
|
||||||
|
|
||||||
foreach (var project in repositories.SelectMany(r => r.AllProjects))
|
foreach (var project in repositories.SelectMany(r => r.AllProjects))
|
||||||
{
|
{
|
||||||
var thisProjectRepositoryNode = graphNodes[project.Repository];
|
var thisProjectRepositoryNode = graphNodes[project.Repository];
|
||||||
if (!string.IsNullOrEmpty(root) && string.Equals(root, project.Repository.Name, StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
searchRoot = thisProjectRepositoryNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var packageDependency in project.PackageReferences)
|
foreach (var packageDependency in project.PackageReferences)
|
||||||
{
|
{
|
||||||
|
|
@ -50,25 +44,7 @@ namespace RepoTools.BuildGraph
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = new HashSet<GraphNode>();
|
|
||||||
if (searchRoot != null)
|
|
||||||
{
|
|
||||||
Visit(results, searchRoot);
|
|
||||||
return results.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
return graphNodes.Values.ToList();
|
return graphNodes.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Visit(HashSet<GraphNode> results, GraphNode searchRoot)
|
|
||||||
{
|
|
||||||
if (results.Add(searchRoot))
|
|
||||||
{
|
|
||||||
foreach (var node in searchRoot.Outgoing)
|
|
||||||
{
|
|
||||||
Visit(results, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue