From a14cb82fcca0b5522dfefe862493ad2e51240a84 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 9 Mar 2023 04:13:27 -0800 Subject: Warn on mismatched output times and validate only Windows Installer databases Fixes 7250 --- src/api/wix/WixToolset.Data/WarningMessages.cs | 4 ++-- src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs | 2 +- .../CommandLine/ValidateSubcommand.cs | 9 ++++++++- .../WindowsInstallerBackendErrors.cs | 6 ++++++ .../Link/FindEntrySectionAndLoadSymbolsCommand.cs | 10 ++++------ src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/api/wix/WixToolset.Data/WarningMessages.cs b/src/api/wix/WixToolset.Data/WarningMessages.cs index 65716ba7..7659b4e5 100644 --- a/src/api/wix/WixToolset.Data/WarningMessages.cs +++ b/src/api/wix/WixToolset.Data/WarningMessages.cs @@ -613,9 +613,9 @@ namespace WixToolset.Data return Message(sourceLineNumbers, Ids.UnclearShortcut, "Because it is an advertised shortcut, the target of shortcut '{0}' will be the keypath of component '{2}' rather than parent file '{1}'. To eliminate this warning, you can (1) make the Shortcut element a child of the File element that is the keypath of component '{2}', (2) make file '{1}' the keypath of component '{2}', or (3) remove the @Advertise attribute so the shortcut is a non-advertised shortcut.", shortcutId, fileId, componentId); } - public static Message UnexpectedEntrySection(SourceLineNumber sourceLineNumbers, string sectionType, string expectedType, string outputExtension) + public static Message UnexpectedEntrySection(SourceLineNumber sourceLineNumbers, string sectionType, string expectedType) { - return Message(sourceLineNumbers, Ids.UnexpectedEntrySection, "Found mismatched entry point <{0}>. Expected <{1}> for specified output package type {2}.", sectionType, expectedType, outputExtension); + return Message(sourceLineNumbers, Ids.UnexpectedEntrySection, "Found entry point <{0}> that does not match expected <{1}> output type. Verify that your source code is correct and matches the expected output type.", sectionType, expectedType); } public static Message UnexpectedTableInProduct(SourceLineNumber sourceLineNumbers, string tableName) diff --git a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs index f90b87f6..817ab7c9 100644 --- a/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/ext/Util/test/WixToolsetTest.Util/UtilExtensionFixture.cs @@ -301,7 +301,7 @@ namespace WixToolsetTest.Util public void CanBuildModuleWithXmlConfig() { var folder = TestData.Get(@"TestData", "XmlConfigModule"); - var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }); + var build = new Builder(folder, typeof(UtilExtensionFactory), new[] { folder }, "test.msm"); var results = build.BuildAndQuery(BuildX64, "Wix4XmlConfig"); WixAssert.CompareLineByLine(new[] diff --git a/src/wix/WixToolset.Core.WindowsInstaller/CommandLine/ValidateSubcommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/CommandLine/ValidateSubcommand.cs index 1294c87f..36ec0d21 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/CommandLine/ValidateSubcommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/CommandLine/ValidateSubcommand.cs @@ -90,7 +90,14 @@ namespace WixToolset.Core.WindowsInstaller.CommandLine if (File.Exists(this.WixpdbPath)) { - data = WindowsInstallerData.Load(this.WixpdbPath); + try + { + data = WindowsInstallerData.Load(this.WixpdbPath); + } + catch (ArgumentOutOfRangeException) + { + this.Messaging.Write(WindowsInstallerBackendErrors.InvalidWindowsInstallerWixpdbForValidation(this.WixpdbPath)); + } } var command = new ValidateDatabaseCommand(this.Messaging, this.FileSystem, this.IntermediateFolder, this.DatabasePath, data, this.CubeFiles, this.Ices, this.SuppressIces); diff --git a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs index ea867ea8..dbdbae0b 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/WindowsInstallerBackendErrors.cs @@ -29,6 +29,11 @@ namespace WixToolset.Core.WindowsInstaller return Message(originalLineNumber, Ids.InvalidModuleVersion, "The Module/@Version was not be able to be used as a four-part version. A valid four-part version has a max value of \"65535.65535.65535.65535\" and must be all numeric.", version); } + public static Message InvalidWindowsInstallerWixpdbForValidation(string wixpdbPath) + { + return Message(null, Ids.InvalidWindowsInstallerWixpdbForValidation, "The validation .wixpdb file: {0} was not from a Windows Installer database build (.msi or .msm). Verify that the output type was actually an MSI Package or Merge Module.", wixpdbPath); + } + public static Message UnknownDecompileType(string decompileType, string filePath) { return Message(null, Ids.UnknownDecompileType, "Unknown decompile type '{0}' from input: {1}", decompileType, filePath); @@ -52,6 +57,7 @@ namespace WixToolset.Core.WindowsInstaller ExceededMaximumAllowedFeatureDepthInMsi = 7503, UnknownDecompileType = 7504, UnknownValidationTargetFileExtension = 7505, + InvalidWindowsInstallerWixpdbForValidation = 7506, } // last available is 7999. 8000 is BurnBackendErrors. } } diff --git a/src/wix/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs b/src/wix/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs index 426718b6..908476db 100644 --- a/src/wix/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs +++ b/src/wix/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs @@ -60,12 +60,10 @@ namespace WixToolset.Core.Link // Try to find the one and only entry section. if (SectionType.Package == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type || SectionType.Bundle == section.Type) { - // TODO: remove this? - //if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) - //{ - // string outputExtension = Output.GetExtension(this.ExpectedOutputType); - // this.Messaging.Write(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension)); - //} + if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) + { + this.Messaging.Write(WarningMessages.UnexpectedEntrySection(section.Symbols.FirstOrDefault()?.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString())); + } if (null == this.EntrySection) { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs index 43f3b110..1f286ac6 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs @@ -120,7 +120,7 @@ namespace WixToolsetTest.CoreIntegration { var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); - var msiPath = Path.Combine(baseFolder, @"bin", "test.msi"); + var msiPath = Path.Combine(baseFolder, @"bin", "test.msm"); var result = WixRunner.Execute(new[] { -- cgit v1.2.3-55-g6feb