diff options
Diffstat (limited to 'src')
3 files changed, 189 insertions, 2 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 6080eeb9..e42d0605 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs | |||
| @@ -105,6 +105,7 @@ namespace WixToolset.Converters | |||
| 105 | private static readonly XName PermissionExElementName = WixNamespace + "PermissionEx"; | 105 | private static readonly XName PermissionExElementName = WixNamespace + "PermissionEx"; |
| 106 | private static readonly XName ProductElementName = WixNamespace + "Product"; | 106 | private static readonly XName ProductElementName = WixNamespace + "Product"; |
| 107 | private static readonly XName ProgressTextElementName = WixNamespace + "ProgressText"; | 107 | private static readonly XName ProgressTextElementName = WixNamespace + "ProgressText"; |
| 108 | private static readonly XName PropertyRefElementName = WixNamespace + "PropertyRef"; | ||
| 108 | private static readonly XName PublishElementName = WixNamespace + "Publish"; | 109 | private static readonly XName PublishElementName = WixNamespace + "Publish"; |
| 109 | private static readonly XName ProvidesElementName = WixNamespace + "Provides"; | 110 | private static readonly XName ProvidesElementName = WixNamespace + "Provides"; |
| 110 | private static readonly XName RequiresElementName = WixNamespace + "Requires"; | 111 | private static readonly XName RequiresElementName = WixNamespace + "Requires"; |
| @@ -138,6 +139,7 @@ namespace WixToolset.Converters | |||
| 138 | private static readonly XName UtilRegistrySearchName = WixUtilNamespace + "RegistrySearch"; | 139 | private static readonly XName UtilRegistrySearchName = WixUtilNamespace + "RegistrySearch"; |
| 139 | private static readonly XName UtilXmlConfigElementName = WixUtilNamespace + "XmlConfig"; | 140 | private static readonly XName UtilXmlConfigElementName = WixUtilNamespace + "XmlConfig"; |
| 140 | private static readonly XName CustomActionElementName = WixNamespace + "CustomAction"; | 141 | private static readonly XName CustomActionElementName = WixNamespace + "CustomAction"; |
| 142 | private static readonly XName CustomActionRefElementName = WixNamespace + "CustomActionRef"; | ||
| 141 | private static readonly XName PropertyElementName = WixNamespace + "Property"; | 143 | private static readonly XName PropertyElementName = WixNamespace + "Property"; |
| 142 | private static readonly XName Wix4ElementName = WixNamespace + "Wix"; | 144 | private static readonly XName Wix4ElementName = WixNamespace + "Wix"; |
| 143 | private static readonly XName Wix3ElementName = Wix3Namespace + "Wix"; | 145 | private static readonly XName Wix3ElementName = Wix3Namespace + "Wix"; |
| @@ -230,12 +232,14 @@ namespace WixToolset.Converters | |||
| 230 | { WixConverter.PermissionExElementName, this.ConvertPermissionExElement }, | 232 | { WixConverter.PermissionExElementName, this.ConvertPermissionExElement }, |
| 231 | { WixConverter.ProductElementName, this.ConvertProductElement }, | 233 | { WixConverter.ProductElementName, this.ConvertProductElement }, |
| 232 | { WixConverter.ProgressTextElementName, this.ConvertProgressTextElement }, | 234 | { WixConverter.ProgressTextElementName, this.ConvertProgressTextElement }, |
| 235 | { WixConverter.PropertyRefElementName, this.ConvertPropertyRefElement }, | ||
| 233 | { WixConverter.PublishElementName, this.ConvertPublishElement }, | 236 | { WixConverter.PublishElementName, this.ConvertPublishElement }, |
| 234 | { WixConverter.MultiStringValueElementName, this.ConvertMultiStringValueElement }, | 237 | { WixConverter.MultiStringValueElementName, this.ConvertMultiStringValueElement }, |
| 235 | { WixConverter.RegistryKeyElementName, this.ConvertRegistryKeyElement }, | 238 | { WixConverter.RegistryKeyElementName, this.ConvertRegistryKeyElement }, |
| 236 | { WixConverter.RegistrySearchElementName, this.ConvertRegistrySearchElement }, | 239 | { WixConverter.RegistrySearchElementName, this.ConvertRegistrySearchElement }, |
| 237 | { WixConverter.RemotePayloadElementName, this.ConvertRemotePayloadElement }, | 240 | { WixConverter.RemotePayloadElementName, this.ConvertRemotePayloadElement }, |
| 238 | { WixConverter.RequiredPrivilegeElementName, this.ConvertRequiredPrivilegeElement }, | 241 | { WixConverter.RequiredPrivilegeElementName, this.ConvertRequiredPrivilegeElement }, |
| 242 | { WixConverter.CustomActionRefElementName, this.ConvertCustomActionRefElement }, | ||
| 239 | { WixConverter.ServiceArgumentElementName, this.ConvertServiceArgumentElement }, | 243 | { WixConverter.ServiceArgumentElementName, this.ConvertServiceArgumentElement }, |
| 240 | { WixConverter.SetDirectoryElementName, this.ConvertSetDirectoryElement }, | 244 | { WixConverter.SetDirectoryElementName, this.ConvertSetDirectoryElement }, |
| 241 | { WixConverter.SetPropertyElementName, this.ConvertSetPropertyElement }, | 245 | { WixConverter.SetPropertyElementName, this.ConvertSetPropertyElement }, |
| @@ -1293,6 +1297,110 @@ namespace WixToolset.Converters | |||
| 1293 | xAttribute?.Remove(); | 1297 | xAttribute?.Remove(); |
| 1294 | } | 1298 | } |
| 1295 | 1299 | ||
| 1300 | private void ConvertPropertyRefElement(XElement element) | ||
| 1301 | { | ||
| 1302 | var newElementName = String.Empty; | ||
| 1303 | |||
| 1304 | var id = element.Attribute("Id"); | ||
| 1305 | switch (id?.Value) | ||
| 1306 | { | ||
| 1307 | case "WIX_SUITE_BACKOFFICE": | ||
| 1308 | case "WIX_SUITE_BLADE": | ||
| 1309 | case "WIX_SUITE_COMMUNICATIONS": | ||
| 1310 | case "WIX_SUITE_COMPUTE_SERVER": | ||
| 1311 | case "WIX_SUITE_DATACENTER": | ||
| 1312 | case "WIX_SUITE_EMBEDDED_RESTRICTED": | ||
| 1313 | case "WIX_SUITE_EMBEDDEDNT": | ||
| 1314 | case "WIX_SUITE_ENTERPRISE": | ||
| 1315 | case "WIX_SUITE_MEDIACENTER": | ||
| 1316 | case "WIX_SUITE_PERSONAL": | ||
| 1317 | case "WIX_SUITE_SECURITY_APPLIANCE": | ||
| 1318 | case "WIX_SUITE_SERVERR2": | ||
| 1319 | case "WIX_SUITE_SINGLEUSERTS": | ||
| 1320 | case "WIX_SUITE_SMALLBUSINESS": | ||
| 1321 | case "WIX_SUITE_SMALLBUSINESS_RESTRICTED": | ||
| 1322 | case "WIX_SUITE_STARTER": | ||
| 1323 | case "WIX_SUITE_STORAGE_SERVER": | ||
| 1324 | case "WIX_SUITE_TABLETPC": | ||
| 1325 | case "WIX_SUITE_TERMINAL": | ||
| 1326 | case "WIX_SUITE_WH_SERVER": | ||
| 1327 | newElementName = "QueryWindowsSuiteInfo"; | ||
| 1328 | break; | ||
| 1329 | case "WIX_DIR_ADMINTOOLS": | ||
| 1330 | case "WIX_DIR_ALTSTARTUP": | ||
| 1331 | case "WIX_DIR_CDBURN_AREA": | ||
| 1332 | case "WIX_DIR_COMMON_ADMINTOOLS": | ||
| 1333 | case "WIX_DIR_COMMON_ALTSTARTUP": | ||
| 1334 | case "WIX_DIR_COMMON_DOCUMENTS": | ||
| 1335 | case "WIX_DIR_COMMON_FAVORITES": | ||
| 1336 | case "WIX_DIR_COMMON_MUSIC": | ||
| 1337 | case "WIX_DIR_COMMON_PICTURES": | ||
| 1338 | case "WIX_DIR_COMMON_VIDEO": | ||
| 1339 | case "WIX_DIR_COOKIES": | ||
| 1340 | case "WIX_DIR_DESKTOP": | ||
| 1341 | case "WIX_DIR_HISTORY": | ||
| 1342 | case "WIX_DIR_INTERNET_CACHE": | ||
| 1343 | case "WIX_DIR_MYMUSIC": | ||
| 1344 | case "WIX_DIR_MYPICTURES": | ||
| 1345 | case "WIX_DIR_MYVIDEO": | ||
| 1346 | case "WIX_DIR_NETHOOD": | ||
| 1347 | case "WIX_DIR_PERSONAL": | ||
| 1348 | case "WIX_DIR_PRINTHOOD": | ||
| 1349 | case "WIX_DIR_PROFILE": | ||
| 1350 | case "WIX_DIR_RECENT": | ||
| 1351 | case "WIX_DIR_RESOURCES": | ||
| 1352 | newElementName = "QueryWindowsDirectories"; | ||
| 1353 | break; | ||
| 1354 | case "WIX_DWM_COMPOSITION_ENABLED": | ||
| 1355 | case "WIX_WDDM_DRIVER_PRESENT": | ||
| 1356 | newElementName = "QueryWindowsDriverInfo"; | ||
| 1357 | break; | ||
| 1358 | case "WIX_ACCOUNT_LOCALSYSTEM": | ||
| 1359 | case "WIX_ACCOUNT_LOCALSERVICE": | ||
| 1360 | case "WIX_ACCOUNT_NETWORKSERVICE": | ||
| 1361 | case "WIX_ACCOUNT_ADMINISTRATORS": | ||
| 1362 | case "WIX_ACCOUNT_USERS": | ||
| 1363 | case "WIX_ACCOUNT_GUESTS": | ||
| 1364 | case "WIX_ACCOUNT_PERFLOGUSERS": | ||
| 1365 | case "WIX_ACCOUNT_PERFLOGUSERS_NODOMAIN": | ||
| 1366 | newElementName = "QueryWindowsWellKnownSIDs"; | ||
| 1367 | break; | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | if (!String.IsNullOrEmpty(newElementName) | ||
| 1371 | && this.OnError(ConverterTestType.UtilReferencesReplaced, element, "Custom action and property reference {0} to WixUtilExtension have been replaced with strongly-typed elements.", id)) | ||
| 1372 | { | ||
| 1373 | element.AddAfterSelf(new XElement(WixUtilNamespace + newElementName)); | ||
| 1374 | element.Remove(); | ||
| 1375 | } | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | private void ConvertCustomActionRefElement(XElement element) | ||
| 1379 | { | ||
| 1380 | var newElementName = String.Empty; | ||
| 1381 | |||
| 1382 | var id = element.Attribute("Id"); | ||
| 1383 | switch (id?.Value) | ||
| 1384 | { | ||
| 1385 | case "WixBroadcastSettingChange": | ||
| 1386 | case "WixBroadcastEnvironmentChange": | ||
| 1387 | case "WixCheckRebootRequired": | ||
| 1388 | case "WixExitEarlyWithSuccess": | ||
| 1389 | case "WixFailWhenDeferred": | ||
| 1390 | case "WixWaitForEvent": | ||
| 1391 | case "WixWaitForEventDeferred": | ||
| 1392 | newElementName = id?.Value.Substring(3); // strip leading Wix | ||
| 1393 | break; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | if (!String.IsNullOrEmpty(newElementName) | ||
| 1397 | && this.OnError(ConverterTestType.UtilReferencesReplaced, element, "Custom action and property reference {0} to WixUtilExtension have been replaced with strongly-typed elements.", id)) | ||
| 1398 | { | ||
| 1399 | element.AddAfterSelf(new XElement(WixUtilNamespace + newElementName)); | ||
| 1400 | element.Remove(); | ||
| 1401 | } | ||
| 1402 | } | ||
| 1403 | |||
| 1296 | private void ConvertPublishElement(XElement element) | 1404 | private void ConvertPublishElement(XElement element) |
| 1297 | { | 1405 | { |
| 1298 | this.ConvertInnerTextToAttribute(element, "Condition"); | 1406 | this.ConvertInnerTextToAttribute(element, "Condition"); |
| @@ -2317,6 +2425,11 @@ namespace WixToolset.Converters | |||
| 2317 | /// Standard directories should no longer be defined using the Directory element. | 2425 | /// Standard directories should no longer be defined using the Directory element. |
| 2318 | /// </summary> | 2426 | /// </summary> |
| 2319 | DefiningStandardDirectoryDeprecated, | 2427 | DefiningStandardDirectoryDeprecated, |
| 2428 | |||
| 2429 | /// <summary> | ||
| 2430 | /// Naked custom action and property references replaced with WixUtilExtension elements. | ||
| 2431 | /// </summary> | ||
| 2432 | UtilReferencesReplaced, | ||
| 2320 | } | 2433 | } |
| 2321 | } | 2434 | } |
| 2322 | } | 2435 | } |
diff --git a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs index acd7991e..a39f6243 100644 --- a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs | |||
| @@ -8,7 +8,6 @@ namespace WixToolsetTest.Converters | |||
| 8 | using WixBuildTools.TestSupport; | 8 | using WixBuildTools.TestSupport; |
| 9 | using WixToolset.Converters; | 9 | using WixToolset.Converters; |
| 10 | using WixToolset.Core; | 10 | using WixToolset.Core; |
| 11 | using WixToolset.Core.ExtensibilityServices; | ||
| 12 | using WixToolset.Core.TestPackage; | 11 | using WixToolset.Core.TestPackage; |
| 13 | using WixToolsetTest.Converters.Mocks; | 12 | using WixToolsetTest.Converters.Mocks; |
| 14 | using Xunit; | 13 | using Xunit; |
| @@ -88,7 +87,7 @@ namespace WixToolsetTest.Converters | |||
| 88 | var converter = new WixConverter(messaging, 4); | 87 | var converter = new WixConverter(messaging, 4); |
| 89 | var errors = converter.ConvertFile(targetFile, true); | 88 | var errors = converter.ConvertFile(targetFile, true); |
| 90 | 89 | ||
| 91 | Assert.Equal(10, errors); | 90 | Assert.Single(messaging.Messages.Where(m => m.Id == 5/*WixConverter.ConverterTestType.UnauthorizedAccessException*/)); |
| 92 | } | 91 | } |
| 93 | } | 92 | } |
| 94 | 93 | ||
diff --git a/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs index 9964e3b0..10450c68 100644 --- a/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs +++ b/src/test/WixToolsetTest.Converters/UtilExtensionFixture.cs | |||
| @@ -111,5 +111,80 @@ namespace WixToolsetTest.Converters | |||
| 111 | var actualLines = UnformattedDocumentLines(document); | 111 | var actualLines = UnformattedDocumentLines(document); |
| 112 | WixAssert.CompareLineByLine(expected, actualLines); | 112 | WixAssert.CompareLineByLine(expected, actualLines); |
| 113 | } | 113 | } |
| 114 | |||
| 115 | |||
| 116 | [Fact] | ||
| 117 | public void FixXmlConfigValueCData() | ||
| 118 | { | ||
| 119 | var parse = String.Join(Environment.NewLine, | ||
| 120 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
| 121 | " <Fragment>", | ||
| 122 | " <util:XmlConfig Id='Change' ElementPath='book'>", | ||
| 123 | " <![CDATA[a<>b]]>", | ||
| 124 | " </util:XmlConfig>", | ||
| 125 | " </Fragment>", | ||
| 126 | "</Wix>"); | ||
| 127 | |||
| 128 | var expected = new[] | ||
| 129 | { | ||
| 130 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
| 131 | " <Fragment>", | ||
| 132 | " <util:XmlConfig Id=\"Change\" ElementPath=\"book\" Value=\"a<>b\" />", | ||
| 133 | " </Fragment>", | ||
| 134 | "</Wix>" | ||
| 135 | }; | ||
| 136 | |||
| 137 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 138 | |||
| 139 | var messaging = new MockMessaging(); | ||
| 140 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 141 | |||
| 142 | var errors = converter.ConvertDocument(document); | ||
| 143 | Assert.Equal(3, errors); | ||
| 144 | |||
| 145 | var actualLines = UnformattedDocumentLines(document); | ||
| 146 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 147 | } | ||
| 148 | |||
| 149 | [Fact] | ||
| 150 | public void FixQueryOsPropertyRefs() | ||
| 151 | { | ||
| 152 | var parse = String.Join(Environment.NewLine, | ||
| 153 | "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", | ||
| 154 | " <Fragment>", | ||
| 155 | " <PropertyRef Id=\"WIX_SUITE_ENTERPRISE\" />", | ||
| 156 | " <PropertyRef Id=\"WIX_DIR_COMMON_DOCUMENTS\" />", | ||
| 157 | " <CustomActionRef Id=\"WixFailWhenDeferred\" />", | ||
| 158 | " <UI>", | ||
| 159 | " <PropertyRef Id=\"WIX_ACCOUNT_LOCALSERVICE\" />", | ||
| 160 | " </UI>", | ||
| 161 | " </Fragment>", | ||
| 162 | "</Wix>"); | ||
| 163 | |||
| 164 | var expected = new[] | ||
| 165 | { | ||
| 166 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", | ||
| 167 | " <Fragment>", | ||
| 168 | " <util:QueryWindowsSuiteInfo />", | ||
| 169 | " <util:QueryWindowsDirectories />", | ||
| 170 | " <util:FailWhenDeferred />", | ||
| 171 | " <UI>", | ||
| 172 | " <util:QueryWindowsWellKnownSIDs />", | ||
| 173 | " </UI>", | ||
| 174 | " </Fragment>", | ||
| 175 | "</Wix>" | ||
| 176 | }; | ||
| 177 | |||
| 178 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
| 179 | |||
| 180 | var messaging = new MockMessaging(); | ||
| 181 | var converter = new WixConverter(messaging, 2, null, null); | ||
| 182 | |||
| 183 | var errors = converter.ConvertDocument(document); | ||
| 184 | Assert.Equal(6, errors); | ||
| 185 | |||
| 186 | var actualLines = UnformattedDocumentLines(document); | ||
| 187 | WixAssert.CompareLineByLine(expected, actualLines); | ||
| 188 | } | ||
| 114 | } | 189 | } |
| 115 | } | 190 | } |
