aboutsummaryrefslogtreecommitdiff
path: root/src/wixext/BalBinder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext/BalBinder.cs')
-rw-r--r--src/wixext/BalBinder.cs125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/wixext/BalBinder.cs b/src/wixext/BalBinder.cs
new file mode 100644
index 00000000..30f7ab44
--- /dev/null
+++ b/src/wixext/BalBinder.cs
@@ -0,0 +1,125 @@
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 WixToolset.Extensions
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8 using System.Text;
9 using WixToolset;
10 using WixToolset.Data;
11 using WixToolset.Data.Rows;
12 using WixToolset.Extensibility;
13
14 public class BalBinder : BinderExtension
15 {
16 public override void Finish(Output output)
17 {
18 // Only process Bundles.
19 if (OutputType.Bundle != output.Type)
20 {
21 return;
22 }
23
24 Table baTable = output.Tables["WixBootstrapperApplication"];
25 Row baRow = baTable.Rows[0];
26 string baId = (string)baRow[0];
27 if (null == baId)
28 {
29 return;
30 }
31
32 bool isStdBA = baId.StartsWith("WixStandardBootstrapperApplication");
33 bool isMBA = baId.StartsWith("ManagedBootstrapperApplicationHost");
34
35 if (isStdBA || isMBA)
36 {
37 VerifyBAFunctions(output);
38 }
39
40 if (isMBA)
41 {
42 VerifyPrereqPackages(output);
43 }
44 }
45
46 private void VerifyBAFunctions(Output output)
47 {
48 Row baFunctionsRow = null;
49 Table baFunctionsTable = output.Tables["WixBalBAFunctions"];
50 foreach (Row row in baFunctionsTable.RowsAs<Row>())
51 {
52 if (null == baFunctionsRow)
53 {
54 baFunctionsRow = row;
55 }
56 else
57 {
58 this.Core.OnMessage(BalErrors.MultipleBAFunctions(row.SourceLineNumbers));
59 }
60 }
61
62 Table payloadPropertiesTable = output.Tables["WixPayloadProperties"];
63 IEnumerable<WixPayloadPropertiesRow> payloadPropertiesRows = payloadPropertiesTable.RowsAs<WixPayloadPropertiesRow>();
64 if (null == baFunctionsRow)
65 {
66 foreach (WixPayloadPropertiesRow payloadPropertiesRow in payloadPropertiesRows)
67 {
68 // TODO: Make core WiX canonicalize Name (this won't catch '.\bafunctions.dll').
69 if (String.Equals(payloadPropertiesRow.Name, "bafunctions.dll", StringComparison.OrdinalIgnoreCase))
70 {
71 this.Core.OnMessage(BalWarnings.UnmarkedBAFunctionsDLL(payloadPropertiesRow.SourceLineNumbers));
72 }
73 }
74 }
75 else
76 {
77 // TODO: May need to revisit this depending on the outcome of #5273.
78 string payloadId = (string)baFunctionsRow[0];
79 WixPayloadPropertiesRow bundlePayloadRow = payloadPropertiesRows.Single(x => payloadId == x.Id);
80 if (Compiler.BurnUXContainerId != bundlePayloadRow.Container)
81 {
82 this.Core.OnMessage(BalErrors.BAFunctionsPayloadRequiredInUXContainer(baFunctionsRow.SourceLineNumbers));
83 }
84 }
85 }
86
87 private void VerifyPrereqPackages(Output output)
88 {
89 Table prereqInfoTable = output.Tables["WixMbaPrereqInformation"];
90 if (null == prereqInfoTable || prereqInfoTable.Rows.Count == 0)
91 {
92 this.Core.OnMessage(BalErrors.MissingPrereq());
93 return;
94 }
95
96 bool foundLicenseFile = false;
97 bool foundLicenseUrl = false;
98
99 foreach (Row prereqInfoRow in prereqInfoTable.Rows)
100 {
101 if (null != prereqInfoRow[1])
102 {
103 if (foundLicenseFile || foundLicenseUrl)
104 {
105 this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers));
106 return;
107 }
108
109 foundLicenseFile = true;
110 }
111
112 if (null != prereqInfoRow[2])
113 {
114 if (foundLicenseFile || foundLicenseUrl)
115 {
116 this.Core.OnMessage(BalErrors.MultiplePrereqLicenses(prereqInfoRow.SourceLineNumbers));
117 return;
118 }
119
120 foundLicenseUrl = true;
121 }
122 }
123 }
124 }
125}