From a34b060e7b1375be7c8c557a985b484155ff2702 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 12 Jul 2020 22:40:30 -0400 Subject: Add elements to reference platform-specific extension custom actions. --- .../TestData/Queries/Package.en-us.wxl | 11 + .../TestData/Queries/Package.wxs | 26 +++ .../TestData/Queries/PackageComponents.wxs | 9 + .../TestData/Queries/example.txt | 1 + .../WixToolsetTest.Util/UtilExtensionFixture.cs | 18 ++ .../WixToolsetTest.Util/WixToolsetTest.Util.csproj | 4 + src/wixext/UtilCompiler.cs | 85 +++++++ src/wixext/util.xsd | 121 ++++++++++ src/wixlib/UtilExtension.wxs | 258 --------------------- src/wixlib/UtilExtension_Platform.wxi | 48 ++++ 10 files changed, 323 insertions(+), 258 deletions(-) create mode 100644 src/test/WixToolsetTest.Util/TestData/Queries/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Util/TestData/Queries/Package.wxs create mode 100644 src/test/WixToolsetTest.Util/TestData/Queries/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.Util/TestData/Queries/example.txt diff --git a/src/test/WixToolsetTest.Util/TestData/Queries/Package.en-us.wxl b/src/test/WixToolsetTest.Util/TestData/Queries/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/Queries/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Util/TestData/Queries/Package.wxs b/src/test/WixToolsetTest.Util/TestData/Queries/Package.wxs new file mode 100644 index 00000000..7f6cd7fa --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/Queries/Package.wxs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Util/TestData/Queries/PackageComponents.wxs b/src/test/WixToolsetTest.Util/TestData/Queries/PackageComponents.wxs new file mode 100644 index 00000000..e2dce4ae --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/Queries/PackageComponents.wxs @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/test/WixToolsetTest.Util/TestData/Queries/example.txt b/src/test/WixToolsetTest.Util/TestData/Queries/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.Util/TestData/Queries/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs index 78a9f967..848e4aa2 100644 --- a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs @@ -132,6 +132,24 @@ namespace WixToolsetTest.Util }, results.OrderBy(s => s).ToArray()); } + [Fact] + public void CanBuildWithQueries() + { + var folder = TestData.Get(@"TestData\Queries"); + var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(BuildARM64, "Binary", "CustomAction"); + Assert.Equal(new[] + { + "Binary:Wix4UtilCA_A64\t[Binary data]", + "CustomAction:Wix4BroadcastEnvironmentChange_A64\t65\tWix4UtilCA_A64\tWixBroadcastEnvironmentChange\t", + "CustomAction:Wix4BroadcastSettingChange_A64\t65\tWix4UtilCA_A64\tWixBroadcastSettingChange\t", + "CustomAction:Wix4CheckRebootRequired_A64\t65\tWix4UtilCA_A64\tWixCheckRebootRequired\t", + "CustomAction:Wix4QueryOsDriverInfo_A64\t257\tWix4UtilCA_A64\tWixQueryOsDriverInfo\t", + "CustomAction:Wix4QueryOsInfo_A64\t257\tWix4UtilCA_A64\tWixQueryOsInfo\t", + }, results.OrderBy(s => s).ToArray()); + } + [Fact] public void CanBuildBundleWithSearches() { diff --git a/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj b/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj index fcac4644..f2d5c486 100644 --- a/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj +++ b/src/test/WixToolsetTest.Util/WixToolsetTest.Util.csproj @@ -39,6 +39,10 @@ + + + + diff --git a/src/wixext/UtilCompiler.cs b/src/wixext/UtilCompiler.cs index 79dbbc6d..fdc1c9eb 100644 --- a/src/wixext/UtilCompiler.cs +++ b/src/wixext/UtilCompiler.cs @@ -233,6 +233,19 @@ namespace WixToolset.Util case "User": this.ParseUserElement(intermediate, section, element, null); break; + case "BroadcastEnvironmentChange": + case "BroadcastSettingChange": + case "CheckRebootRequired": + case "ExitEarlyWithSuccess": + case "FailWhenDeferred": + case "QueryWindowsDirectories": + case "QueryWindowsDriverInfo": + case "QueryWindowsSuiteInfo": + case "QueryWindowsWellKnownSIDs": + case "WaitForEvent": + case "WaitForEventDeferred": + this.AddCustomActionReference(intermediate, section, element, parentElement); + break; case "ComponentSearch": case "ComponentSearchRef": case "DirectorySearch": @@ -340,6 +353,24 @@ namespace WixToolset.Util break; } break; + case "UI": + switch (element.Name.LocalName) + { + case "BroadcastEnvironmentChange": + case "BroadcastSettingChange": + case "CheckRebootRequired": + case "ExitEarlyWithSuccess": + case "FailWhenDeferred": + case "QueryWindowsDirectories": + case "QueryWindowsDriverInfo": + case "QueryWindowsSuiteInfo": + case "QueryWindowsWellKnownSIDs": + case "WaitForEvent": + case "WaitForEventDeferred": + this.AddCustomActionReference(intermediate, section, element, parentElement); + break; + } + break; default: this.ParseHelper.UnexpectedElement(parentElement, element); break; @@ -348,6 +379,60 @@ namespace WixToolset.Util return possibleKeyPath; } + private void AddCustomActionReference(Intermediate intermediate, IntermediateSection section, XElement element, XElement parentElement) + { + // These elements are not supported for bundles. + if (parentElement.Name.LocalName == "Bundle") + { + this.ParseHelper.UnexpectedElement(parentElement, element); + return; + } + + var customAction = element.Name.LocalName; + switch (element.Name.LocalName) + { + case "BroadcastEnvironmentChange": + case "BroadcastSettingChange": + case "CheckRebootRequired": + case "ExitEarlyWithSuccess": + case "FailWhenDeferred": + case "WaitForEvent": + case "WaitForEventDeferred": + //default: customAction = element.Name.LocalName; + break; + case "QueryWindowsDirectories": + customAction = "QueryOsDirs"; + break; + case "QueryWindowsDriverInfo": + customAction = "QueryOsDriverInfo"; + break; + case "QueryWindowsSuiteInfo": + customAction = "QueryOsInfo"; + break; + case "QueryWindowsWellKnownSIDs": + customAction = "QueryOsWellKnownSID"; + break; + } + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + // no attributes today + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, customAction, this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64); + } + /// /// Parses the common search attributes shared across all searches. /// diff --git a/src/wixext/util.xsd b/src/wixext/util.xsd index b6f0365b..133a93fa 100644 --- a/src/wixext/util.xsd +++ b/src/wixext/util.xsd @@ -1586,6 +1586,127 @@ + + + Schedules the BroadcastEnvironmentChange custom action for the current platform. + + + + + + + + + + + Schedules the BroadcastSettingChange custom action for the current platform. + + + + + + + + + + + Schedules the CheckRebootRequired custom action for the current platform. + + + + + + + + + + + Schedules the ExitEarlyWithSuccess custom action for the current platform. + + + + + + + + + + + Schedules the FailWhenDeferred custom action for the current platform. + + + + + + + + + + Schedules the WaitForEvent custom action for the current platform. + + + + + + + + + + + Schedules the WaitForEventDeferred custom action for the current platform. + + + + + + + + + + + Schedules the QueryOsDirs custom action for the current platform. + + + + + + + + + + + Schedules the QueryOsDriverInfo custom action for the current platform. + + + + + + + + + + + Schedules the QueryOsInfo custom action for the current platform. + + + + + + + + + + + Schedules the QueryOsWellKnownSID custom action for the current platform. + + + + + + + + + diff --git a/src/wixlib/UtilExtension.wxs b/src/wixlib/UtilExtension.wxs index 2e9ad272..fccba7bf 100644 --- a/src/wixlib/UtilExtension.wxs +++ b/src/wixlib/UtilExtension.wxs @@ -62,264 +62,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/UtilExtension_Platform.wxi b/src/wixlib/UtilExtension_Platform.wxi index c557e04b..5fb1d0ae 100644 --- a/src/wixlib/UtilExtension_Platform.wxi +++ b/src/wixlib/UtilExtension_Platform.wxi @@ -299,6 +299,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb