diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index a948fb2f2..bc63247e0 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs @@ -1306,11 +1306,6 @@ public static Message InvalidPreprocessorVariable(SourceLineNumber sourceLineNum 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); } - public static Message InvalidProductVersion(SourceLineNumber sourceLineNumbers, string version) - { - 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); - } - public static Message InvalidRemoveComponent(SourceLineNumber sourceLineNumbers, string component, string feature, string transformPath) { 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 @@ public enum Ids InvalidWixTransform = 239, UnexpectedFileExtension = 240, UnexpectedTableInPatch = 241, - InvalidProductVersion = 242, InvalidKeypathChange = 243, MissingValidatorExtension = 244, InvalidValidatorMessageType = 245, diff --git a/src/api/wix/WixToolset.Data/WarningMessages.cs b/src/api/wix/WixToolset.Data/WarningMessages.cs index 7659b4e5d..d54990e1a 100644 --- a/src/api/wix/WixToolset.Data/WarningMessages.cs +++ b/src/api/wix/WixToolset.Data/WarningMessages.cs @@ -678,6 +678,17 @@ public static Message InvalidMsiProductVersion(SourceLineNumber sourceLineNumber 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); } + public static Message InvalidMsiProductVersion(SourceLineNumber sourceLineNumbers, string version) + { + return Message(sourceLineNumbers, Ids.InvalidMsiProductVersion, + "Invalid MSI package version: '{0}'. " + + "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. " + + "The revision value is ignored but version labels and metadata are not allowed. " + + "Violating the MSI rules sometimes works as expected but the behavior is unpredictable and undefined. "+ + "Future versions of WiX might treat invalid package versions as an error.", + version); + } + public static Message CollidingModularizationTypes(string tableName, string columnName, string foreignTableName, int foreignColumnNumber, string modularizationType, string foreignModularizationType) { 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 9b92b271d..a1ec24f48 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -533,7 +533,7 @@ private void ProcessProductVersion(WixPackageSymbol packageSymbol, IntermediateS } else if (validate) { - this.Messaging.Write(ErrorMessages.InvalidProductVersion(packageSymbol.SourceLineNumbers, packageSymbol.Version)); + this.Messaging.Write(WarningMessages.InvalidMsiProductVersion(packageSymbol.SourceLineNumbers, packageSymbol.Version)); } } diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs index f160bff68..b25f0b527 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs @@ -1626,7 +1626,7 @@ private bool CheckUpgradeVersion(UpgradeSymbol symbol, string version, out strin } else { - this.Messaging.Write(ErrorMessages.InvalidProductVersion(symbol.SourceLineNumbers, version)); + this.Messaging.Write(WarningMessages.InvalidMsiProductVersion(symbol.SourceLineNumbers, version)); } changedVersion = null; diff --git a/src/wix/WixToolset.Core/Compiler_Patch.cs b/src/wix/WixToolset.Core/Compiler_Patch.cs index bd250ef4c..43e1d2e97 100644 --- a/src/wix/WixToolset.Core/Compiler_Patch.cs +++ b/src/wix/WixToolset.Core/Compiler_Patch.cs @@ -374,7 +374,7 @@ private void ParsePatchFamilyElement(XElement node, ComplexReferenceParentType p } else if (!CompilerCore.IsValidProductVersion(version)) { - this.Core.Write(ErrorMessages.InvalidProductVersion(sourceLineNumbers, version)); + this.Core.Write(WarningMessages.InvalidMsiProductVersion(sourceLineNumbers, version)); } // 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 000000000..8e008e0ee --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Version/PackageWithUndefinedBindVariableVersion.wxs @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs index 5d0b69d1d..7d0883f8b 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/UpgradeFixture.cs @@ -36,11 +36,8 @@ public void FailsOnInvalidVersion() var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) .Select(m => m.ToString()) .ToArray(); - WixAssert.CompareLineByLine(new[] - { - "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.", - }, errorMessages); - Assert.Equal(242, result.ExitCode); + Assert.StartsWith("Invalid MSI package version: '1.256.0'.", errorMessages.Single()); + Assert.Equal(1148, result.ExitCode); } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs index facc772d5..cf8466aa1 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs @@ -99,11 +99,8 @@ public void CannotBuildMsiWithExtendedVersion() var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) .Select(m => m.ToString()) .ToArray(); - WixAssert.CompareLineByLine(new[] - { - "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.", - }, errorMessages); - Assert.Equal(242, result.ExitCode); + Assert.StartsWith("Invalid MSI package version: 'v4.3.2-preview.1'.", errorMessages.Single()); + Assert.Equal(1148, result.ExitCode); } } @@ -118,7 +115,7 @@ public void CannotBuildMsiWithInvalidMajorVersion() var intermediateFolder = Path.Combine(baseFolder, "obj"); var msiPath = Path.Combine(baseFolder, @"bin\test1.msi"); - var result = WixRunner.Execute(new[] + var result = WixRunner.Execute(warningsAsErrors: false, new[] { "build", Path.Combine(folder, "Version", "PackageWithReplaceableVersion.wxs"), @@ -128,14 +125,42 @@ public void CannotBuildMsiWithInvalidMajorVersion() "-o", msiPath }); - var errorMessages = result.Messages.Where(m => m.Level == MessageLevel.Error) - .Select(m => m.ToString()) - .ToArray(); - WixAssert.CompareLineByLine(new[] + result.AssertSuccess(); + + var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning).Select(m => m.ToString()).ToArray(); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[0]); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[1]); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[2]); + } + } + + [Fact] + public void CannotBuildMsiWithInvalidBindVariableVersion() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test1.msi"); + + var result = WixRunner.Execute(warningsAsErrors: false, new[] { - "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.", - }, errorMessages); - Assert.Equal(242, result.ExitCode); + "build", + Path.Combine(folder, "Version", "PackageWithUndefinedBindVariableVersion.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-bindvariable", "Version=257.0.0", + "-o", msiPath + }); + + result.AssertSuccess(); + + var warningMessages = result.Messages.Where(m => m.Level == MessageLevel.Warning).Select(m => m.ToString()).ToArray(); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[0]); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[1]); + Assert.StartsWith("Invalid MSI package version: '257.0.0'.", warningMessages[2]); } }