From dc634c5c0fa8d6c646d75be144cc546abc4b72c7 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 19 Mar 2022 11:09:40 -0700 Subject: Make ModuleSignature a standard table and no refs with EnsureTable ModuleSignature was missing from the standard tables, that part is easy. The breaking change is EnsureTable no longer tries to create refs to custom tables when it doesn't recognize the table name as standard or coming from an extension. Use CustomTableRef to create custom table references. Fixes 6424 --- .../WixToolset.Data/Symbols/SymbolDefinitions.cs | 1 + .../CreateWindowsInstallerDataFromIRCommand.cs | 11 +++++-- .../ExtensibilityServices/ParseHelper.cs | 17 ---------- .../test/Example.Extension/ExampleExtensionData.cs | 2 +- .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 8 ++--- .../MsiQueryFixture.cs | 38 ++++++++++++++++++++-- .../TestData/EnsureTable/EnsureExtensionTable.wxs | 10 ++++++ .../TestData/EnsureTable/EnsureModuleSignature.wxs | 10 ++++++ .../TestData/EnsureTable/EnsureTable.wxs | 10 ------ 9 files changed, 70 insertions(+), 37 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureExtensionTable.wxs create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureModuleSignature.wxs delete mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureTable.wxs (limited to 'src') diff --git a/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs b/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs index ad7646a7..21ca1b6d 100644 --- a/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs +++ b/src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs @@ -57,6 +57,7 @@ namespace WixToolset.Data ModuleExclusion, ModuleIgnoreTable, WixModule, + ModuleSignature, ModuleSubstitution, MoveFile, Assembly, diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs index b1805e69..a4f6200e 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs @@ -1224,8 +1224,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void AddWixEnsureTableSymbol(WixEnsureTableSymbol symbol) { - var tableDefinition = this.TableDefinitions[symbol.Table]; - this.Data.EnsureTable(tableDefinition); + try + { + var tableDefinition = this.TableDefinitions[symbol.Table]; + this.Data.EnsureTable(tableDefinition); + } + catch (WixMissingTableDefinitionException e) + { + this.Messaging.Write(e.Error); + } } private void AddWixPackageSymbol(WixPackageSymbol symbol) diff --git a/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index 2d5c5b2e..654b56dc 100644 --- a/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs @@ -306,9 +306,6 @@ namespace WixToolset.Core.ExtensibilityServices { Table = tableDefinition.Name, }); - - // TODO: Check if the given table definition is a custom table. For now we have to assume that it isn't. - //this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixCustomTable, tableDefinition.Name); } public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName) @@ -317,20 +314,6 @@ namespace WixToolset.Core.ExtensibilityServices { Table = tableName, }); - - if (this.Creator == null) - { - this.CreateSymbolDefinitionCreator(); - } - - // TODO: The tableName may not be the same as the symbolName. For now, we have to assume that it is. - // We don't add custom table definitions to the tableDefinitions collection, - // so if it's not in there, it better be a custom table. If the Id is just wrong, - // instead of a custom table, we get an unresolved reference at link time. - if (!this.Creator.TryGetSymbolDefinitionByName(tableName, out var _)) - { - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixCustomTable, tableName); - } } public string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false) diff --git a/src/wix/test/Example.Extension/ExampleExtensionData.cs b/src/wix/test/Example.Extension/ExampleExtensionData.cs index 91d60eb9..e8ae0cca 100644 --- a/src/wix/test/Example.Extension/ExampleExtensionData.cs +++ b/src/wix/test/Example.Extension/ExampleExtensionData.cs @@ -20,4 +20,4 @@ namespace Example.Extension return symbolDefinition != null; } } -} \ No newline at end of file +} diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 67a5f132..cb1ecb04 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -846,8 +846,8 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] - public void FailsBuildAtLinkTimeForMissingEnsureTable() + [Fact] + public void FailsBuildAtBindTimeForMissingEnsureTable() { var folder = TestData.Get(@"TestData"); var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); @@ -873,7 +873,7 @@ namespace WixToolsetTest.CoreIntegration first => { Assert.Equal(MessageLevel.Error, first.Level); - Assert.Equal("The identifier 'WixCustomTable:TableDefinitionNotExposedByExtension' could not be found. Ensure you have typed the reference correctly and that all the necessary inputs are provided to the linker.", first.ToString()); + Assert.Equal("Cannot find the table definitions for the 'TableDefinitionNotExposedByExtension' table. This is likely due to a typing error or missing extension. Please ensure all the necessary extensions are supplied on the command line with the -ext parameter.", first.ToString()); }); Assert.False(File.Exists(msiPath)); @@ -884,7 +884,7 @@ namespace WixToolsetTest.CoreIntegration { return table.Rows.Select(r => JoinFields(r.Fields)).ToArray(); - string JoinFields(Field[] fields) + static string JoinFields(Field[] fields) { return String.Join('\t', fields.Select(f => f.ToString())); } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index f361a274..e94114bb 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -334,8 +334,40 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] - public void PopulatesExampleTableBecauseOfEnsureTable() + [Fact] + public void CanBuildMsiWithEmptyStandardTableBecauseOfEnsureTable() + { + var folder = TestData.Get(@"TestData"); + var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "EnsureTable", "EnsureModuleSignature.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-ext", extensionPath, + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(msiPath)); + var results = Query.QueryDatabaseByTable(msiPath, new[] { "ModuleSignature" }); + WixAssert.StringCollectionEmpty(results["ModuleSignature"]); + } + } + + [Fact] + public void CanBuildMsiWithEmptyTableFromExtensionBecauseOfEnsureTable() { var folder = TestData.Get(@"TestData"); var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); @@ -349,7 +381,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", - Path.Combine(folder, "EnsureTable", "EnsureTable.wxs"), + Path.Combine(folder, "EnsureTable", "EnsureExtensionTable.wxs"), Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), "-ext", extensionPath, diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureExtensionTable.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureExtensionTable.wxs new file mode 100644 index 00000000..01767abb --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureExtensionTable.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureModuleSignature.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureModuleSignature.wxs new file mode 100644 index 00000000..a7bc1ff2 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureModuleSignature.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureTable.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureTable.wxs deleted file mode 100644 index 01767abb..00000000 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureTable.wxs +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - -- cgit v1.2.3-55-g6feb