aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2023-05-31 16:04:27 -0400
committerRob Mensching <rob@firegiant.com>2023-06-03 01:24:39 -0700
commit29cec14e4197080bdac5d6c1b66f4aaf9b53e91c (patch)
treeab1de23bebc77ba8218423e1bb82d1b8d2306c84
parent856658a8cbbf5bac9c0bf5cfced01a009c59f80d (diff)
downloadwix-29cec14e4197080bdac5d6c1b66f4aaf9b53e91c.tar.gz
wix-29cec14e4197080bdac5d6c1b66f4aaf9b53e91c.tar.bz2
wix-29cec14e4197080bdac5d6c1b66f4aaf9b53e91c.zip
Downgrade bad ProductVersion error to warning.
Fixes https://github.com/wixtoolset/issues/issues/7522.
-rw-r--r--src/api/wix/WixToolset.Data/ErrorMessages.cs6
-rw-r--r--src/api/wix/WixToolset.Data/WarningMessages.cs11
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs2
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs2
-rw-r--r--src/wix/WixToolset.Core/Compiler_Patch.cs2
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/Version/PackageWithUndefinedBindVariableVersion.wxs31
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs7
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs51
8 files changed, 85 insertions, 27 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs
index a948fb2f..bc63247e 100644
--- a/src/api/wix/WixToolset.Data/ErrorMessages.cs
+++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs
@@ -1306,11 +1306,6 @@ namespace WixToolset.Data
1306 return Message(sourceLineNumbers, Ids.InvalidPreprocessorVariable, "Ill-formed preprocessor variable '$({0})'. Variables must have a prefix (like 'var.', 'env.', or 'sys.') and a name at least 1 character long. If the literal string '$({0})' is desired, use '$$({0})'.", variable); 1306 return Message(sourceLineNumbers, Ids.InvalidPreprocessorVariable, "Ill-formed preprocessor variable '$({0})'. Variables must have a prefix (like 'var.', 'env.', or 'sys.') and a name at least 1 character long. If the literal string '$({0})' is desired, use '$$({0})'.", variable);
1307 } 1307 }
1308 1308
1309 public static Message InvalidProductVersion(SourceLineNumber sourceLineNumbers, string version)
1310 {
1311 return Message(sourceLineNumbers, Ids.InvalidProductVersion, "Invalid product version '{0}'. MSI product versions must have a major version less than 256, a minor version less than 256, and a build version less than 65536. The revision value is ignored but version labels and metadata are not allowed.", version);
1312 }
1313
1314 public static Message InvalidRemoveComponent(SourceLineNumber sourceLineNumbers, string component, string feature, string transformPath) 1309 public static Message InvalidRemoveComponent(SourceLineNumber sourceLineNumbers, string component, string feature, string transformPath)
1315 { 1310 {
1316 return Message(sourceLineNumbers, Ids.InvalidRemoveComponent, "Removing component '{0}' from feature '{1}' is not supported. Either the component was removed or the guid changed in the transform '{2}'. Add the component back, undo the change to the component guid, or remove the entire feature.", component, feature, transformPath); 1311 return Message(sourceLineNumbers, Ids.InvalidRemoveComponent, "Removing component '{0}' from feature '{1}' is not supported. Either the component was removed or the guid changed in the transform '{2}'. Add the component back, undo the change to the component guid, or remove the entire feature.", component, feature, transformPath);
@@ -2520,7 +2515,6 @@ namespace WixToolset.Data
2520 InvalidWixTransform = 239, 2515 InvalidWixTransform = 239,
2521 UnexpectedFileExtension = 240, 2516 UnexpectedFileExtension = 240,
2522 UnexpectedTableInPatch = 241, 2517 UnexpectedTableInPatch = 241,
2523 InvalidProductVersion = 242,
2524 InvalidKeypathChange = 243, 2518 InvalidKeypathChange = 243,
2525 MissingValidatorExtension = 244, 2519 MissingValidatorExtension = 244,
2526 InvalidValidatorMessageType = 245, 2520 InvalidValidatorMessageType = 245,
diff --git a/src/api/wix/WixToolset.Data/WarningMessages.cs b/src/api/wix/WixToolset.Data/WarningMessages.cs
index 7659b4e5..d54990e1 100644
--- a/src/api/wix/WixToolset.Data/WarningMessages.cs
+++ b/src/api/wix/WixToolset.Data/WarningMessages.cs
@@ -678,6 +678,17 @@ namespace WixToolset.Data
678 return Message(sourceLineNumbers, Ids.InvalidMsiProductVersion, "Invalid product version '{0}' in MSI package '{1}'. Product version should have a major version less than 256, a minor version less than 256, and a build version less than 65536. The bundle may incorrectly detect upgrades of this package.", version, package); 678 return Message(sourceLineNumbers, Ids.InvalidMsiProductVersion, "Invalid product version '{0}' in MSI package '{1}'. Product version should have a major version less than 256, a minor version less than 256, and a build version less than 65536. The bundle may incorrectly detect upgrades of this package.", version, package);
679 } 679 }
680 680
681 public static Message InvalidMsiProductVersion(SourceLineNumber sourceLineNumbers, string version)
682 {
683 return Message(sourceLineNumbers, Ids.InvalidMsiProductVersion,
684 "Invalid MSI package version: '{0}'. " +
685 "The Windows Installer SDK says that MSI product versions must have a major version less than 256, a minor version less than 256, and a build version less than 65536. " +
686 "The revision value is ignored but version labels and metadata are not allowed. " +
687 "Violating the MSI rules sometimes works as expected but the behavior is unpredictable and undefined. "+
688 "Future versions of WiX might treat invalid package versions as an error.",
689 version);
690 }
691
681 public static Message CollidingModularizationTypes(string tableName, string columnName, string foreignTableName, int foreignColumnNumber, string modularizationType, string foreignModularizationType) 692 public static Message CollidingModularizationTypes(string tableName, string columnName, string foreignTableName, int foreignColumnNumber, string modularizationType, string foreignModularizationType)
682 { 693 {
683 return Message(null, Ids.CollidingModularizationTypes, "The definition for the '{0}' table's '{1}' column is a foreign key relationship to the '{2}' table's column number {3}. The modularization types of the two column definitions differ: table '{0}' uses type {4} and table '{2}' uses type {5}. Change one of the modularization types so that they match.", tableName, columnName, foreignTableName, foreignColumnNumber, modularizationType, foreignModularizationType); 694 return Message(null, Ids.CollidingModularizationTypes, "The definition for the '{0}' table's '{1}' column is a foreign key relationship to the '{2}' table's column number {3}. The modularization types of the two column definitions differ: table '{0}' uses type {4} and table '{2}' uses type {5}. Change one of the modularization types so that they match.", tableName, columnName, foreignTableName, foreignColumnNumber, modularizationType, foreignModularizationType);
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
index 9b92b271..a1ec24f4 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
@@ -533,7 +533,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
533 } 533 }
534 else if (validate) 534 else if (validate)
535 { 535 {
536 this.Messaging.Write(ErrorMessages.InvalidProductVersion(packageSymbol.SourceLineNumbers, packageSymbol.Version)); 536 this.Messaging.Write(WarningMessages.InvalidMsiProductVersion(packageSymbol.SourceLineNumbers, packageSymbol.Version));
537 } 537 }
538 } 538 }
539 539
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs
index f160bff6..b25f0b52 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs
@@ -1626,7 +1626,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
1626 } 1626 }
1627 else 1627 else
1628 { 1628 {
1629 this.Messaging.Write(ErrorMessages.InvalidProductVersion(symbol.SourceLineNumbers, version)); 1629 this.Messaging.Write(WarningMessages.InvalidMsiProductVersion(symbol.SourceLineNumbers, version));
1630 } 1630 }
1631 1631
1632 changedVersion = null; 1632 changedVersion = null;
diff --git a/src/wix/WixToolset.Core/Compiler_Patch.cs b/src/wix/WixToolset.Core/Compiler_Patch.cs
index bd250ef4..43e1d2e9 100644
--- a/src/wix/WixToolset.Core/Compiler_Patch.cs
+++ b/src/wix/WixToolset.Core/Compiler_Patch.cs
@@ -374,7 +374,7 @@ namespace WixToolset.Core
374 } 374 }
375 else if (!CompilerCore.IsValidProductVersion(version)) 375 else if (!CompilerCore.IsValidProductVersion(version))
376 { 376 {
377 this.Core.Write(ErrorMessages.InvalidProductVersion(sourceLineNumbers, version)); 377 this.Core.Write(WarningMessages.InvalidMsiProductVersion(sourceLineNumbers, version));
378 } 378 }
379 379
380 // find unexpected child elements 380 // find unexpected child elements
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Version/PackageWithUndefinedBindVariableVersion.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Version/PackageWithUndefinedBindVariableVersion.wxs
new file mode 100644
index 00000000..8e008e0e
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Version/PackageWithUndefinedBindVariableVersion.wxs
@@ -0,0 +1,31 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Version="!(wix.Version)"
3 Name="MsiPackage"
4 Manufacturer="Example Corporation"
5 UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a"
6 Scope="perUser">
7 <MajorUpgrade DowngradeErrorMessage="Downgrade not allowed" />
8 <MediaTemplate EmbedCab="true" />
9
10 <Feature Id="ProductFeature" Title="Feature title">
11 <ComponentGroupRef Id="ProductComponents" />
12 </Feature>
13 </Package>
14
15 <Fragment>
16 <StandardDirectory Id="DesktopFolder">
17 <Directory Id="INSTALLFOLDER" Name="MsiPackage !(wix.Version) and !(bind.property.ProductVersion)" />
18 </StandardDirectory>
19 </Fragment>
20
21 <Fragment>
22 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
23 <Component>
24 <File Source="test.txt" />
25 </Component>
26 <Component Id="Shared.dll" Shared="yes">
27 <File Name="Shared.dll" Source="test.txt" />
28 </Component>
29 </ComponentGroup>
30 </Fragment>
31</Wix>
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs
index 5d0b69d1..7d0883f8 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs
@@ -36,11 +36,8 @@ namespace WixToolsetTest.CoreIntegration
36 var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) 36 var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error)
37 .Select(m => m.ToString()) 37 .Select(m => m.ToString())
38 .ToArray(); 38 .ToArray();
39 WixAssert.CompareLineByLine(new[] 39 Assert.StartsWith("Invalid MSI package version: '1.256.0'.", errorMessages.Single());
40 { 40 Assert.Equal(1148, result.ExitCode);
41 "Invalid product version '1.256.0'. MSI product versions must have a major version less than 256, a minor version less than 256, and a build version less than 65536. The revision value is ignored but version labels and metadata are not allowed.",
42 }, errorMessages);
43 Assert.Equal(242, result.ExitCode);
44 } 41 }
45 } 42 }
46 43
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
index facc772d..cf8466aa 100644
--- a/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
@@ -99,11 +99,8 @@ namespace WixToolsetTest.CoreIntegration
99 var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) 99 var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error)
100 .Select(m => m.ToString()) 100 .Select(m => m.ToString())
101 .ToArray(); 101 .ToArray();
102 WixAssert.CompareLineByLine(new[] 102 Assert.StartsWith("Invalid MSI package version: 'v4.3.2-preview.1'.", errorMessages.Single());
103 { 103 Assert.Equal(1148, result.ExitCode);
104 "Invalid product version 'v4.3.2-preview.1'. MSI product versions must have a major version less than 256, a minor version less than 256, and a build version less than 65536. The revision value is ignored but version labels and metadata are not allowed.",
105 }, errorMessages);
106 Assert.Equal(242, result.ExitCode);
107 } 104 }
108 } 105 }
109 106
@@ -118,7 +115,7 @@ namespace WixToolsetTest.CoreIntegration
118 var intermediateFolder = Path.Combine(baseFolder, "obj"); 115 var intermediateFolder = Path.Combine(baseFolder, "obj");
119 var msiPath = Path.Combine(baseFolder, @"bin\test1.msi"); 116 var msiPath = Path.Combine(baseFolder, @"bin\test1.msi");
120 117
121 var result = WixRunner.Execute(new[] 118 var result = WixRunner.Execute(warningsAsErrors: false, new[]
122 { 119 {
123 "build", 120 "build",
124 Path.Combine(folder, "Version", "PackageWithReplaceableVersion.wxs"), 121 Path.Combine(folder, "Version", "PackageWithReplaceableVersion.wxs"),
@@ -128,14 +125,42 @@ namespace WixToolsetTest.CoreIntegration
128 "-o", msiPath 125 "-o", msiPath
129 }); 126 });
130 127
131 var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) 128 result.AssertSuccess();
132 .Select(m => m.ToString()) 129
133 .ToArray(); 130 var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning).Select(m => m.ToString()).ToArray();
134 WixAssert.CompareLineByLine(new[] 131 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[0]);
132 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[1]);
133 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[2]);
134 }
135 }
136
137 [Fact]
138 public void CannotBuildMsiWithInvalidBindVariableVersion()
139 {
140 var folder = TestData.Get(@"TestData");
141
142 using (var fs = new DisposableFileSystem())
143 {
144 var baseFolder = fs.GetFolder();
145 var intermediateFolder = Path.Combine(baseFolder, "obj");
146 var msiPath = Path.Combine(baseFolder, @"bin\test1.msi");
147
148 var result = WixRunner.Execute(warningsAsErrors: false, new[]
135 { 149 {
136 "Invalid product version '257.0.0'. MSI product versions must have a major version less than 256, a minor version less than 256, and a build version less than 65536. The revision value is ignored but version labels and metadata are not allowed.", 150 "build",
137 }, errorMessages); 151 Path.Combine(folder, "Version", "PackageWithUndefinedBindVariableVersion.wxs"),
138 Assert.Equal(242, result.ExitCode); 152 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
153 "-intermediateFolder", intermediateFolder,
154 "-bindvariable", "Version=257.0.0",
155 "-o", msiPath
156 });
157
158 result.AssertSuccess();
159
160 var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning).Select(m => m.ToString()).ToArray();
161 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[0]);
162 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[1]);
163 Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[2]);
139 } 164 }
140 } 165 }
141 166