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