summaryrefslogtreecommitdiff
path: root/src/internal/WixBuildTools.TestSupport/Builder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/WixBuildTools.TestSupport/Builder.cs')
-rw-r--r--src/internal/WixBuildTools.TestSupport/Builder.cs158
1 files changed, 0 insertions, 158 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/Builder.cs b/src/internal/WixBuildTools.TestSupport/Builder.cs
deleted file mode 100644
index 31df0084..00000000
--- a/src/internal/WixBuildTools.TestSupport/Builder.cs
+++ /dev/null
@@ -1,158 +0,0 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixBuildTools.TestSupport
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8
9 public class Builder
10 {
11 public Builder(string sourceFolder, Type extensionType = null, string[] bindPaths = null, string outputFile = null)
12 {
13 this.SourceFolder = sourceFolder;
14 this.ExtensionType = extensionType;
15 this.BindPaths = bindPaths;
16 this.OutputFile = outputFile ?? "test.msi";
17 }
18
19 public string[] BindPaths { get; set; }
20
21 public Type ExtensionType { get; set; }
22
23 public string OutputFile { get; set; }
24
25 public string SourceFolder { get; }
26
27 public string[] BuildAndQuery(Action<string[]> buildFunc, params string[] tables)
28 {
29 var sourceFiles = Directory.GetFiles(this.SourceFolder, "*.wxs");
30 var wxlFiles = Directory.GetFiles(this.SourceFolder, "*.wxl");
31
32 using (var fs = new DisposableFileSystem())
33 {
34 var intermediateFolder = fs.GetFolder();
35 var outputPath = Path.Combine(intermediateFolder, "bin", this.OutputFile);
36
37 var args = new List<string>
38 {
39 "build",
40 "-o", outputPath,
41 "-intermediateFolder", intermediateFolder,
42 };
43
44 if (this.ExtensionType != null)
45 {
46 args.Add("-ext");
47 args.Add(Path.GetFullPath(new Uri(this.ExtensionType.Assembly.CodeBase).LocalPath));
48 }
49
50 args.AddRange(sourceFiles);
51
52 foreach (var wxlFile in wxlFiles)
53 {
54 args.Add("-loc");
55 args.Add(wxlFile);
56 }
57
58 foreach (var bindPath in this.BindPaths)
59 {
60 args.Add("-bindpath");
61 args.Add(bindPath);
62 }
63
64 buildFunc(args.ToArray());
65
66 return Query.QueryDatabase(outputPath, tables);
67 }
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 }
157 }
158}