diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/WixToolset.Converters/WixConverter.cs | 65 | ||||
-rw-r--r-- | src/test/WixToolsetTest.Converters/ConverterFixture.cs | 33 | ||||
-rw-r--r-- | src/test/WixToolsetTest.Converters/RemotePayloadFixture.cs | 104 |
3 files changed, 169 insertions, 33 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs index 83a333f0..83053725 100644 --- a/src/WixToolset.Converters/WixConverter.cs +++ b/src/WixToolset.Converters/WixConverter.cs | |||
@@ -66,10 +66,12 @@ namespace WixToolset.Converters | |||
66 | private static readonly XName LaunchElementName = WixNamespace + "Launch"; | 66 | private static readonly XName LaunchElementName = WixNamespace + "Launch"; |
67 | private static readonly XName LevelElementName = WixNamespace + "Level"; | 67 | private static readonly XName LevelElementName = WixNamespace + "Level"; |
68 | private static readonly XName ExePackageElementName = WixNamespace + "ExePackage"; | 68 | private static readonly XName ExePackageElementName = WixNamespace + "ExePackage"; |
69 | private static readonly XName ExePackagePayloadElementName = WixNamespace + "ExePackagePayload"; | ||
69 | private static readonly XName ModuleElementName = WixNamespace + "Module"; | 70 | private static readonly XName ModuleElementName = WixNamespace + "Module"; |
70 | private static readonly XName MsiPackageElementName = WixNamespace + "MsiPackage"; | 71 | private static readonly XName MsiPackageElementName = WixNamespace + "MsiPackage"; |
71 | private static readonly XName MspPackageElementName = WixNamespace + "MspPackage"; | 72 | private static readonly XName MspPackageElementName = WixNamespace + "MspPackage"; |
72 | private static readonly XName MsuPackageElementName = WixNamespace + "MsuPackage"; | 73 | private static readonly XName MsuPackageElementName = WixNamespace + "MsuPackage"; |
74 | private static readonly XName MsuPackagePayloadElementName = WixNamespace + "MsuPackagePayload"; | ||
73 | private static readonly XName PackageElementName = WixNamespace + "Package"; | 75 | private static readonly XName PackageElementName = WixNamespace + "Package"; |
74 | private static readonly XName PayloadElementName = WixNamespace + "Payload"; | 76 | private static readonly XName PayloadElementName = WixNamespace + "Payload"; |
75 | private static readonly XName PermissionExElementName = WixNamespace + "PermissionEx"; | 77 | private static readonly XName PermissionExElementName = WixNamespace + "PermissionEx"; |
@@ -1099,6 +1101,44 @@ namespace WixToolset.Converters | |||
1099 | 1101 | ||
1100 | private void ConvertRemotePayloadElement(XElement element) | 1102 | private void ConvertRemotePayloadElement(XElement element) |
1101 | { | 1103 | { |
1104 | var xParent = element.Parent; | ||
1105 | |||
1106 | if (xParent.Name == ExePackageElementName && | ||
1107 | this.OnError(ConverterTestType.RemotePayloadRenamed, element, "The RemotePayload element has been renamed. Use the 'ExePackagePayload' instead.")) | ||
1108 | { | ||
1109 | element.Name = ExePackagePayloadElementName; | ||
1110 | } | ||
1111 | else if (xParent.Name == MsuPackageElementName && | ||
1112 | this.OnError(ConverterTestType.RemotePayloadRenamed, element, "The RemotePayload element has been renamed. Use the 'MsuPackagePayload' instead.")) | ||
1113 | { | ||
1114 | element.Name = MsuPackagePayloadElementName; | ||
1115 | } | ||
1116 | |||
1117 | var xName = xParent.Attribute("Name"); | ||
1118 | if (xName != null && | ||
1119 | this.OnError(ConverterTestType.NameAttributeMovedToRemotePayload, xParent, "The Name attribute must be specified on the child XxxPackagePayload element when using a remote payload.")) | ||
1120 | { | ||
1121 | element.SetAttributeValue("Name", xName.Value); | ||
1122 | xName.Remove(); | ||
1123 | } | ||
1124 | |||
1125 | var xDownloadUrl = xParent.Attribute("DownloadUrl"); | ||
1126 | if (xDownloadUrl != null && | ||
1127 | this.OnError(ConverterTestType.DownloadUrlAttributeMovedToRemotePayload, xParent, "The DownloadUrl attribute must be specified on the child XxxPackagePayload element when using a remote payload.")) | ||
1128 | { | ||
1129 | element.SetAttributeValue("DownloadUrl", xDownloadUrl.Value); | ||
1130 | xDownloadUrl.Remove(); | ||
1131 | } | ||
1132 | |||
1133 | var xCompressed = xParent.Attribute("Compressed"); | ||
1134 | if (xCompressed != null && | ||
1135 | this.OnError(ConverterTestType.CompressedAttributeUnnecessaryForRemotePayload, xParent, "The Compressed attribute should not be specified when using a remote payload.")) | ||
1136 | { | ||
1137 | xCompressed.Remove(); | ||
1138 | } | ||
1139 | |||
1140 | this.OnError(ConverterTestType.BurnHashAlgorithmChanged, element, "The hash algorithm for bundles changed from SHA1 to SHA512."); | ||
1141 | |||
1102 | RemoveIfPresent(element.Attribute("CertificatePublicKey")); | 1142 | RemoveIfPresent(element.Attribute("CertificatePublicKey")); |
1103 | RemoveIfPresent(element.Attribute("CertificateThumbprint")); | 1143 | RemoveIfPresent(element.Attribute("CertificateThumbprint")); |
1104 | 1144 | ||
@@ -1957,6 +1997,31 @@ namespace WixToolset.Converters | |||
1957 | /// Remove unused namespaces. | 1997 | /// Remove unused namespaces. |
1958 | /// </summary> | 1998 | /// </summary> |
1959 | RemoveUnusedNamespaces, | 1999 | RemoveUnusedNamespaces, |
2000 | |||
2001 | /// <summary> | ||
2002 | /// The Remote element has been renamed. Use the "XxxPackagePayload" element instead. | ||
2003 | /// </summary> | ||
2004 | RemotePayloadRenamed, | ||
2005 | |||
2006 | /// <summary> | ||
2007 | /// The XxxPackage/@Name attribute must be specified on the child XxxPackagePayload element when using a remote payload. | ||
2008 | /// </summary> | ||
2009 | NameAttributeMovedToRemotePayload, | ||
2010 | |||
2011 | /// <summary> | ||
2012 | /// The XxxPackage/@Compressed attribute should not be specified when using a remote payload. | ||
2013 | /// </summary> | ||
2014 | CompressedAttributeUnnecessaryForRemotePayload, | ||
2015 | |||
2016 | /// <summary> | ||
2017 | /// The XxxPackage/@DownloadUrl attribute must be specified on the child XxxPackagePayload element when using a remote payload. | ||
2018 | /// </summary> | ||
2019 | DownloadUrlAttributeMovedToRemotePayload, | ||
2020 | |||
2021 | /// <summary> | ||
2022 | /// The hash algorithm used for bundles changed from SHA1 to SHA512. | ||
2023 | /// </summary> | ||
2024 | BurnHashAlgorithmChanged, | ||
1960 | } | 2025 | } |
1961 | } | 2026 | } |
1962 | } | 2027 | } |
diff --git a/src/test/WixToolsetTest.Converters/ConverterFixture.cs b/src/test/WixToolsetTest.Converters/ConverterFixture.cs index 207d5c8f..4d815247 100644 --- a/src/test/WixToolsetTest.Converters/ConverterFixture.cs +++ b/src/test/WixToolsetTest.Converters/ConverterFixture.cs | |||
@@ -331,39 +331,6 @@ namespace WixToolsetTest.Converters | |||
331 | } | 331 | } |
332 | 332 | ||
333 | [Fact] | 333 | [Fact] |
334 | public void CanConvertRemotePayloadElement() | ||
335 | { | ||
336 | var parse = String.Join(Environment.NewLine, | ||
337 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
338 | " <RemotePayload", | ||
339 | " Description='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", | ||
340 | " Hash='61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA'", | ||
341 | " CertificatePublicKey='3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18'", | ||
342 | " CertificateThumbprint='2485A7AFA98E178CB8F30C9838346B514AEA4769'", | ||
343 | " ProductName='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", | ||
344 | " Size='7841880'", | ||
345 | " Version='3.1.8.20421' />", | ||
346 | "</Wix>"); | ||
347 | |||
348 | var expected = String.Join(Environment.NewLine, | ||
349 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
350 | " <RemotePayload Description=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Hash=\"61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA\" ProductName=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Size=\"7841880\" Version=\"3.1.8.20421\" />", | ||
351 | "</Wix>"); | ||
352 | |||
353 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
354 | |||
355 | var messaging = new MockMessaging(); | ||
356 | var converter = new WixConverter(messaging, 2, null, null); | ||
357 | |||
358 | var errors = converter.ConvertDocument(document); | ||
359 | |||
360 | var actual = UnformattedDocumentString(document); | ||
361 | |||
362 | Assert.Equal(2, errors); | ||
363 | Assert.Equal(expected, actual); | ||
364 | } | ||
365 | |||
366 | [Fact] | ||
367 | public void CanConvertSuppressSignatureValidationNo() | 334 | public void CanConvertSuppressSignatureValidationNo() |
368 | { | 335 | { |
369 | var parse = String.Join(Environment.NewLine, | 336 | var parse = String.Join(Environment.NewLine, |
diff --git a/src/test/WixToolsetTest.Converters/RemotePayloadFixture.cs b/src/test/WixToolsetTest.Converters/RemotePayloadFixture.cs new file mode 100644 index 00000000..b2640e13 --- /dev/null +++ b/src/test/WixToolsetTest.Converters/RemotePayloadFixture.cs | |||
@@ -0,0 +1,104 @@ | |||
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 RemotePayloadFixture : BaseConverterFixture | ||
13 | { | ||
14 | [Fact] | ||
15 | public void CanConvertExePackageRemotePayload() | ||
16 | { | ||
17 | var parse = String.Join(Environment.NewLine, | ||
18 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
19 | " <Fragment>", | ||
20 | " <PackageGroup Id='exe'>", | ||
21 | " <ExePackage Name='example.exe' DownloadUrl='example.com'>", | ||
22 | " <RemotePayload", | ||
23 | " Description='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", | ||
24 | " Hash='61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA'", | ||
25 | " CertificatePublicKey='3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18'", | ||
26 | " CertificateThumbprint='2485A7AFA98E178CB8F30C9838346B514AEA4769'", | ||
27 | " ProductName='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", | ||
28 | " Size='7841880'", | ||
29 | " Version='3.1.8.20421' />", | ||
30 | " </ExePackage>", | ||
31 | " </PackageGroup>", | ||
32 | " </Fragment>", | ||
33 | "</Wix>"); | ||
34 | |||
35 | var expected = new[] | ||
36 | { | ||
37 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
38 | " <Fragment>", | ||
39 | " <PackageGroup Id=\"exe\">", | ||
40 | " <ExePackage>", | ||
41 | " <ExePackagePayload Description=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Hash=\"61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA\" ProductName=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Size=\"7841880\" Version=\"3.1.8.20421\" Name=\"example.exe\" DownloadUrl=\"example.com\" />", | ||
42 | " </ExePackage>", | ||
43 | " </PackageGroup>", | ||
44 | " </Fragment>", | ||
45 | "</Wix>" | ||
46 | }; | ||
47 | |||
48 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
49 | |||
50 | var messaging = new MockMessaging(); | ||
51 | var converter = new WixConverter(messaging, 2, null, null); | ||
52 | |||
53 | var errors = converter.ConvertDocument(document); | ||
54 | Assert.Equal(6, errors); | ||
55 | |||
56 | var actualLines = UnformattedDocumentLines(document); | ||
57 | WixAssert.CompareLineByLine(expected, actualLines); | ||
58 | } | ||
59 | |||
60 | [Fact] | ||
61 | public void CanConvertMsuPackageRemotePayload() | ||
62 | { | ||
63 | var parse = String.Join(Environment.NewLine, | ||
64 | "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", | ||
65 | " <Fragment>", | ||
66 | " <PackageGroup Id='msu'>", | ||
67 | " <MsuPackage Name='example.msu' DownloadUrl='example.com' Compressed='no'>", | ||
68 | " <RemotePayload", | ||
69 | " Description='msu description'", | ||
70 | " Hash='71DC9EAA0C8968E48E13C5913ED202A2F8F94DBB'", | ||
71 | " ProductName='msu product name'", | ||
72 | " Size='500'", | ||
73 | " Version='0.0.0.0' />", | ||
74 | " </MsuPackage>", | ||
75 | " </PackageGroup>", | ||
76 | " </Fragment>", | ||
77 | "</Wix>"); | ||
78 | |||
79 | var expected = new[] | ||
80 | { | ||
81 | "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", | ||
82 | " <Fragment>", | ||
83 | " <PackageGroup Id=\"msu\">", | ||
84 | " <MsuPackage>", | ||
85 | " <MsuPackagePayload Description=\"msu description\" Hash=\"71DC9EAA0C8968E48E13C5913ED202A2F8F94DBB\" ProductName=\"msu product name\" Size=\"500\" Version=\"0.0.0.0\" Name=\"example.msu\" DownloadUrl=\"example.com\" />", | ||
86 | " </MsuPackage>", | ||
87 | " </PackageGroup>", | ||
88 | " </Fragment>", | ||
89 | "</Wix>" | ||
90 | }; | ||
91 | |||
92 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); | ||
93 | |||
94 | var messaging = new MockMessaging(); | ||
95 | var converter = new WixConverter(messaging, 2, null, null); | ||
96 | |||
97 | var errors = converter.ConvertDocument(document); | ||
98 | Assert.Equal(5, errors); | ||
99 | |||
100 | var actualLines = UnformattedDocumentLines(document); | ||
101 | WixAssert.CompareLineByLine(expected, actualLines); | ||
102 | } | ||
103 | } | ||
104 | } | ||