diff --git a/ConsoleTest/ConsoleTest.sln b/ConsoleTest/ConsoleTest.sln
new file mode 100644
index 0000000..8ec1301
--- /dev/null
+++ b/ConsoleTest/ConsoleTest.sln
@@ -0,0 +1,76 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26124.0
+MinimumVisualStudioVersion = 15.0.26124.0
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GraphBuilder", "..\GraphBuilder\src\GraphBuilder.csproj", "{6A28B56B-954A-4B13-98F9-EE9F0809550E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageBuilder", "..\PackageBuilder\src\PackageBuilder.csproj", "{D56FBF34-841A-46DE-A451-29072979A058}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageHasher", "..\PackageHasher\src\PackageHasher.csproj", "{7F1CD306-1EE9-4665-8BD1-E9DAAA854107}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "src\ConsoleTest.csproj", "{6990819A-89F7-4C68-8166-698017244944}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|x64.Build.0 = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Debug|x86.Build.0 = Debug|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|x64.ActiveCfg = Release|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|x64.Build.0 = Release|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|x86.ActiveCfg = Release|Any CPU
+ {6A28B56B-954A-4B13-98F9-EE9F0809550E}.Release|x86.Build.0 = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|x64.Build.0 = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Debug|x86.Build.0 = Debug|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|x64.ActiveCfg = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|x64.Build.0 = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|x86.ActiveCfg = Release|Any CPU
+ {D56FBF34-841A-46DE-A451-29072979A058}.Release|x86.Build.0 = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|x64.Build.0 = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Debug|x86.Build.0 = Debug|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|x64.ActiveCfg = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|x64.Build.0 = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|x86.ActiveCfg = Release|Any CPU
+ {7F1CD306-1EE9-4665-8BD1-E9DAAA854107}.Release|x86.Build.0 = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|x64.Build.0 = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Debug|x86.Build.0 = Debug|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|x64.ActiveCfg = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|x64.Build.0 = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|x86.ActiveCfg = Release|Any CPU
+ {6990819A-89F7-4C68-8166-698017244944}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/ConsoleTest/src/ConsoleTest.csproj b/ConsoleTest/src/ConsoleTest.csproj
new file mode 100644
index 0000000..aec4a0b
--- /dev/null
+++ b/ConsoleTest/src/ConsoleTest.csproj
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+ Exe
+ netcoreapp3.0
+
+
+
diff --git a/ConsoleTest/src/Program.cs b/ConsoleTest/src/Program.cs
new file mode 100644
index 0000000..38b93f0
--- /dev/null
+++ b/ConsoleTest/src/Program.cs
@@ -0,0 +1,43 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using PackageAnalyzer;
+
+namespace ConsoleTest
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+
+ string packageroot = "A";
+ string packagedescriptions = @"\pkgs\descriptions";
+ string packagesource = @"\src";
+ string testroot = @"C:\tmp";
+
+ GraphBuilder gb = new GraphBuilder($"{testroot}{packagedescriptions}");
+
+ if (gb.Graph.IsCyclic)
+ {
+ Console.WriteLine("Build graph contains cyclic dependencies.");
+ return;
+ }
+
+ DirectoryInfo di = new DirectoryInfo($"{testroot}{packagesource}");
+ List paths = di.GetDirectories().Select(d => d.FullName).ToList();
+ var task = Task.Run(async () => await PackageHasher.HashFoldersAsync(paths, testroot));
+ Dictionary packageSourceHash = task.Result;
+
+ PackageBuilder pb = new PackageBuilder(testroot);
+ Dictionary buildResults = pb.Build(packageroot, $"{testroot}{packagesource}", packageSourceHash, gb.Graph);
+
+ foreach (string key in buildResults.Keys)
+ {
+ Console.WriteLine($"package {key} build : {buildResults[key]}");
+ }
+
+ }
+ }
+}
diff --git a/GraphBuilder/src/Graph.cs b/GraphBuilder/src/Graph.cs
index 7aa6dac..006712b 100644
--- a/GraphBuilder/src/Graph.cs
+++ b/GraphBuilder/src/Graph.cs
@@ -13,6 +13,16 @@ public Graph()
parentnodes = new Dictionary>();
}
+ public string[] Nodes
+ {
+ get
+ {
+ string[] nodes = new string[directednodes.Keys.Count];
+ directednodes.Keys.CopyTo(nodes, 0);
+ return nodes;
+ }
+ }
+
public List Paths(string V)
{
return directednodes[V];
diff --git a/GraphBuilder/tests/Graph.Tests.cs b/GraphBuilder/tests/Graph.Tests.cs
index fd01ef7..12f42e1 100644
--- a/GraphBuilder/tests/Graph.Tests.cs
+++ b/GraphBuilder/tests/Graph.Tests.cs
@@ -11,6 +11,7 @@ public void SimpleGraphCycleTest1()
GraphBuilder gb = GraphTestUtilities.PopulateGB("simplecycle1");
Assert.IsTrue(gb.Graph.IsCyclic);
+ Assert.AreEqual(2, gb.Graph.Nodes.Length);
}
[TestMethod]
@@ -63,7 +64,9 @@ public void IntermediateGraphCycleTest1()
Assert.AreEqual(1, gb.Graph.Children("D").Count);
Assert.IsTrue(gb.Graph.Children("D").Contains("E"));
- Assert.AreEqual(0, gb.Graph.Children("E").Count);
+ Assert.AreEqual(0, gb.Graph.Children("E").Count);
+
+ Assert.AreEqual(5, gb.Graph.Nodes.Length);
}
}
}
diff --git a/PackageBuilder/src/PackageBuilder.cs b/PackageBuilder/src/PackageBuilder.cs
index ede1fd0..18cabd1 100644
--- a/PackageBuilder/src/PackageBuilder.cs
+++ b/PackageBuilder/src/PackageBuilder.cs
@@ -45,6 +45,12 @@ public Dictionary Build(string startNode, string sourceFolder, Dic
Dictionary packageBuildResults = new Dictionary();
+ // Initialize the results collection
+ foreach (string node in g.Nodes)
+ {
+ packageBuildResults.Add(node,false);
+ }
+
BuildPackages(packages, hash, g, packageBuildResults);
return packageBuildResults;
@@ -84,8 +90,13 @@ private void BuildPackages(List packages, Dictionary has
forceBuild = true;
}
}
+ bool result = BuildPackage(package, hash, forceBuild);
- buildResults.Add(package, BuildPackage(package, hash, forceBuild));
+ if (result)
+ {
+ buildResults[package] = result;
+ }
+
children.AddRange(g.Children(package));
}
@@ -133,6 +144,8 @@ private void Compile(string package, string packageHashName)
string source = $"{_sourceRoot}{package}";
string dest = $"{_outputRoot}{packageHashName}.zip";
+ File.Delete($"{_outputRoot}{packageHashName}.zip");
+
ZipFile.CreateFromDirectory($"{_sourceRoot}{package}", $"{_outputRoot}{packageHashName}.zip");
}
}
diff --git a/PackageBuilder/tests/PackageBuilder.Tests.cs b/PackageBuilder/tests/PackageBuilder.Tests.cs
index 12f2c11..93e2ad2 100644
--- a/PackageBuilder/tests/PackageBuilder.Tests.cs
+++ b/PackageBuilder/tests/PackageBuilder.Tests.cs
@@ -228,5 +228,44 @@ public void IntermediateBuilderTest1()
Assert.IsTrue(buildResults["E"]);
}
}
+
+ [TestMethod]
+ public void IntermediateBuilderTest2()
+ {
+ //
+ // cache contains a pre built A and B. A and B do not build. C will build.
+ //
+
+ string cwd = Directory.GetCurrentDirectory();
+ string testroot = $"{cwd}\\testcases\\intermediate1";
+
+ GraphBuilder gb = new GraphBuilder($"{testroot}{packagedescriptions}");
+
+ DirectoryInfo di = new DirectoryInfo($"{testroot}{packagesource}");
+ List paths = di.GetDirectories().Select(d => d.FullName).ToList();
+ var task = Task.Run(async () => await PackageHasher.HashFoldersAsync(paths, testroot));
+
+ // package source to package source hash mapping
+ Dictionary packageSourceHash = task.Result;
+
+ List excludeList = new List();
+ excludeList.Add(packageSourceHash["A"]);
+ excludeList.Add(packageSourceHash["B"]);
+ excludeList.Add(packageSourceHash["C"]);
+ excludeList.Add(packageSourceHash["D"]);
+ excludeList.Add(packageSourceHash["E"]);
+ CleanCache(testroot, excludeList);
+
+ {
+ CleanOutput(testroot);
+ PackageBuilder pb = new PackageBuilder(testroot);
+ Dictionary buildResults = pb.Build("A", $"{testroot}{packagesource}", packageSourceHash, gb.Graph);
+ Assert.IsFalse(buildResults["A"]);
+ Assert.IsFalse(buildResults["B"]);
+ Assert.IsFalse(buildResults["C"]);
+ Assert.IsFalse(buildResults["D"]);
+ Assert.IsFalse(buildResults["E"]);
+ }
+ }
}
}
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/A.061E4A81196F0421370B6B00873592A1.zip b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/A.061E4A81196F0421370B6B00873592A1.zip
new file mode 100644
index 0000000..fe3f4ca
Binary files /dev/null and b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/A.061E4A81196F0421370B6B00873592A1.zip differ
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/B.4ACF41085828E31F786F43D8F381341C.zip b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/B.4ACF41085828E31F786F43D8F381341C.zip
new file mode 100644
index 0000000..41b9177
Binary files /dev/null and b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/B.4ACF41085828E31F786F43D8F381341C.zip differ
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/C.99A6BC607FBD4F6AC4F97D0B2B9CEB34.zip b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/C.99A6BC607FBD4F6AC4F97D0B2B9CEB34.zip
new file mode 100644
index 0000000..e1621a5
Binary files /dev/null and b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/C.99A6BC607FBD4F6AC4F97D0B2B9CEB34.zip differ
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/D.104F979DDC76A9F397A9DE087C788446.zip b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/D.104F979DDC76A9F397A9DE087C788446.zip
new file mode 100644
index 0000000..fddff50
Binary files /dev/null and b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/D.104F979DDC76A9F397A9DE087C788446.zip differ
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/E.8FED3A8528DFF1BA9B340449E9311315.zip b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/E.8FED3A8528DFF1BA9B340449E9311315.zip
new file mode 100644
index 0000000..47ad6a9
Binary files /dev/null and b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/E.8FED3A8528DFF1BA9B340449E9311315.zip differ
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/dummy b/PackageBuilder/tests/testcases/intermediate2/pkgs/cache/dummy
new file mode 100644
index 0000000..e69de29
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/A.xml b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/A.xml
new file mode 100644
index 0000000..4bd41b8
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/A.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/B.xml b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/B.xml
new file mode 100644
index 0000000..be4f421
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/B.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/C.xml b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/C.xml
new file mode 100644
index 0000000..748d15f
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/C.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/D.xml b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/D.xml
new file mode 100644
index 0000000..01817cd
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/D.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/E.xml b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/E.xml
new file mode 100644
index 0000000..f675bb4
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/pkgs/descriptions/E.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/src/A/file1.txt b/PackageBuilder/tests/testcases/intermediate2/src/A/file1.txt
new file mode 100644
index 0000000..86fc6b2
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/src/A/file1.txt
@@ -0,0 +1 @@
+test data for file1. Just needed to get a hash value.
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/src/B/file2.txt b/PackageBuilder/tests/testcases/intermediate2/src/B/file2.txt
new file mode 100644
index 0000000..86fc6b2
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/src/B/file2.txt
@@ -0,0 +1 @@
+test data for file1. Just needed to get a hash value.
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/src/C/file3.txt b/PackageBuilder/tests/testcases/intermediate2/src/C/file3.txt
new file mode 100644
index 0000000..86fc6b2
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/src/C/file3.txt
@@ -0,0 +1 @@
+test data for file1. Just needed to get a hash value.
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/src/D/file4.txt b/PackageBuilder/tests/testcases/intermediate2/src/D/file4.txt
new file mode 100644
index 0000000..86fc6b2
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/src/D/file4.txt
@@ -0,0 +1 @@
+test data for file1. Just needed to get a hash value.
\ No newline at end of file
diff --git a/PackageBuilder/tests/testcases/intermediate2/src/E/file5.txt b/PackageBuilder/tests/testcases/intermediate2/src/E/file5.txt
new file mode 100644
index 0000000..86fc6b2
--- /dev/null
+++ b/PackageBuilder/tests/testcases/intermediate2/src/E/file5.txt
@@ -0,0 +1 @@
+test data for file1. Just needed to get a hash value.
\ No newline at end of file