From d686f0d92fc14940441dbf53c28547a975572f92 Mon Sep 17 00:00:00 2001
From: Sean Hall <r.sean.hall@gmail.com>
Date: Thu, 23 Apr 2020 12:01:31 +1000
Subject: Add ManagedBootstrapperApplicationPrereqInformation element to move
 prereq info back to NetFx.

---
 src/wixext/BalCompiler.cs       | 65 +++++++++++++++++++++++++++++++++++++
 src/wixext/bal.xsd              | 29 +++++++++++++++++
 src/wixlib/NetFx451AsPrereq.wxs | 34 --------------------
 src/wixlib/NetFx452AsPrereq.wxs | 34 --------------------
 src/wixlib/NetFx45AsPrereq.wxs  | 34 --------------------
 src/wixlib/NetFx461AsPrereq.wxs | 34 --------------------
 src/wixlib/NetFx462AsPrereq.wxs | 34 --------------------
 src/wixlib/NetFx46AsPrereq.wxs  | 34 --------------------
 src/wixlib/NetFx4AsPrereq.wxs   | 71 -----------------------------------------
 src/wixlib/bal.wixproj          |  7 ----
 10 files changed, 94 insertions(+), 282 deletions(-)
 delete mode 100644 src/wixlib/NetFx451AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx452AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx45AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx461AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx462AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx46AsPrereq.wxs
 delete mode 100644 src/wixlib/NetFx4AsPrereq.wxs

(limited to 'src')

diff --git a/src/wixext/BalCompiler.cs b/src/wixext/BalCompiler.cs
index c291d41f..da32234c 100644
--- a/src/wixext/BalCompiler.cs
+++ b/src/wixext/BalCompiler.cs
@@ -46,6 +46,9 @@ namespace WixToolset.Bal
                         case "Condition":
                             this.ParseConditionElement(intermediate, section, element);
                             break;
+                        case "ManagedBootstrapperApplicationPrereqInformation":
+                            this.ParseMbaPrereqInfoElement(intermediate, section, element);
+                            break;
                         default:
                             this.ParseHelper.UnexpectedElement(parentElement, element);
                             break;
@@ -292,6 +295,68 @@ namespace WixToolset.Bal
             }
         }
 
+        /// <summary>
+        /// Parses a Condition element for Bundles.
+        /// </summary>
+        /// <param name="node">The element to parse.</param>
+        private void ParseMbaPrereqInfoElement(Intermediate intermediate, IntermediateSection section, XElement node)
+        {
+            var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
+            string packageId = null;
+            string licenseFile = null;
+            string licenseUrl = null;
+
+            foreach (var attrib in node.Attributes())
+            {
+                if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
+                {
+                    switch (attrib.Name.LocalName)
+                    {
+                        case "LicenseFile":
+                            licenseFile = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
+                            break;
+                        case "LicenseUrl":
+                            licenseUrl = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
+                            break;
+                        case "PackageId":
+                            packageId = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
+                            break;
+                        default:
+                            this.ParseHelper.UnexpectedAttribute(node, attrib);
+                            break;
+                    }
+                }
+                else
+                {
+                    this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
+                }
+            }
+
+            this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
+
+            if (null == packageId)
+            {
+                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "PackageId"));
+            }
+
+            if (null == licenseFile && null == licenseUrl ||
+                null != licenseFile && null != licenseUrl)
+            {
+                this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "LicenseFile", "LicenseUrl", true));
+            }
+
+            if (!this.Messaging.EncounteredError)
+            {
+                section.AddTuple(new WixMbaPrereqInformationTuple(sourceLineNumbers)
+                {
+                    PackageId = packageId,
+                    LicenseFile = licenseFile,
+                    LicenseUrl = licenseUrl,
+                });
+                this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.WixBundlePackage, packageId);
+            }
+        }
+
         /// <summary>
         /// Parses a WixStandardBootstrapperApplication element for Bundles.
         /// </summary>
diff --git a/src/wixext/bal.xsd b/src/wixext/bal.xsd
index 73f10540..3081a279 100644
--- a/src/wixext/bal.xsd
+++ b/src/wixext/bal.xsd
@@ -186,6 +186,35 @@
         </xs:complexType>
     </xs:element>
 
+    <xs:element name="ManagedBootstrapperApplicationPrereqInformation">
+        <xs:annotation>
+            <xs:documentation>
+                Adds license information for a prereq package, should only be used when unable to add the license attributes to the package directly.
+            </xs:documentation>
+            <xs:appinfo>
+                <xse:parent namespace="http://wixtoolset.org/schemas/v4/wxs" ref="Bundle" />
+                <xse:parent namespace="http://wixtoolset.org/schemas/v4/wxs" ref="Fragment" />
+            </xs:appinfo>
+        </xs:annotation>
+        <xs:complexType>
+            <xs:attribute name="PackageId" type="xs:string" use="required">
+                <xs:annotation>
+                    <xs:documentation>Id of the target package.</xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+            <xs:attribute name="LicenseFile" type="xs:string">
+                <xs:annotation>
+                    <xs:documentation>Source file of the license. May not be used with LicenseUrl.</xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+            <xs:attribute name="LicenseUrl" type="xs:string">
+                <xs:annotation>
+                    <xs:documentation>Source url of the license. May not be used with LicenseFile.</xs:documentation>
+                </xs:annotation>
+            </xs:attribute>
+        </xs:complexType>
+    </xs:element>
+
     <xs:attribute name="BAFunctions" type="YesNoType">
         <xs:annotation>
             <xs:documentation>
diff --git a/src/wixlib/NetFx451AsPrereq.wxs b/src/wixlib/NetFx451AsPrereq.wxs
deleted file mode 100644
index 67c05b05..00000000
--- a/src/wixlib/NetFx451AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx451EulaLink = http://wixtoolset.org/licenses/netfx451 ?>
-    <?define NetFx451WebId = NetFx451Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx451WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx451WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx451WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx451EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx451RedistId = NetFx451Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx451RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx451RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx451RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx451EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx452AsPrereq.wxs b/src/wixlib/NetFx452AsPrereq.wxs
deleted file mode 100644
index b41a9986..00000000
--- a/src/wixlib/NetFx452AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx452EulaLink = http://wixtoolset.org/licenses/netfx452 ?>
-    <?define NetFx452WebId = NetFx452Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx452WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx452WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx452WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx452EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx452RedistId = NetFx452Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx452RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx452RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx452RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx452EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx45AsPrereq.wxs b/src/wixlib/NetFx45AsPrereq.wxs
deleted file mode 100644
index b95fc8a4..00000000
--- a/src/wixlib/NetFx45AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx45EulaLink = http://go.microsoft.com/fwlink/?LinkID=260867 ?>
-    <?define NetFx45WebId = NetFx45Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx45WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx45WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx45WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx45EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx45RedistId = NetFx45Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx45RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx45RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx45RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx45EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx461AsPrereq.wxs b/src/wixlib/NetFx461AsPrereq.wxs
deleted file mode 100644
index d6b24b43..00000000
--- a/src/wixlib/NetFx461AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx461EulaLink = http://referencesource.microsoft.com/license.html ?>
-    <?define NetFx461WebId = NetFx461Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx461WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx461WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx461WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx461EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-
-    <?define NetFx461RedistId = NetFx461Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx461RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx461RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx461RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx461EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx462AsPrereq.wxs b/src/wixlib/NetFx462AsPrereq.wxs
deleted file mode 100644
index e6f6889a..00000000
--- a/src/wixlib/NetFx462AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx462EulaLink = http://referencesource.microsoft.com/license.html ?>
-    <?define NetFx462WebId = NetFx462Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx462WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx462WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx462WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx462EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-
-    <?define NetFx462RedistId = NetFx462Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx462RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx462RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx462RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx462EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx46AsPrereq.wxs b/src/wixlib/NetFx46AsPrereq.wxs
deleted file mode 100644
index 52880022..00000000
--- a/src/wixlib/NetFx46AsPrereq.wxs
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx46EulaLink = http://go.microsoft.com/fwlink/?LinkID=558772 ?>
-    <?define NetFx46WebId = NetFx46Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx46WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx46WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx46WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx46EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-
-    <?define NetFx46RedistId = NetFx46Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx46RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx46RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx46RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx46EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/NetFx4AsPrereq.wxs b/src/wixlib/NetFx4AsPrereq.wxs
deleted file mode 100644
index 9b7437e5..00000000
--- a/src/wixlib/NetFx4AsPrereq.wxs
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!-- 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. -->
-
-
-<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>
-    <?define NetFx40EulaLink =  http://go.microsoft.com/fwlink/?LinkID=188993 ?>
-    <?define NetFx40WebId = NetFx40Web ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx40WebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx40WebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx40WebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx40EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx40RedistId = NetFx40Redist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx40RedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx40RedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx40RedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx40EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx40ClientWebId = NetFx40ClientWeb ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx40ClientWebId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx40ClientWebId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx40ClientWebId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx40EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <?define NetFx40ClientRedistId = NetFx40ClientRedist ?>
-    <Fragment>
-        <PackageGroup Id="$(var.NetFx40ClientRedistId)AsPrereq">
-            <PackageGroupRef Id="$(var.NetFx40ClientRedistId)" />
-        </PackageGroup>
-        
-        <CustomTable Id='WixMbaPrereqInformation'>
-            <Row>
-                <Data Column='PackageId'>$(var.NetFx40ClientRedistId)</Data>
-                <Data Column='LicenseUrl'>$(var.NetFx40EulaLink)</Data>
-            </Row>
-        </CustomTable>
-    </Fragment>
-    
-    <!-- Not sure why we have to redefine the table here. -->
-    <Fragment>
-        <CustomTable Id='WixMbaPrereqInformation' Unreal='yes'>
-            <Column Id='PackageId' Category='Identifier' Type='string' Width='72' PrimaryKey ='yes'/>
-            <Column Id='LicenseUrl' Category='Formatted' Type='string' Width='0' Nullable='yes'/>
-            <Column Id='LicenseFile' Category='Formatted' Type='string' Width='0' Nullable='yes'/>
-        </CustomTable>
-    </Fragment>
-</Wix>
diff --git a/src/wixlib/bal.wixproj b/src/wixlib/bal.wixproj
index 51268803..c33375fe 100644
--- a/src/wixlib/bal.wixproj
+++ b/src/wixlib/bal.wixproj
@@ -15,13 +15,6 @@
   <ItemGroup>
     <Compile Include="BalExtension.wxs" />
     <Compile Include="Mba.wxs" />
-    <Compile Include="NetFx4AsPrereq.wxs" />
-    <Compile Include="NetFx45AsPrereq.wxs" />
-    <Compile Include="NetFx451AsPrereq.wxs" />
-    <Compile Include="NetFx452AsPrereq.wxs" />
-    <Compile Include="NetFx46AsPrereq.wxs" />
-    <Compile Include="NetFx461AsPrereq.wxs" />
-    <Compile Include="NetFx462AsPrereq.wxs" />
     <Compile Include="wixstdba.wxs" />
     <Compile Include="wixstdba_x86.wxs" />
   </ItemGroup>
-- 
cgit v1.2.3-55-g6feb