@joebigelow / wix / commits / d7d4243b

Add WixUI/@InstallDirectory to simplify authoring.

Fixes https://github.com/wixtoolset/issues/issues/6926.

Bob Arnson committed Sep 22, 2022 at 21:26 UTC d7d4243b78ca816bd6beb33b499a3b0c85b5a53d
3 files changed +19 -3
src/ext/UI/test/WixToolsetTest.UI/TestData/WixUI_InstallDir/Package.wxs
+2 -2
@@ -1,4 +1,4 @@
1 -<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
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">
3 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4
@@ -12,7 +12,7 @@
12 </Component>
13 </ComponentGroup>
14
15 - <ui:WixUI Id="WixUI_InstallDir" />
15 + <ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
16 </Package>
17
18 <Fragment>
src/ext/UI/test/WixToolsetTest.UI/UIExtensionFixture.cs
+5 -1
@@ -138,7 +138,7 @@ namespace WixToolsetTest.UI
138 var bindFolder = TestData.Get(@"TestData\data");
139 var build = new Builder(folder, typeof(UIExtensionFactory), new[] { bindFolder });
140
141 - var results = build.BuildAndQuery(Build, "Binary", "Dialog", "CustomAction");
141 + var results = build.BuildAndQuery(Build, "Binary", "Dialog", "CustomAction", "Property");
142 Assert.Single(results, result => result.StartsWith("Dialog:InstallDirDlg\t"));
143 WixAssert.CompareLineByLine(new[]
144 {
@@ -155,6 +155,10 @@ namespace WixToolsetTest.UI
155 "CustomAction:WixUIPrintEula\t65\tWixUiCa_X86\tPrintEula\t",
156 "CustomAction:WixUIValidatePath\t65\tWixUiCa_X86\tValidatePath\t",
157 }, results.Where(r => r.StartsWith("CustomAction:")).ToArray());
158 + WixAssert.CompareLineByLine(new[]
159 + {
160 + "Property:WIXUI_INSTALLDIR\tINSTALLFOLDER",
161 + }, results.Where(r => r.StartsWith("Property:WIXUI")).ToArray());
162 }
163
164 [Fact]
src/ext/UI/wixext/UICompiler.cs
+12
@@ -55,6 +55,7 @@ namespace WixToolset.UI
55 {
56 var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element);
57 string id = null;
58 + string installDirectory = null;
59
60 foreach (var attrib in element.Attributes())
61 {
@@ -65,6 +66,9 @@ namespace WixToolset.UI
66 case "Id":
67 id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
68 break;
69 + case "InstallDirectory":
70 + installDirectory = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
71 + break;
72 default:
73 this.ParseHelper.UnexpectedAttribute(element, attrib);
74 break;
@@ -111,6 +115,14 @@ namespace WixToolset.UI
115 IgnoreResult = true,
116 ExecutionType = CustomActionExecutionType.Immediate,
117 });
118 +
119 + if (installDirectory != null)
120 + {
121 + section.AddSymbol(new PropertySymbol(sourceLineNumbers, new Identifier(AccessModifier.Global, "WIXUI_INSTALLDIR"))
122 + {
123 + Value = installDirectory
124 + });
125 + }
126 }
127
128 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element);