@joebigelow / wix / commits / 7ff5ffb7

Replace Win64 attribute with Bitness attribute

Rob Mensching committed Feb 11, 2021 at 13:45 UTC 7ff5ffb753fc0f576c24b0faa5d03b6d85b0f238
2 files changed +235 -1
src/WixToolset.Converters/WixConverter.cs
+54 -1
@@ -43,6 +43,7 @@ namespace WixToolset.Converters
43 private static readonly XName BootstrapperApplicationElementName = WixNamespace + "BootstrapperApplication";
44 private static readonly XName BootstrapperApplicationDllElementName = WixNamespace + "BootstrapperApplicationDll";
45 private static readonly XName BootstrapperApplicationRefElementName = WixNamespace + "BootstrapperApplicationRef";
46 + private static readonly XName ApprovedExeForElevationElementName = WixNamespace + "ApprovedExeForElevation";
47 private static readonly XName EmbeddedChainerElementName = WixNamespace + "EmbeddedChainer";
48 private static readonly XName CatalogElementName = WixNamespace + "Catalog";
49 private static readonly XName ColumnElementName = WixNamespace + "Column";
@@ -73,6 +74,7 @@ namespace WixToolset.Converters
74 private static readonly XName PublishElementName = WixNamespace + "Publish";
75 private static readonly XName MultiStringValueElementName = WixNamespace + "MultiStringValue";
76 private static readonly XName RemotePayloadElementName = WixNamespace + "RemotePayload";
77 + private static readonly XName RegistrySearchElementName = WixNamespace + "RegistrySearch";
78 private static readonly XName RequiredPrivilegeElementName = WixNamespace + "RequiredPrivilege";
79 private static readonly XName ServiceArgumentElementName = WixNamespace + "ServiceArgument";
80 private static readonly XName SetDirectoryElementName = WixNamespace + "SetDirectory";
@@ -151,6 +153,7 @@ namespace WixToolset.Converters
153 { WixConverter.InstallExecuteSequenceElementName, this.ConvertSequenceElement },
154 { WixConverter.BootstrapperApplicationElementName, this.ConvertBootstrapperApplicationElement },
155 { WixConverter.BootstrapperApplicationRefElementName, this.ConvertBootstrapperApplicationRefElement },
156 + { WixConverter.ApprovedExeForElevationElementName, this.ConvertApprovedExeForElevationElement },
157 { WixConverter.CatalogElementName, this.ConvertCatalogElement },
158 { WixConverter.ColumnElementName, this.ConvertColumnElement },
159 { WixConverter.CustomTableElementName, this.ConvertCustomTableElement },
@@ -175,6 +178,7 @@ namespace WixToolset.Converters
178 { WixConverter.ProgressTextElementName, this.ConvertProgressTextElement },
179 { WixConverter.PublishElementName, this.ConvertPublishElement },
180 { WixConverter.MultiStringValueElementName, this.ConvertMultiStringValueElement },
181 + { WixConverter.RegistrySearchElementName, this.ConvertRegistrySearchElement },
182 { WixConverter.RemotePayloadElementName, this.ConvertRemotePayloadElement },
183 { WixConverter.RequiredPrivilegeElementName, this.ConvertRequiredPrivilegeElement },
184 { WixConverter.CustomActionElementName, this.ConvertCustomActionElement },
@@ -625,6 +629,20 @@ namespace WixToolset.Converters
629 }
630 }
631
632 + private void ConvertApprovedExeForElevationElement(XElement element)
633 + {
634 + if (this.SourceVersion < 4)
635 + {
636 + var win64 = element.Attribute("Win64");
637 + if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead."))
638 + {
639 + var value = win64.Value;
640 + element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32"));
641 + win64.Remove();
642 + }
643 + }
644 + }
645 +
646 private void ConvertBalBootstrapperApplicationRef(XElement element, string theme, XName balBAElementName, XName oldBalBAElementName = null)
647 {
648 var xBalBa = element.Element(oldBalBAElementName ?? balBAElementName);
@@ -733,6 +751,14 @@ namespace WixToolset.Converters
751 xCondition.Remove();
752 }
753 }
754 +
755 + var win64 = element.Attribute("Win64");
756 + if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead."))
757 + {
758 + var value = win64.Value;
759 + element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32"));
760 + win64.Remove();
761 + }
762 }
763
764 private void ConvertDirectoryElement(XElement element)
@@ -1071,6 +1097,20 @@ namespace WixToolset.Converters
1097 }
1098 }
1099
1100 + private void ConvertRegistrySearchElement(XElement element)
1101 + {
1102 + if (this.SourceVersion < 4)
1103 + {
1104 + var win64 = element.Attribute("Win64");
1105 + if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead."))
1106 + {
1107 + var value = win64.Value;
1108 + element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32"));
1109 + win64.Remove();
1110 + }
1111 + }
1112 + }
1113 +
1114 private void ConvertRequiredPrivilegeElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Name");
1115
1116 private void ConvertRowElement(XElement element) => this.ConvertInnerTextToAttribute(element, "Value");
@@ -1241,7 +1281,7 @@ namespace WixToolset.Converters
1281 var inheritable = element.Parent.Name == CreateFolderElementName;
1282 if (!inheritable)
1283 {
1244 - if (this.OnError(ConverterTestType.AssignPermissionExInheritable, element, "The PermissionEx Inheritable attribute is being set to 'no' to ensure it remains the same as the v3 default"))
1284 + if (this.OnError(ConverterTestType.AssignPermissionExInheritable, element, "The PermissionEx Inheritable attribute is being set to 'no' to ensure it remains the same as the v3 default."))
1285 {
1286 element.Add(new XAttribute("Inheritable", "no"));
1287 }
@@ -1253,6 +1293,14 @@ namespace WixToolset.Converters
1293 {
1294 if (this.SourceVersion < 4)
1295 {
1296 + var win64 = element.Attribute("Win64");
1297 + if (win64 != null && this.OnError(ConverterTestType.Win64AttributeRenamed, element, "The Win64 attribute has been renamed. Use the Bitness attribute instead."))
1298 + {
1299 + var value = win64.Value;
1300 + element.Add(new XAttribute("Bitness", value == "yes" ? "always64" : "always32"));
1301 + win64.Remove();
1302 + }
1303 +
1304 var result = element.Attribute("Result")?.Value;
1305 if (result == null || result == "value")
1306 {
@@ -1742,6 +1790,11 @@ namespace WixToolset.Converters
1790 /// The ExePackage elements "XxxCommand" attributes have been renamed to "XxxArguments".
1791 /// </summary>
1792 RenameExePackageCommandToArguments,
1793 +
1794 + /// <summary>
1795 + /// The Win64 attribute has been renamed. Use the Bitness attribute instead.
1796 + /// </summary>
1797 + Win64AttributeRenamed,
1798 }
1799 }
1800 }
src/test/WixToolsetTest.Converters/BitnessFixture.cs new
+181
@@ -0,0 +1,181 @@
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 +namespace WixToolsetTest.Converters
4 +{
5 + using System;
6 + using System.Xml.Linq;
7 + using WixBuildTools.TestSupport;
8 + using WixToolset.Converters;
9 + using WixToolsetTest.Converters.Mocks;
10 + using Xunit;
11 +
12 + public class BitnessFixture : BaseConverterFixture
13 + {
14 + [Fact]
15 + public void FixComponentBitness()
16 + {
17 + var parse = String.Join(Environment.NewLine,
18 + "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
19 + "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
20 + " <Fragment>",
21 + " <Component>",
22 + " <File Source='default.exe' />",
23 + " </Component>",
24 + " <Component Win64='no'>",
25 + " <File Source='32bit.exe' />",
26 + " </Component>",
27 + " <Component Win64='yes'>",
28 + " <File Source='64bit.exe' />",
29 + " </Component>",
30 + " </Fragment>",
31 + "</Wix>");
32 +
33 + var expected = new[]
34 + {
35 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
36 + " <Fragment>",
37 + " <Component>",
38 + " <File Id=\"default.exe\" Source=\"default.exe\" />",
39 + " </Component>",
40 + " <Component Bitness=\"always32\">",
41 + " <File Id=\"_32bit.exe\" Source=\"32bit.exe\" />",
42 + " </Component>",
43 + " <Component Bitness=\"always64\">",
44 + " <File Id=\"_64bit.exe\" Source=\"64bit.exe\" />",
45 + " </Component>",
46 + " </Fragment>",
47 + "</Wix>"
48 + };
49 +
50 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
51 +
52 + var messaging = new MockMessaging();
53 + var converter = new WixConverter(messaging, 2, null, null);
54 +
55 + var errors = converter.ConvertDocument(document);
56 + Assert.Equal(7, errors);
57 +
58 + var actualLines = UnformattedDocumentLines(document);
59 + WixAssert.CompareLineByLine(expected, actualLines);
60 + }
61 +
62 + [Fact]
63 + public void FixRegistrySearchBitness()
64 + {
65 + var parse = String.Join(Environment.NewLine,
66 + "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
67 + "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
68 + " <Fragment>",
69 + " <Property Id='BITNESSDEFAULT'>",
70 + " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw'></RegistrySearch>",
71 + " </Property>",
72 + " <Property Id='BITNESS32'>",
73 + " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw' Win64='no'></RegistrySearch>",
74 + " </Property>",
75 + " <Property Id='BITNESS64'>",
76 + " <RegistrySearch Id='SampleRegSearch' Root='HKLM' Key='SampleReg' Type='raw' Win64='yes'></RegistrySearch>",
77 + " </Property>",
78 + " </Fragment>",
79 + "</Wix>");
80 +
81 + var expected = new[]
82 + {
83 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
84 + " <Fragment>",
85 + " <Property Id=\"BITNESSDEFAULT\">",
86 + " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\"></RegistrySearch>",
87 + " </Property>",
88 + " <Property Id=\"BITNESS32\">",
89 + " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\" Bitness=\"always32\"></RegistrySearch>",
90 + " </Property>",
91 + " <Property Id=\"BITNESS64\">",
92 + " <RegistrySearch Id=\"SampleRegSearch\" Root=\"HKLM\" Key=\"SampleReg\" Type=\"raw\" Bitness=\"always64\"></RegistrySearch>",
93 + " </Property>",
94 + " </Fragment>",
95 + "</Wix>"
96 + };
97 +
98 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
99 +
100 + var messaging = new MockMessaging();
101 + var converter = new WixConverter(messaging, 2, null, null);
102 +
103 + var errors = converter.ConvertDocument(document);
104 + Assert.Equal(4, errors);
105 +
106 + var actualLines = UnformattedDocumentLines(document);
107 + WixAssert.CompareLineByLine(expected, actualLines);
108 + }
109 +
110 + [Fact]
111 + public void FixUtilRegistrySearchBitness()
112 + {
113 + var parse = String.Join(Environment.NewLine,
114 + "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>",
115 + " <Fragment>",
116 + " <util:RegistrySearch Id='RegValue' Root='HKLM' Key='Converter' Variable='Test' />",
117 + " <util:RegistrySearch Id='RegValue2' Root='HKLM' Key='Converter' Variable='Test' Result='value' Win64='no' />",
118 + " <util:RegistrySearch Id='RegValue3' Root='HKLM' Key='Converter' Variable='Test' Result='exists' Win64='yes' />",
119 + " </Fragment>",
120 + "</Wix>");
121 +
122 + var expected = new[]
123 + {
124 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">",
125 + " <Fragment>",
126 + " <util:RegistrySearch Id=\"RegValue\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" />",
127 + " <util:RegistrySearch Id=\"RegValue2\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"value\" Bitness=\"always32\" />",
128 + " <util:RegistrySearch Id=\"RegValue3\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"exists\" Bitness=\"always64\" />",
129 + " </Fragment>",
130 + "</Wix>"
131 + };
132 +
133 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
134 +
135 + var messaging = new MockMessaging();
136 + var converter = new WixConverter(messaging, 2, null, null);
137 +
138 + var errors = converter.ConvertDocument(document);
139 + Assert.Equal(6, errors);
140 +
141 + var actualLines = UnformattedDocumentLines(document);
142 + WixAssert.CompareLineByLine(expected, actualLines);
143 + }
144 +
145 + [Fact]
146 + public void FixApprovedExeBitness()
147 + {
148 + var parse = String.Join(Environment.NewLine,
149 + "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
150 + "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>",
151 + " <Bundle>",
152 + " <ApprovedExeForElevation Id='Default' Key='WixToolset\\BurnTesting' Value='Test' />",
153 + " <ApprovedExeForElevation Id='Bitness32' Key='WixToolset\\BurnTesting' Value='Test' Win64='no' />",
154 + " <ApprovedExeForElevation Id='Bitness64' Key='WixToolset\\BurnTesting' Value='Test' Win64='yes' />",
155 + " </Bundle>",
156 + "</Wix>");
157 +
158 + var expected = new[]
159 + {
160 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
161 + " <Bundle>",
162 + " <ApprovedExeForElevation Id=\"Default\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" />",
163 + " <ApprovedExeForElevation Id=\"Bitness32\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" Bitness=\"always32\" />",
164 + " <ApprovedExeForElevation Id=\"Bitness64\" Key=\"WixToolset\\BurnTesting\" Value=\"Test\" Bitness=\"always64\" />",
165 + " </Bundle>",
166 + "</Wix>"
167 + };
168 +
169 + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo);
170 +
171 + var messaging = new MockMessaging();
172 + var converter = new WixConverter(messaging, 2, null, null);
173 +
174 + var errors = converter.ConvertDocument(document);
175 + Assert.Equal(4, errors);
176 +
177 + var actualLines = UnformattedDocumentLines(document);
178 + WixAssert.CompareLineByLine(expected, actualLines);
179 + }
180 + }
181 +}