aboutsummaryrefslogtreecommitdiff
path: root/src/internal/WixBuildTools.TestSupport/Builder.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-05-11 07:37:18 -0700
committerRob Mensching <rob@firegiant.com>2021-05-11 07:37:18 -0700
commit985b2683b2717c83a27295b36e09b126083238f9 (patch)
tree622804d279e0ac58366dee62888e6a317a2b9d41 /src/internal/WixBuildTools.TestSupport/Builder.cs
parent3f583916719eeef598d10a5d4e14ef14f008243b (diff)
parent6a24996a2e831cfe402398af65b31fb1ecd575a9 (diff)
downloadwix-985b2683b2717c83a27295b36e09b126083238f9.tar.gz
wix-985b2683b2717c83a27295b36e09b126083238f9.tar.bz2
wix-985b2683b2717c83a27295b36e09b126083238f9.zip
Merge WixBuildTools
Diffstat (limited to 'src/internal/WixBuildTools.TestSupport/Builder.cs')
-rw-r--r--src/internal/WixBuildTools.TestSupport/Builder.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/internal/WixBuildTools.TestSupport/Builder.cs b/src/internal/WixBuildTools.TestSupport/Builder.cs
new file mode 100644
index 00000000..ef0de8c9
--- /dev/null
+++ b/src/internal/WixBuildTools.TestSupport/Builder.cs
@@ -0,0 +1,70 @@
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}