diff options
author | Rob Mensching <rob@firegiant.com> | 2021-04-22 16:36:39 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2021-04-22 16:50:15 -0700 |
commit | 6a24996a2e831cfe402398af65b31fb1ecd575a9 (patch) | |
tree | e377370df4bc7901745c6b5f50268fa665edb3f8 /src/internal/WixBuildTools.TestSupport/Builder.cs | |
parent | 2587a8b46b705d53156f5cd1bd866f855049081d (diff) | |
download | wix-6a24996a2e831cfe402398af65b31fb1ecd575a9.tar.gz wix-6a24996a2e831cfe402398af65b31fb1ecd575a9.tar.bz2 wix-6a24996a2e831cfe402398af65b31fb1ecd575a9.zip |
Move WixBuildTools into internal
Diffstat (limited to 'src/internal/WixBuildTools.TestSupport/Builder.cs')
-rw-r--r-- | src/internal/WixBuildTools.TestSupport/Builder.cs | 70 |
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 | |||
3 | namespace 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 | } | ||