diff options
author | StefanStojanovic <stefan.stojanovic@janeasystems.com> | 2022-09-28 11:22:23 +0200 |
---|---|---|
committer | Bob Arnson <github@bobs.org> | 2022-09-28 09:47:35 -0400 |
commit | ec6b93c7d601db880d0765fe12abb07a5ec2928e (patch) | |
tree | 8556d37fa4f0505924cd31871236d79c8716f94d | |
parent | dfcd6728a9d56ac37a5daa8cbedabbf10c333773 (diff) | |
download | wix-ec6b93c7d601db880d0765fe12abb07a5ec2928e.tar.gz wix-ec6b93c7d601db880d0765fe12abb07a5ec2928e.tar.bz2 wix-ec6b93c7d601db880d0765fe12abb07a5ec2928e.zip |
Fix UICompiler custom actions duplication
For each ui:WixUI tag found, UICompiler adds PrintEula and ValidatePath
custom actions. This causes problems with duplicate symbols if 2 or more
such tags are used. This change makes sure that UI custom actions are
added only once in total.
-rw-r--r-- | src/ext/UI/wixext/UICompiler.cs | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/src/ext/UI/wixext/UICompiler.cs b/src/ext/UI/wixext/UICompiler.cs index 44ab4cdc..6fdb5bd9 100644 --- a/src/ext/UI/wixext/UICompiler.cs +++ b/src/ext/UI/wixext/UICompiler.cs | |||
@@ -17,6 +17,11 @@ namespace WixToolset.UI | |||
17 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/ui"; | 17 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/ui"; |
18 | 18 | ||
19 | /// <summary> | 19 | /// <summary> |
20 | /// Flag to prevent custom action symbols duplication. | ||
21 | /// </summary> | ||
22 | private bool customActionsAdded = false; | ||
23 | |||
24 | /// <summary> | ||
20 | /// Processes an element for the Compiler. | 25 | /// Processes an element for the Compiler. |
21 | /// </summary> | 26 | /// </summary> |
22 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | 27 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> |
@@ -88,33 +93,38 @@ namespace WixToolset.UI | |||
88 | { | 93 | { |
89 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, id); | 94 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixUI, id); |
90 | 95 | ||
91 | // Because these custom actions are "scheduled" via `DoAction` control events, we have to create the | 96 | if (!customActionsAdded) |
92 | // custom action definitions here, so the `DoAction` references are static and the targets are | ||
93 | // dynamically created to properly reflect the platform-specific DLL and avoid having duplicate ids | ||
94 | // in the UI .wixlib. | ||
95 | var platform = this.Context.Platform == Platform.ARM64 ? "A64" : this.Context.Platform.ToString(); | ||
96 | var source = $"WixUiCa_{platform}"; | ||
97 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, source); | ||
98 | |||
99 | section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIPrintEula")) | ||
100 | { | 97 | { |
101 | TargetType = CustomActionTargetType.Dll, | 98 | // Because these custom actions are "scheduled" via `DoAction` control events, we have to create the |
102 | Target = "PrintEula", | 99 | // custom action definitions here, so the `DoAction` references are static and the targets are |
103 | SourceType = CustomActionSourceType.Binary, | 100 | // dynamically created to properly reflect the platform-specific DLL and avoid having duplicate ids |
104 | Source = source, | 101 | // in the UI .wixlib. |
105 | IgnoreResult = true, | 102 | var platform = this.Context.Platform == Platform.ARM64 ? "A64" : this.Context.Platform.ToString(); |
106 | ExecutionType = CustomActionExecutionType.Immediate, | 103 | var source = $"WixUiCa_{platform}"; |
107 | }); | 104 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, source); |
108 | 105 | ||
109 | section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIValidatePath")) | 106 | section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIPrintEula")) |
110 | { | 107 | { |
111 | TargetType = CustomActionTargetType.Dll, | 108 | TargetType = CustomActionTargetType.Dll, |
112 | Target = "ValidatePath", | 109 | Target = "PrintEula", |
113 | SourceType = CustomActionSourceType.Binary, | 110 | SourceType = CustomActionSourceType.Binary, |
114 | Source = source, | 111 | Source = source, |
115 | IgnoreResult = true, | 112 | IgnoreResult = true, |
116 | ExecutionType = CustomActionExecutionType.Immediate, | 113 | ExecutionType = CustomActionExecutionType.Immediate, |
117 | }); | 114 | }); |
115 | |||
116 | section.AddSymbol(new CustomActionSymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WixUIValidatePath")) | ||
117 | { | ||
118 | TargetType = CustomActionTargetType.Dll, | ||
119 | Target = "ValidatePath", | ||
120 | SourceType = CustomActionSourceType.Binary, | ||
121 | Source = source, | ||
122 | IgnoreResult = true, | ||
123 | ExecutionType = CustomActionExecutionType.Immediate, | ||
124 | }); | ||
125 | |||
126 | customActionsAdded = true; | ||
127 | } | ||
118 | 128 | ||
119 | if (installDirectory != null) | 129 | if (installDirectory != null) |
120 | { | 130 | { |