From 13292da793c9e0792d3ecd86974304b8b2a51d7a Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 16 Nov 2022 20:27:48 -0500 Subject: Warn about unsuffixed custom action ids. Fixes https://github.com/wixtoolset/issues/issues/7018. --- src/wix/WixToolset.Converters/WixConverter.cs | 79 +++++++++++++++++++++- .../WixToolsetTest.Converters/ConverterFixture.cs | 32 +++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/src/wix/WixToolset.Converters/WixConverter.cs b/src/wix/WixToolset.Converters/WixConverter.cs index 941a5062..6c15b022 100644 --- a/src/wix/WixToolset.Converters/WixConverter.cs +++ b/src/wix/WixToolset.Converters/WixConverter.cs @@ -78,6 +78,7 @@ namespace WixToolset.Converters private static readonly XName BundleCustomDataElementName = WixNamespace + "BundleCustomData"; private static readonly XName BundleCustomDataRefElementName = WixNamespace + "BundleCustomDataRef"; private static readonly XName BundleElementElementName = WixNamespace + "BundleElement"; + private static readonly XName CustomElementName = WixNamespace + "Custom"; private static readonly XName CustomTableElementName = WixNamespace + "CustomTable"; private static readonly XName CustomTableRefElementName = WixNamespace + "CustomTableRef"; private static readonly XName CatalogElementName = WixNamespace + "Catalog"; @@ -97,7 +98,6 @@ namespace WixToolset.Converters private static readonly XName FileElementName = WixNamespace + "File"; private static readonly XName FragmentElementName = WixNamespace + "Fragment"; private static readonly XName FirewallRemoteAddressElementName = WixFirewallNamespace + "RemoteAddress"; - private static readonly XName GetCapabilitiesElementName = WixFirewallNamespace + "GetCapabilities"; private static readonly XName LaunchElementName = WixNamespace + "Launch"; private static readonly XName LevelElementName = WixNamespace + "Level"; private static readonly XName ExePackageElementName = WixNamespace + "ExePackage"; @@ -196,6 +196,65 @@ namespace WixToolset.Converters { "http://schemas.microsoft.com/wix/2006/WixUnit", "http://wixtoolset.org/schemas/v4/wixunit" }, }; + private static readonly Dictionary CustomActionIdsWithPlatformSuffix = new Dictionary() + { + { "ConfigureComPlusUninstall", "Wix4ConfigureComPlusUninstall_" }, + { "ConfigureComPlusInstall", "Wix4ConfigureComPlusInstall_" }, + { "WixDependencyRequire", "Wix4DependencyRequire_" }, + { "WixDependencyCheck", "Wix4DependencyCheck_" }, + { "WixQueryDirectXCaps", "Wix4QueryDirectXCaps_" }, + { "WixSchedFirewallExceptionsUninstall", "Wix4SchedFirewallExceptionsUninstall_" }, + { "WixSchedFirewallExceptionsInstall", "Wix4SchedFirewallExceptionsInstall_" }, + { "WixSchedHttpUrlReservationsUninstall", "Wix4SchedHttpUrlReservationsUninstall_" }, + { "WixSchedHttpUrlReservationsInstall", "Wix4SchedHttpUrlReservationsInstall_" }, + { "ConfigureIIs", "Wix4ConfigureIIs_" }, + { "UninstallCertificates", "Wix4UninstallCertificates_" }, + { "InstallCertificates", "Wix4_" }, + { "MessageQueuingUninstall", "Wix4MessageQueuingUninstall_" }, + { "MessageQueuingInstall", "Wix4_MessageQueuingInstall" }, + { "NetFxScheduleNativeImage", "Wix4NetFxScheduleNativeImage_" }, + { "NetFxExecuteNativeImageCommitUninstall", "Wix4NetFxExecuteNativeImageCommitUninstall_" }, + { "NetFxExecuteNativeImageUninstall", "Wix4NetFxExecuteNativeImageUninstall_" }, + { "NetFxExecuteNativeImageCommitInstall", "Wix4NetFxExecuteNativeImageCommitInstall_" }, + { "NetFxExecuteNativeImageInstall", "Wix4NetFxExecuteNativeImageInstall_" }, + { "UninstallSqlData", "Wix4UninstallSqlData_" }, + { "InstallSqlData", "Wix4InstallSqlData_" }, + { "WixCheckRebootRequired", "Wix4CheckRebootRequired_" }, + { "WixCloseApplications", "Wix4CloseApplications_" }, + { "WixRegisterRestartResources", "Wix4RegisterRestartResources_" }, + { "ConfigureUsers", "Wix4ConfigureUsers_" }, + { "ConfigureSmbInstall", "Wix4ConfigureSmbInstall_" }, + { "ConfigureSmbUninstall", "Wix4ConfigureSmbUninstall_" }, + { "InstallPerfCounterData", "Wix4InstallPerfCounterData_" }, + { "UninstallPerfCounterData", "Wix4UninstallPerfCounterData_" }, + { "ConfigurePerfmonInstall", "Wix4ConfigurePerfmonInstall_" }, + { "ConfigurePerfmonUninstall", "Wix4ConfigurePerfmonUninstall_" }, + { "ConfigurePerfmonManifestRegister", "Wix4ConfigurePerfmonManifestRegister_" }, + { "ConfigurePerfmonManifestUnregister", "Wix4ConfigurePerfmonManifestUnregister_" }, + { "ConfigureEventManifestRegister", "Wix4ConfigureEventManifestRegister_" }, + { "ConfigureEventManifestUnregister", "Wix4ConfigureEventManifestUnregister_" }, + { "SchedServiceConfig", "Wix4SchedServiceConfig_" }, + { "SchedXmlFile", "Wix4SchedXmlFile_" }, + { "SchedXmlConfig", "Wix4SchedXmlConfig_" }, + { "WixSchedInternetShortcuts", "Wix4SchedInternetShortcuts_" }, + { "WixRollbackInternetShortcuts", "Wix4RollbackInternetShortcuts_" }, + { "WixCreateInternetShortcuts", "Wix4CreateInternetShortcuts_" }, + { "WixQueryOsInfo", "Wix4QueryOsInfo_" }, + { "WixQueryOsDirs", "Wix4QueryOsDirs_" }, + { "WixQueryOsWellKnownSID", "Wix4QueryOsWellKnownSID_" }, + { "WixQueryOsDriverInfo", "Wix4QueryOsDriverInfo_" }, + { "WixQueryNativeMachine", "Wix4QueryNativeMachine_" }, + { "WixFailWhenDeferred", "Wix4FailWhenDeferred_" }, + { "WixWaitForEvent", "Wix4WaitForEvent_" }, + { "WixWaitForEventDeferred", "Wix4WaitForEventDeferred_" }, + { "WixExitEarlyWithSuccess", "Wix4ExitEarlyWithSuccess_" }, + { "WixBroadcastSettingChange", "Wix4BroadcastSettingChange_" }, + { "WixBroadcastEnvironmentChange", "Wix4BroadcastEnvironmentChange_" }, + { "SchedSecureObjects", "Wix4SchedSecureObjects_" }, + { "SchedSecureObjectsRollback", "Wix4SchedSecureObjectsRollback_" }, + { "VSFindInstances", "Wix4VSFindInstances_" }, + }; + private readonly Dictionary> ConvertElementMapping; private readonly Regex DeprecatedPrefixRegex = new Regex(@"(?<=(^|[^\$])(\$\$)*)\$(?=\(loc\.[^.].*\))", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture); @@ -224,6 +283,7 @@ namespace WixToolset.Converters { WixConverter.ColumnElementName, this.ConvertColumnElement }, { WixConverter.ComponentElementName, this.ConvertComponentElement }, { WixConverter.ControlElementName, this.ConvertControlElement }, + { WixConverter.CustomElementName, this.ConvertCustomElement }, { WixConverter.CustomActionElementName, this.ConvertCustomActionElement }, { WixConverter.CustomTableElementName, this.ConvertCustomTableElement }, { WixConverter.DataElementName, this.ConvertDataElement }, @@ -840,6 +900,18 @@ namespace WixToolset.Converters } } + private void ConvertCustomElement(XElement element) + { + var actionId = element.Attribute("Action")?.Value; + + if (actionId != null + && CustomActionIdsWithPlatformSuffix.TryGetValue(actionId, out var replacementId)) + { + this.OnError(ConverterTestType.CustomActionIdsIncludePlatformSuffix, element, + $"Custom action ids have changed in WiX v4 extensions to support platform-specific custom actions. The platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom action '{actionId}', you must use the new custom action id '{replacementId}'."); + } + } + private void ConvertCustomTableElement(XElement element) { var bootstrapperApplicationData = element.Attribute("BootstrapperApplicationData"); @@ -3056,6 +3128,11 @@ namespace WixToolset.Converters /// Namespace should be defined on the root. The '{0}' namespace was move to the root element. /// MoveNamespacesToRoot, + + /// + /// Custom action ids have changed in WiX v4 extensions. Because WiX v4 has platform-specific custom actions, the platform is applied as a suffix: _X86, _X64, _A64 (Arm64). When manually rescheduling custom actions, you must use the new custom action id, with platform suffix. + /// + CustomActionIdsIncludePlatformSuffix, } } } diff --git a/src/wix/test/WixToolsetTest.Converters/ConverterFixture.cs b/src/wix/test/WixToolsetTest.Converters/ConverterFixture.cs index bdc67431..375b6608 100644 --- a/src/wix/test/WixToolsetTest.Converters/ConverterFixture.cs +++ b/src/wix/test/WixToolsetTest.Converters/ConverterFixture.cs @@ -512,5 +512,37 @@ namespace WixToolsetTest.Converters Assert.Equal(3, errors); WixAssert.CompareLineByLine(expected, actual); } + + [Fact] + public void CantConvertStandardCustomActionRescheduling() + { + var parse = String.Join(Environment.NewLine, + "", + " ", + " ", + " ", + ""); + + var expected = new[] + { + "", + " ", + " ", + " ", + "", + }; + + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); + + var messaging = new MockMessaging(); + var converter = new WixConverter(messaging, 2, null, null); + + var errors = converter.ConvertDocument(document); + + var actual = UnformattedDocumentLines(document); + + Assert.Equal(2, errors); + WixAssert.CompareLineByLine(expected, actual); + } } } -- cgit v1.2.3-55-g6feb