summaryrefslogtreecommitdiff
path: root/src/internal/WixBuildTools.TestSupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/WixBuildTools.TestSupport')
-rw-r--r--src/internal/WixBuildTools.TestSupport/Builder.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/Builder.cs b/src/internal/WixBuildTools.TestSupport/Builder.cs
index ef0de8c9..31df0084 100644
--- a/src/internal/WixBuildTools.TestSupport/Builder.cs
+++ b/src/internal/WixBuildTools.TestSupport/Builder.cs
@@ -66,5 +66,93 @@ namespace WixBuildTools.TestSupport
66 return Query.QueryDatabase(outputPath, tables); 66 return Query.QueryDatabase(outputPath, tables);
67 } 67 }
68 } 68 }
69
70 public void BuildAndDecompileAndBuild(Action<string[]> buildFunc, Action<string[]> decompileFunc, string decompilePath)
71 {
72 var sourceFiles = Directory.GetFiles(this.SourceFolder, "*.wxs");
73 var wxlFiles = Directory.GetFiles(this.SourceFolder, "*.wxl");
74
75 using (var fs = new DisposableFileSystem())
76 {
77 var intermediateFolder = fs.GetFolder();
78 var outputFolder = Path.Combine(intermediateFolder, "bin");
79 var decompileExtractFolder = Path.Combine(intermediateFolder, "decompiled", "extract");
80 var decompileIntermediateFolder = Path.Combine(intermediateFolder, "decompiled", "obj");
81 var decompileBuildFolder = Path.Combine(intermediateFolder, "decompiled", "bin");
82 var outputPath = Path.Combine(outputFolder, this.OutputFile);
83 var decompileBuildPath = Path.Combine(decompileBuildFolder, this.OutputFile);
84
85 // First build.
86 var firstBuildArgs = new List<string>
87 {
88 "build",
89 "-o", outputPath,
90 "-intermediateFolder", intermediateFolder,
91 };
92
93 if (this.ExtensionType != null)
94 {
95 firstBuildArgs.Add("-ext");
96 firstBuildArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
97 }
98
99 firstBuildArgs.AddRange(sourceFiles);
100
101 foreach (var wxlFile in wxlFiles)
102 {
103 firstBuildArgs.Add("-loc");
104 firstBuildArgs.Add(wxlFile);
105 }
106
107 foreach (var bindPath in this.BindPaths)
108 {
109 firstBuildArgs.Add("-bindpath");
110 firstBuildArgs.Add(bindPath);
111 }
112
113 buildFunc(firstBuildArgs.ToArray());
114
115 // Decompile built output.
116 var decompileArgs = new List<string>
117 {
118 "msi", "decompile",
119 outputPath,
120 "-intermediateFolder", decompileIntermediateFolder,
121 "-x", decompileExtractFolder,
122 "-o", decompilePath
123 };
124
125 if (this.ExtensionType != null)
126 {
127 decompileArgs.Add("-ext");
128 decompileArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
129 }
130
131 decompileFunc(decompileArgs.ToArray());
132
133 // Build decompiled output.
134 var secondBuildArgs = new List<string>
135 {
136 "build",
137 decompilePath,
138 "-o", decompileBuildPath,
139 "-intermediateFolder", decompileIntermediateFolder
140 };
141
142 if (this.ExtensionType != null)
143 {
144 secondBuildArgs.Add("-ext");
145 secondBuildArgs.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
146 }
147
148 secondBuildArgs.Add("-bindpath");
149 secondBuildArgs.Add(outputFolder);
150
151 secondBuildArgs.Add("-bindpath");
152 secondBuildArgs.Add(decompileExtractFolder);
153
154 buildFunc(secondBuildArgs.ToArray());
155 }
156 }
69 } 157 }
70} 158}