aboutsummaryrefslogtreecommitdiff
path: root/src/ext
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2022-01-29 23:44:11 -0500
committerBob Arnson <github@bobs.org>2022-01-30 13:02:05 -0500
commit7ce477c6863c74ef0a50d117d8c28b2f19971b42 (patch)
treeb953aae25a04d9ffbf0bd4609055087d96e760dc /src/ext
parent3c1b81ff55975adffdc76f1a184b0f264bd97cd6 (diff)
downloadwix-7ce477c6863c74ef0a50d117d8c28b2f19971b42.tar.gz
wix-7ce477c6863c74ef0a50d117d8c28b2f19971b42.tar.bz2
wix-7ce477c6863c74ef0a50d117d8c28b2f19971b42.zip
Add compiler extension to handle platforms.
Custom actions to print EULA and validate install directories are defined in WixUIExtension compiler extension, to handle platform-specific custom actions referred to from `DoAction` control events. This is the least-worst solution, given the `DoAction` approach used in the WixUI authoring and anyone customizing a WixUI set.
Diffstat (limited to 'src/ext')
-rw-r--r--src/ext/UI/ca/uica.vcxproj16
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Advanced/Package.wxs6
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_FeatureTree/Package.wxs4
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs4
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Minimal/Package.wxs4
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs4
-rw-r--r--src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs99
-rw-r--r--src/ext/UI/wixext/UICompiler.cs118
-rw-r--r--src/ext/UI/wixext/UIExtensionFactory.cs1
-rw-r--r--src/ext/UI/wixlib/Common_Platform.wxi17
-rw-r--r--src/ext/UI/wixlib/Common_arm64.wxs7
-rw-r--r--src/ext/UI/wixlib/Common_x64.wxs7
-rw-r--r--src/ext/UI/wixlib/WixUI_Advanced.wxs1
-rw-r--r--src/ext/UI/wixlib/WixUI_FeatureTree.wxs1
-rw-r--r--src/ext/UI/wixlib/WixUI_InstallDir.wxs1
-rw-r--r--src/ext/UI/wixlib/WixUI_Minimal.wxs1
-rw-r--r--src/ext/UI/wixlib/WixUI_Mondo.wxs1
-rw-r--r--src/ext/UI/wixlib/caSuffix.wxi27
-rw-r--r--src/ext/UI/wixlib/ui.wixproj4
19 files changed, 238 insertions, 85 deletions
diff --git a/src/ext/UI/ca/uica.vcxproj b/src/ext/UI/ca/uica.vcxproj
index e06b7572..27f0faa7 100644
--- a/src/ext/UI/ca/uica.vcxproj
+++ b/src/ext/UI/ca/uica.vcxproj
@@ -11,6 +11,22 @@
11 <Configuration>Release</Configuration> 11 <Configuration>Release</Configuration>
12 <Platform>Win32</Platform> 12 <Platform>Win32</Platform>
13 </ProjectConfiguration> 13 </ProjectConfiguration>
14 <ProjectConfiguration Include="Debug|x64">
15 <Configuration>Debug</Configuration>
16 <Platform>x64</Platform>
17 </ProjectConfiguration>
18 <ProjectConfiguration Include="Release|x64">
19 <Configuration>Release</Configuration>
20 <Platform>x64</Platform>
21 </ProjectConfiguration>
22 <ProjectConfiguration Include="Debug|ARM64">
23 <Configuration>Debug</Configuration>
24 <Platform>ARM64</Platform>
25 </ProjectConfiguration>
26 <ProjectConfiguration Include="Release|ARM64">
27 <Configuration>Release</Configuration>
28 <Platform>ARM64</Platform>
29 </ProjectConfiguration>
14 </ItemGroup> 30 </ItemGroup>
15 31
16 <PropertyGroup Label="Globals"> 32 <PropertyGroup Label="Globals">
diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Advanced/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Advanced/Package.wxs
index 5ce4b00f..c22328e6 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Advanced/Package.wxs
+++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Advanced/Package.wxs
@@ -1,5 +1,5 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4 4
5 <Feature Id="ProductFeature" Title="MsiPackage"> 5 <Feature Id="ProductFeature" Title="MsiPackage">
@@ -12,7 +12,7 @@
12 </Component> 12 </Component>
13 </ComponentGroup> 13 </ComponentGroup>
14 14
15 <UIRef Id="WixUI_Advanced" /> 15 <ui:WixUI Id="WixUI_Advanced" />
16 <Property Id="ApplicationFolderName" Value="MyProgram" /> 16 <Property Id="ApplicationFolderName" Value="MyProgram" />
17 <Property Id="WixAppFolder" Value="WixPerMachineFolder" /> 17 <Property Id="WixAppFolder" Value="WixPerMachineFolder" />
18 </Package> 18 </Package>
diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_FeatureTree/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_FeatureTree/Package.wxs
index aff1c077..7c4db223 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_FeatureTree/Package.wxs
+++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_FeatureTree/Package.wxs
@@ -1,4 +1,4 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4 4
@@ -12,7 +12,7 @@
12 </Component> 12 </Component>
13 </ComponentGroup> 13 </ComponentGroup>
14 14
15 <UIRef Id="WixUI_FeatureTree" /> 15 <ui:WixUI Id="WixUI_FeatureTree" />
16 </Package> 16 </Package>
17 17
18 <Fragment> 18 <Fragment>
diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs
index 7c2ceae0..b6f2344a 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs
+++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs
@@ -1,4 +1,4 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4 4
@@ -12,7 +12,7 @@
12 </Component> 12 </Component>
13 </ComponentGroup> 13 </ComponentGroup>
14 14
15 <UIRef Id="WixUI_InstallDir" /> 15 <ui:WixUI Id="WixUI_InstallDir" />
16 </Package> 16 </Package>
17 17
18 <Fragment> 18 <Fragment>
diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Minimal/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Minimal/Package.wxs
index d2ff256c..962be579 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Minimal/Package.wxs
+++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Minimal/Package.wxs
@@ -1,4 +1,4 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4 4
@@ -12,7 +12,7 @@
12 </Component> 12 </Component>
13 </ComponentGroup> 13 </ComponentGroup>
14 14
15 <UIRef Id="WixUI_Minimal" /> 15 <ui:WixUI Id="WixUI_Minimal" />
16 </Package> 16 </Package>
17 17
18 <Fragment> 18 <Fragment>
diff --git a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs
index 8d5a856a..9eca9790 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs
+++ b/src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_Mondo/Package.wxs
@@ -1,4 +1,4 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> 1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200"> 2 <Package Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" InstallerVersion="200">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4 4
@@ -12,7 +12,7 @@
12 </Component> 12 </Component>
13 </ComponentGroup> 13 </ComponentGroup>
14 14
15 <UIRef Id="WixUI_Mondo" /> 15 <ui:WixUI Id="WixUI_Mondo" />
16 </Package> 16 </Package>
17 17
18 <Fragment> 18 <Fragment>
diff --git a/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs b/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs
index 778bfb64..4ab7ec3f 100644
--- a/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs
+++ b/src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs
@@ -7,8 +7,6 @@ namespace WixToolsetTest.UI
7 using System.Linq; 7 using System.Linq;
8 using WixBuildTools.TestSupport; 8 using WixBuildTools.TestSupport;
9 using WixToolset.Core.TestPackage; 9 using WixToolset.Core.TestPackage;
10 using WixToolset.Data;
11 using WixToolset.Data.Symbols;
12 using WixToolset.Data.WindowsInstaller; 10 using WixToolset.Data.WindowsInstaller;
13 using WixToolset.UI; 11 using WixToolset.UI;
14 using Xunit; 12 using Xunit;
@@ -22,11 +20,48 @@ namespace WixToolsetTest.UI
22 var bindFolder = TestData.Get(@"TestData\data"); 20 var bindFolder = TestData.Get(@"TestData\data");
23 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder }); 21 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
24 22
25 var results = build.BuildAndQuery(Build, "Property"); 23 var results = build.BuildAndQuery(Build, "Dialog", "CustomAction");
26 WixAssert.CompareLineByLine(new[] 24 Assert.Single(results, result => result.StartsWith("Dialog:AdvancedWelcomeEulaDlg\t"));
27 { 25 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerMachineFolder\t"));
28 "Property:WixUI_Mode\tAdvanced", 26 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerUserFolder\t"));
29 }, results.Where(s => s.StartsWith("Property:WixUI_Mode")).ToArray()); 27 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerMachineFolder\t"));
28 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerUserFolder\t"));
29 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIPrintEula\t65\tWixUiCa_X86\t"));
30 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIValidatePath\t65\tWixUiCa_X86\t"));
31 }
32
33 [Fact]
34 public void CanBuildUsingWixUIAdvancedX64()
35 {
36 var folder = TestData.Get(@"TestData\WixUI_Advanced");
37 var bindFolder = TestData.Get(@"TestData\data");
38 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
39
40 var results = build.BuildAndQuery(BuildX64, "Dialog", "CustomAction");
41 Assert.Single(results, result => result.StartsWith("Dialog:AdvancedWelcomeEulaDlg\t"));
42 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerMachineFolder\t"));
43 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerUserFolder\t"));
44 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerMachineFolder\t"));
45 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerUserFolder\t"));
46 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIPrintEula\t65\tWixUiCa_X64\t"));
47 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIValidatePath\t65\tWixUiCa_X64\t"));
48 }
49
50 [Fact]
51 public void CanBuildUsingWixUIAdvancedARM64()
52 {
53 var folder = TestData.Get(@"TestData\WixUI_Advanced");
54 var bindFolder = TestData.Get(@"TestData\data");
55 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
56
57 var results = build.BuildAndQuery(BuildARM64, "Dialog", "CustomAction");
58 Assert.Single(results, result => result.StartsWith("Dialog:AdvancedWelcomeEulaDlg\t"));
59 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerMachineFolder\t"));
60 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetDefaultPerUserFolder\t"));
61 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerMachineFolder\t"));
62 Assert.Single(results, result => result.StartsWith("CustomAction:WixSetPerUserFolder\t"));
63 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIPrintEula\t65\tWixUiCa_A64\t"));
64 Assert.Single(results, result => result.StartsWith("CustomAction:WixUIValidatePath\t65\tWixUiCa_A64\t"));
30 } 65 }
31 66
32 [Fact] 67 [Fact]
@@ -36,11 +71,10 @@ namespace WixToolsetTest.UI
36 var bindFolder = TestData.Get(@"TestData\data"); 71 var bindFolder = TestData.Get(@"TestData\data");
37 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder }); 72 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
38 73
39 var results = build.BuildAndQuery(Build, "Property"); 74 var results = build.BuildAndQuery(Build, "Dialog", "CustomAction");
40 WixAssert.CompareLineByLine(new[] 75 Assert.Single(results, result => result.StartsWith("Dialog:WelcomeDlg\t"));
41 { 76 Assert.Single(results, result => result.StartsWith("Dialog:CustomizeDlg\t"));
42 "Property:WixUI_Mode\tFeatureTree", 77 Assert.Empty(results.Where(result => result.StartsWith("Dialog:SetupTypeDlg\t")));
43 }, results.Where(s => s.StartsWith("Property:WixUI_Mode")).ToArray());
44 } 78 }
45 79
46 [Fact] 80 [Fact]
@@ -50,11 +84,8 @@ namespace WixToolsetTest.UI
50 var bindFolder = TestData.Get(@"TestData\data"); 84 var bindFolder = TestData.Get(@"TestData\data");
51 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder }); 85 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
52 86
53 var results = build.BuildAndQuery(Build, "Property"); 87 var results = build.BuildAndQuery(Build, "Dialog", "CustomAction");
54 WixAssert.CompareLineByLine(new[] 88 Assert.Single(results, result => result.StartsWith("Dialog:InstallDirDlg\t"));
55 {
56 "Property:WixUI_Mode\tInstallDir",
57 }, results.Where(s => s.StartsWith("Property:WixUI_Mode")).ToArray());
58 } 89 }
59 90
60 [Fact] 91 [Fact]
@@ -64,11 +95,8 @@ namespace WixToolsetTest.UI
64 var bindFolder = TestData.Get(@"TestData\data"); 95 var bindFolder = TestData.Get(@"TestData\data");
65 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder }); 96 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
66 97
67 var results = build.BuildAndQuery(Build, "Property"); 98 var results = build.BuildAndQuery(Build, "Dialog", "CustomAction");
68 WixAssert.CompareLineByLine(new[] 99 Assert.Single(results, result => result.StartsWith("Dialog:WelcomeEulaDlg\t"));
69 {
70 "Property:WixUI_Mode\tMinimal",
71 }, results.Where(s => s.StartsWith("Property:WixUI_Mode")).ToArray());
72 } 100 }
73 101
74 [Fact] 102 [Fact]
@@ -92,10 +120,8 @@ namespace WixToolsetTest.UI
92 }); 120 });
93 121
94 var wid = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb")); 122 var wid = WindowsInstallerData.Load(Path.Combine(intermediateFolder, @"bin\test.wixpdb"));
95 var propertyTable = wid.Tables["Property"]; 123 var dialogTable = wid.Tables["Dialog"];
96 124 var dialogRow = dialogTable.Rows.Single(r => r.GetPrimaryKey() == "WelcomeEulaDlg");
97 var propertyRow = propertyTable.Rows.Single(r => r.GetPrimaryKey() == "WixUI_Mode");
98 WixAssert.StringEqual("Minimal", propertyRow.FieldAsString(1));
99 } 125 }
100 } 126 }
101 127
@@ -106,11 +132,10 @@ namespace WixToolsetTest.UI
106 var bindFolder = TestData.Get(@"TestData\data"); 132 var bindFolder = TestData.Get(@"TestData\data");
107 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder }); 133 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
108 134
109 var results = build.BuildAndQuery(Build, "Property"); 135 var results = build.BuildAndQuery(Build, "Dialog", "CustomAction");
110 WixAssert.CompareLineByLine(new[] 136 Assert.Single(results, result => result.StartsWith("Dialog:WelcomeDlg\t"));
111 { 137 Assert.Single(results, result => result.StartsWith("Dialog:CustomizeDlg\t"));
112 "Property:WixUI_Mode\tMondo", 138 Assert.Single(results, result => result.StartsWith("Dialog:SetupTypeDlg\t"));
113 }, results.Where(s => s.StartsWith("Property:WixUI_Mode")).ToArray());
114 } 139 }
115 140
116 [Fact] 141 [Fact]
@@ -133,6 +158,18 @@ namespace WixToolsetTest.UI
133 .AssertSuccess(); 158 .AssertSuccess();
134 } 159 }
135 160
161 private static void BuildX64(string[] args)
162 {
163 var result = WixRunner.Execute(args.Concat(new[] { "-arch", "x64" }).ToArray())
164 .AssertSuccess();
165 }
166
167 private static void BuildARM64(string[] args)
168 {
169 var result = WixRunner.Execute(args.Concat(new[] { "-arch", "arm64" }).ToArray())
170 .AssertSuccess();
171 }
172
136 private static void BuildInGerman(string[] args) 173 private static void BuildInGerman(string[] args)
137 { 174 {
138 var localizedArgs = args.Append("-culture").Append("de-DE").ToArray(); 175 var localizedArgs = args.Append("-culture").Append("de-DE").ToArray();
diff --git a/src/ext/UI/wixext/UICompiler.cs b/src/ext/UI/wixext/UICompiler.cs
new file mode 100644
index 00000000..46b856c0
--- /dev/null
+++ b/src/ext/UI/wixext/UICompiler.cs
@@ -0,0 +1,118 @@
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.UI
4{
5 using System;
6 using System.Collections.Generic;
7 using System.Xml.Linq;
8 using WixToolset.Data;
9 using WixToolset.Data.Symbols;
10 using WixToolset.Extensibility;
11
12 /// <summary>
13 /// The decompiler for the WiX Toolset UI Extension.
14 /// </summary>
15 public sealed class UICompiler : BaseCompilerExtension
16 {
17 public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/ui";
18
19 /// <summary>
20 /// Processes an element for the Compiler.
21 /// </summary>
22 /// <param name="sourceLineNumbers">Source line number for the parent element.</param>
23 /// <param name="parentElement">Parent element of element to process.</param>
24 /// <param name="element">Element to process.</param>
25 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
26 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
27 {
28 switch (parentElement.Name.LocalName)
29 {
30 case "Fragment":
31 case "Module":
32 case "PatchFamily":
33 case "Package":
34 case "UI":
35 switch (element.Name.LocalName)
36 {
37 case "WixUI":
38 this.ParseWixUIElement(intermediate, section, element);
39 break;
40 default:
41 this.ParseHelper.UnexpectedElement(parentElement, element);
42 break;
43 }
44 break;
45 default:
46 this.ParseHelper.UnexpectedElement(parentElement, element);
47 break;
48 }
49 }
50
51 /// <summary>
52 /// Parses a WixUI element.
53 /// </summary>
54 private void ParseWixUIElement(Intermediate intermediate, IntermediateSection section, XElement element)
55 {
56 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
57 string id = null;
58
59 foreach (var attrib in element.Attributes())
60 {
61 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace)
62 {
63 switch (attrib.Name.LocalName)
64 {
65 case "Id":
66 id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
67 break;
68 default:
69 this.ParseHelper.UnexpectedAttribute(element, attrib);
70 break;
71 }
72 }
73 else
74 {
75 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib);
76 }
77 }
78
79 if (null == id)
80 {
81 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id"));
82 }
83 else
84 {
85 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, id);
86
87 // Because these custom actions are "scheduled" via `DoAction` control events, we have to create the
88 // custom action definitions here, so the `DoAction` references are static and the targets are
89 // dynamically created to properly reflect the platform-specific DLL and avoid having duplicate ids
90 // in the UI .wixlib.
91 var platform = this.Context.Platform == Platform.ARM64 ? "A64" : this.Context.Platform.ToString();
92 var source = $"WixUiCa_{platform}";
93
94 section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIPrintEula"))
95 {
96 TargetType = CustomActionTargetType.Dll,
97 Target = "PrintEula",
98 SourceType = CustomActionSourceType.Binary,
99 Source = source,
100 IgnoreResult = true,
101 ExecutionType = CustomActionExecutionType.Immediate,
102 });
103
104 section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIValidatePath"))
105 {
106 TargetType = CustomActionTargetType.Dll,
107 Target = "ValidatePath",
108 SourceType = CustomActionSourceType.Binary,
109 Source = source,
110 IgnoreResult = true,
111 ExecutionType = CustomActionExecutionType.Immediate,
112 });
113 }
114
115 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);
116 }
117 }
118}
diff --git a/src/ext/UI/wixext/UIExtensionFactory.cs b/src/ext/UI/wixext/UIExtensionFactory.cs
index 141aa39f..a16a9899 100644
--- a/src/ext/UI/wixext/UIExtensionFactory.cs
+++ b/src/ext/UI/wixext/UIExtensionFactory.cs
@@ -11,6 +11,7 @@ namespace WixToolset.UI
11 protected override IReadOnlyCollection<Type> ExtensionTypes => new[] 11 protected override IReadOnlyCollection<Type> ExtensionTypes => new[]
12 { 12 {
13 typeof(UIExtensionData), 13 typeof(UIExtensionData),
14 typeof(UICompiler),
14 }; 15 };
15 } 16 }
16} 17}
diff --git a/src/ext/UI/wixlib/Common_Platform.wxi b/src/ext/UI/wixlib/Common_Platform.wxi
index ffaa7114..0c03629c 100644
--- a/src/ext/UI/wixlib/Common_Platform.wxi
+++ b/src/ext/UI/wixlib/Common_Platform.wxi
@@ -2,18 +2,15 @@
2 2
3 3
4<Include xmlns="http://wixtoolset.org/schemas/v4/wxs"> 4<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 <?include caSuffix.wxi ?> 5 <?include ..\..\caDecor.wxi ?>
6 <Fragment>
7 <!-- print EULA functionality -->
8 <CustomAction Id="WixUIPrintEula$(var.Suffix)" DllEntry="PrintEula" Return="ignore" Execute="immediate" BinaryRef="WixUIWixca$(var.Suffix)" />
9 </Fragment>
10 6
11 <Fragment> 7 <!--
12 <!-- Validate install directory --> 8 Custom actions to print EULA amd validate install directories are defined
13 <CustomAction Id="WixUIValidatePath$(var.Suffix)" DllEntry="ValidatePath" Return="ignore" Execute="immediate" BinaryRef="WixUIWixca$(var.Suffix)" /> 9 in WixUIExtension compiler extension, to handle platform-specific custom
14 </Fragment> 10 actions referred to from `DoAction` control events.
11 -->
15 12
16 <Fragment> 13 <Fragment>
17 <Binary Id="WixUIWixca$(var.Suffix)" SourceFile="!(bindpath.$(var.platform))uica.dll" /> 14 <Binary Id="WixUiCa$(var.Suffix)" SourceFile="!(bindpath.$(var.platform))uica.dll" />
18 </Fragment> 15 </Fragment>
19</Include> 16</Include>
diff --git a/src/ext/UI/wixlib/Common_arm64.wxs b/src/ext/UI/wixlib/Common_arm64.wxs
new file mode 100644
index 00000000..61dd5ddd
--- /dev/null
+++ b/src/ext/UI/wixlib/Common_arm64.wxs
@@ -0,0 +1,7 @@
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
4<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 <?define platform=arm64 ?>
6 <?include Common_Platform.wxi ?>
7</Wix>
diff --git a/src/ext/UI/wixlib/Common_x64.wxs b/src/ext/UI/wixlib/Common_x64.wxs
new file mode 100644
index 00000000..89204605
--- /dev/null
+++ b/src/ext/UI/wixlib/Common_x64.wxs
@@ -0,0 +1,7 @@
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
4<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5 <?define platform=x64 ?>
6 <?include Common_Platform.wxi ?>
7</Wix>
diff --git a/src/ext/UI/wixlib/WixUI_Advanced.wxs b/src/ext/UI/wixlib/WixUI_Advanced.wxs
index 7d1f4df0..2ea7a97d 100644
--- a/src/ext/UI/wixlib/WixUI_Advanced.wxs
+++ b/src/ext/UI/wixlib/WixUI_Advanced.wxs
@@ -53,7 +53,6 @@ Todo:
53 <TextStyle Id="WixUI_Font_Emphasized" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Emphasized_Size)" Bold="yes" /> 53 <TextStyle Id="WixUI_Font_Emphasized" FaceName="!(loc.Advanced_Font_FaceName)" Size="!(loc.Advanced_Font_Emphasized_Size)" Bold="yes" />
54 54
55 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> 55 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
56 <Property Id="WixUI_Mode" Value="Advanced" />
57 56
58 <DialogRef Id="BrowseDlg" /> 57 <DialogRef Id="BrowseDlg" />
59 <DialogRef Id="DiskCostDlg" /> 58 <DialogRef Id="DiskCostDlg" />
diff --git a/src/ext/UI/wixlib/WixUI_FeatureTree.wxs b/src/ext/UI/wixlib/WixUI_FeatureTree.wxs
index e999f2fe..6f36bdb8 100644
--- a/src/ext/UI/wixlib/WixUI_FeatureTree.wxs
+++ b/src/ext/UI/wixlib/WixUI_FeatureTree.wxs
@@ -29,7 +29,6 @@ Patch dialog sequence:
29 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> 29 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
30 30
31 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> 31 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
32 <Property Id="WixUI_Mode" Value="FeatureTree" />
33 32
34 <DialogRef Id="ErrorDlg" /> 33 <DialogRef Id="ErrorDlg" />
35 <DialogRef Id="FatalError" /> 34 <DialogRef Id="FatalError" />
diff --git a/src/ext/UI/wixlib/WixUI_InstallDir.wxs b/src/ext/UI/wixlib/WixUI_InstallDir.wxs
index afe7820f..f8eb3b11 100644
--- a/src/ext/UI/wixlib/WixUI_InstallDir.wxs
+++ b/src/ext/UI/wixlib/WixUI_InstallDir.wxs
@@ -30,7 +30,6 @@ Patch dialog sequence:
30 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> 30 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
31 31
32 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> 32 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
33 <Property Id="WixUI_Mode" Value="InstallDir" />
34 33
35 <DialogRef Id="BrowseDlg" /> 34 <DialogRef Id="BrowseDlg" />
36 <DialogRef Id="DiskCostDlg" /> 35 <DialogRef Id="DiskCostDlg" />
diff --git a/src/ext/UI/wixlib/WixUI_Minimal.wxs b/src/ext/UI/wixlib/WixUI_Minimal.wxs
index 08dba96d..8ac9751f 100644
--- a/src/ext/UI/wixlib/WixUI_Minimal.wxs
+++ b/src/ext/UI/wixlib/WixUI_Minimal.wxs
@@ -24,7 +24,6 @@ Patch dialog sequence:
24 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> 24 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
25 25
26 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> 26 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
27 <Property Id="WixUI_Mode" Value="Minimal" />
28 27
29 <DialogRef Id="ErrorDlg" /> 28 <DialogRef Id="ErrorDlg" />
30 <DialogRef Id="FatalError" /> 29 <DialogRef Id="FatalError" />
diff --git a/src/ext/UI/wixlib/WixUI_Mondo.wxs b/src/ext/UI/wixlib/WixUI_Mondo.wxs
index 2d53b9dd..6a4b15b1 100644
--- a/src/ext/UI/wixlib/WixUI_Mondo.wxs
+++ b/src/ext/UI/wixlib/WixUI_Mondo.wxs
@@ -31,7 +31,6 @@ Patch dialog sequence:
31 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" /> 31 <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
32 32
33 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" /> 33 <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
34 <Property Id="WixUI_Mode" Value="Mondo" />
35 34
36 <DialogRef Id="ErrorDlg" /> 35 <DialogRef Id="ErrorDlg" />
37 <DialogRef Id="FatalError" /> 36 <DialogRef Id="FatalError" />
diff --git a/src/ext/UI/wixlib/caSuffix.wxi b/src/ext/UI/wixlib/caSuffix.wxi
deleted file mode 100644
index 18436269..00000000
--- a/src/ext/UI/wixlib/caSuffix.wxi
+++ /dev/null
@@ -1,27 +0,0 @@
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<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
4 <?ifndef platform ?>
5 <?error Required value "platform" not defined in include caSuffix.wxi ?>
6 <?endif?>
7
8 <?ifdef Suffix ?>
9 <?undef Suffix ?>
10 <?undef DeferredSuffix ?>
11 <?endif?>
12
13 <?if $(var.platform)="x86" ?>
14 <?define Suffix="" ?>
15 <?define DeferredSuffix="" ?>
16 <?endif?>
17
18 <?if $(var.platform)="x64" ?>
19 <?define Suffix="_x64" ?>
20 <?define DeferredSuffix="_64" ?>
21 <?endif?>
22
23 <?if $(var.platform)="arm" ?>
24 <?define Suffix="_ARM" ?>
25 <?define DeferredSuffix="_ARM" ?>
26 <?endif?>
27</Include>
diff --git a/src/ext/UI/wixlib/ui.wixproj b/src/ext/UI/wixlib/ui.wixproj
index 2b335f01..ead77af4 100644
--- a/src/ext/UI/wixlib/ui.wixproj
+++ b/src/ext/UI/wixlib/ui.wixproj
@@ -27,7 +27,9 @@
27 </ItemGroup> 27 </ItemGroup>
28 28
29 <ItemGroup> 29 <ItemGroup>
30 <ProjectReference Include="..\ca\uica.vcxproj" Properties="Platform=x86" ReferenceOutputAssembly="false" /> 30 <ProjectReference Include="..\ca\uica.vcxproj" Properties="Platform=x86" />
31 <ProjectReference Include="..\ca\uica.vcxproj" Properties="Platform=x64" />
32 <ProjectReference Include="..\ca\uica.vcxproj" Properties="Platform=ARM64" />
31 </ItemGroup> 33 </ItemGroup>
32 34
33 <ItemGroup> 35 <ItemGroup>