aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Mba.Core
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-05-15 17:18:36 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-16 21:47:46 +1000
commit9010bd828e70e91523ed74733cc371eec09f58bb (patch)
tree9d40b796b6b29474122bcf0fb99bc717f83e7cf1 /src/WixToolset.Mba.Core
parent780cd25e41f2d2982807a0a2a24a734684d27fe6 (diff)
downloadwix-9010bd828e70e91523ed74733cc371eec09f58bb.tar.gz
wix-9010bd828e70e91523ed74733cc371eec09f58bb.tar.bz2
wix-9010bd828e70e91523ed74733cc371eec09f58bb.zip
WIXFEAT:6164 Update BAL_INFO_PACKAGE with bal specific data.
Diffstat (limited to 'src/WixToolset.Mba.Core')
-rw-r--r--src/WixToolset.Mba.Core/BundleInfo.cs8
-rw-r--r--src/WixToolset.Mba.Core/IBundleInfo.cs2
-rw-r--r--src/WixToolset.Mba.Core/IPackageInfo.cs6
-rw-r--r--src/WixToolset.Mba.Core/PackageInfo.cs64
4 files changed, 66 insertions, 14 deletions
diff --git a/src/WixToolset.Mba.Core/BundleInfo.cs b/src/WixToolset.Mba.Core/BundleInfo.cs
index e6d2f6e6..e1a56878 100644
--- a/src/WixToolset.Mba.Core/BundleInfo.cs
+++ b/src/WixToolset.Mba.Core/BundleInfo.cs
@@ -20,10 +20,11 @@ namespace WixToolset.Mba.Core
20 this.Packages = new Dictionary<string, IPackageInfo>(); 20 this.Packages = new Dictionary<string, IPackageInfo>();
21 } 21 }
22 22
23 public void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e) 23 public IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e)
24 { 24 {
25 var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version); 25 var package = PackageInfo.GetRelatedBundleAsPackage(e.ProductCode, e.RelationType, e.PerMachine, e.Version);
26 this.Packages.Add(package.Id, package); 26 this.Packages.Add(package.Id, package);
27 return package;
27 } 28 }
28 29
29 public static IBundleInfo ParseBundleFromStream(Stream stream) 30 public static IBundleInfo ParseBundleFromStream(Stream stream)
@@ -56,10 +57,7 @@ namespace WixToolset.Mba.Core
56 57
57 bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable"); 58 bundle.LogVariable = BootstrapperApplicationData.GetAttribute(bundleNode, "LogPathVariable");
58 59
59 foreach (var package in PackageInfo.ParsePackagesFromXml(root)) 60 bundle.Packages = PackageInfo.ParsePackagesFromXml(root);
60 {
61 bundle.Packages.Add(package.Id, package);
62 }
63 61
64 return bundle; 62 return bundle;
65 } 63 }
diff --git a/src/WixToolset.Mba.Core/IBundleInfo.cs b/src/WixToolset.Mba.Core/IBundleInfo.cs
index 3d5b067e..d471c677 100644
--- a/src/WixToolset.Mba.Core/IBundleInfo.cs
+++ b/src/WixToolset.Mba.Core/IBundleInfo.cs
@@ -11,6 +11,6 @@ namespace WixToolset.Mba.Core
11 IDictionary<string, IPackageInfo> Packages { get; } 11 IDictionary<string, IPackageInfo> Packages { get; }
12 bool PerMachine { get; } 12 bool PerMachine { get; }
13 13
14 void AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e); 14 IPackageInfo AddRelatedBundleAsPackage(DetectRelatedBundleEventArgs e);
15 } 15 }
16} \ No newline at end of file 16} \ No newline at end of file
diff --git a/src/WixToolset.Mba.Core/IPackageInfo.cs b/src/WixToolset.Mba.Core/IPackageInfo.cs
index 5afe4b38..a82e81ea 100644
--- a/src/WixToolset.Mba.Core/IPackageInfo.cs
+++ b/src/WixToolset.Mba.Core/IPackageInfo.cs
@@ -5,12 +5,16 @@ namespace WixToolset.Mba.Core
5 public interface IPackageInfo 5 public interface IPackageInfo
6 { 6 {
7 CacheType CacheType { get; } 7 CacheType CacheType { get; }
8 object CustomData { get; set; }
8 string Description { get; } 9 string Description { get; }
9 bool DisplayInternalUI { get; } 10 string DisplayInternalUICondition { get; }
10 string DisplayName { get; } 11 string DisplayName { get; }
11 string Id { get; } 12 string Id { get; }
12 string InstallCondition { get; } 13 string InstallCondition { get; }
13 bool Permanent { get; } 14 bool Permanent { get; }
15 bool PrereqPackage { get; }
16 string PrereqLicenseFile { get; }
17 string PrereqLicenseUrl { get; }
14 string ProductCode { get; } 18 string ProductCode { get; }
15 PackageType Type { get; } 19 PackageType Type { get; }
16 string UpgradeCode { get; } 20 string UpgradeCode { get; }
diff --git a/src/WixToolset.Mba.Core/PackageInfo.cs b/src/WixToolset.Mba.Core/PackageInfo.cs
index 46894d2e..d3199c08 100644
--- a/src/WixToolset.Mba.Core/PackageInfo.cs
+++ b/src/WixToolset.Mba.Core/PackageInfo.cs
@@ -34,17 +34,22 @@ namespace WixToolset.Mba.Core
34 public PackageType Type { get; internal set; } 34 public PackageType Type { get; internal set; }
35 public bool Permanent { get; internal set; } 35 public bool Permanent { get; internal set; }
36 public bool Vital { get; internal set; } 36 public bool Vital { get; internal set; }
37 public bool DisplayInternalUI { get; internal set; } 37 public string DisplayInternalUICondition { get; internal set; }
38 public string ProductCode { get; internal set; } 38 public string ProductCode { get; internal set; }
39 public string UpgradeCode { get; internal set; } 39 public string UpgradeCode { get; internal set; }
40 public string Version { get; internal set; } 40 public string Version { get; internal set; }
41 public string InstallCondition { get; internal set; } 41 public string InstallCondition { get; internal set; }
42 public CacheType CacheType { get; internal set; } 42 public CacheType CacheType { get; internal set; }
43 public bool PrereqPackage { get; internal set; }
44 public string PrereqLicenseFile { get; internal set; }
45 public string PrereqLicenseUrl { get; internal set; }
46 public object CustomData { get; set; }
43 47
44 internal PackageInfo() { } 48 internal PackageInfo() { }
45 49
46 public static IEnumerable<IPackageInfo> ParsePackagesFromXml(XPathNavigator root) 50 public static IDictionary<string, IPackageInfo> ParsePackagesFromXml(XPathNavigator root)
47 { 51 {
52 var packagesById = new Dictionary<string, IPackageInfo>();
48 XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); 53 XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable);
49 namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); 54 namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace);
50 XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager); 55 XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixPackageProperties", namespaceManager);
@@ -85,9 +90,6 @@ namespace WixToolset.Mba.Core
85 } 90 }
86 package.Vital = vital.Value; 91 package.Vital = vital.Value;
87 92
88 bool? displayInternalUI = BootstrapperApplicationData.GetYesNoAttribute(node, "DisplayInternalUI");
89 package.DisplayInternalUI = displayInternalUI.HasValue && displayInternalUI.Value;
90
91 package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode"); 93 package.ProductCode = BootstrapperApplicationData.GetAttribute(node, "ProductCode");
92 94
93 package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode"); 95 package.UpgradeCode = BootstrapperApplicationData.GetAttribute(node, "UpgradeCode");
@@ -96,8 +98,11 @@ namespace WixToolset.Mba.Core
96 98
97 package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition"); 99 package.InstallCondition = BootstrapperApplicationData.GetAttribute(node, "InstallCondition");
98 100
99 yield return package; 101 packagesById.Add(package.Id, package);
100 } 102 }
103
104 ParseBalPackageInfoFromXml(root, namespaceManager, packagesById);
105 return packagesById;
101 } 106 }
102 107
103 public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName) 108 public static CacheType? GetCacheTypeAttribute(XPathNavigator node, string attributeName)
@@ -154,7 +159,7 @@ namespace WixToolset.Mba.Core
154 } 159 }
155 } 160 }
156 161
157 public static PackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version) 162 public static IPackageInfo GetRelatedBundleAsPackage(string id, RelationType relationType, bool perMachine, Version version)
158 { 163 {
159 PackageInfo package = new PackageInfo(); 164 PackageInfo package = new PackageInfo();
160 package.Id = id; 165 package.Id = id;
@@ -177,5 +182,50 @@ namespace WixToolset.Mba.Core
177 182
178 return package; 183 return package;
179 } 184 }
185
186 internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespaceManager namespaceManager, Dictionary<string, IPackageInfo> packagesById)
187 {
188 XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixBalPackageInfo", namespaceManager);
189
190 foreach (XPathNavigator node in nodes)
191 {
192 string id = BootstrapperApplicationData.GetAttribute(node, "PackageId");
193 if (id == null)
194 {
195 throw new Exception("Failed to get package identifier for WixBalPackageInfo.");
196 }
197
198 if (!packagesById.TryGetValue(id, out var ipackage))
199 {
200 throw new Exception(string.Format("Failed to find package specified in WixBalPackageInfo: {0}", id));
201 }
202
203 var package = (PackageInfo)ipackage;
204
205 package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition");
206 }
207
208 nodes = root.Select("/p:BootstrapperApplicationData/p:WixMbaPrereqInformation", namespaceManager);
209
210 foreach (XPathNavigator node in nodes)
211 {
212 string id = BootstrapperApplicationData.GetAttribute(node, "PackageId");
213 if (id == null)
214 {
215 throw new Exception("Failed to get package identifier for WixMbaPrereqInformation.");
216 }
217
218 if (!packagesById.TryGetValue(id, out var ipackage))
219 {
220 throw new Exception(string.Format("Failed to find package specified in WixMbaPrereqInformation: {0}", id));
221 }
222
223 var package = (PackageInfo)ipackage;
224
225 package.PrereqPackage = true;
226 package.PrereqLicenseFile = BootstrapperApplicationData.GetAttribute(node, "LicenseFile");
227 package.PrereqLicenseUrl = BootstrapperApplicationData.GetAttribute(node, "LicenseUrl");
228 }
229 }
180 } 230 }
181} 231}