@joebigelow / wix / commits / dc634c5c

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

Rob Mensching committed Mar 19, 2022 at 11:09 UTC dc634c5c0fa8d6c646d75be144cc546abc4b72c7
8 files changed +60 -27
src/api/wix/WixToolset.Data/Symbols/SymbolDefinitions.cs
+1
@@ -57,6 +57,7 @@ namespace WixToolset.Data
57 ModuleExclusion,
58 ModuleIgnoreTable,
59 WixModule,
60 + ModuleSignature,
61 ModuleSubstitution,
62 MoveFile,
63 Assembly,
src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateWindowsInstallerDataFromIRCommand.cs
+9 -2
@@ -1224,8 +1224,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
1224
1225 private void AddWixEnsureTableSymbol(WixEnsureTableSymbol symbol)
1226 {
1227 - var tableDefinition = this.TableDefinitions[symbol.Table];
1228 - this.Data.EnsureTable(tableDefinition);
1227 + try
1228 + {
1229 + var tableDefinition = this.TableDefinitions[symbol.Table];
1230 + this.Data.EnsureTable(tableDefinition);
1231 + }
1232 + catch (WixMissingTableDefinitionException e)
1233 + {
1234 + this.Messaging.Write(e.Error);
1235 + }
1236 }
1237
1238 private void AddWixPackageSymbol(WixPackageSymbol symbol)
src/wix/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
-17
@@ -306,9 +306,6 @@ namespace WixToolset.Core.ExtensibilityServices
306 {
307 Table = tableDefinition.Name,
308 });
309 -
310 - // TODO: Check if the given table definition is a custom table. For now we have to assume that it isn't.
311 - //this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixCustomTable, tableDefinition.Name);
309 }
310
311 public void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName)
@@ -317,20 +314,6 @@ namespace WixToolset.Core.ExtensibilityServices
314 {
315 Table = tableName,
316 });
320 -
321 - if (this.Creator == null)
322 - {
323 - this.CreateSymbolDefinitionCreator();
324 - }
325 -
326 - // TODO: The tableName may not be the same as the symbolName. For now, we have to assume that it is.
327 - // We don't add custom table definitions to the tableDefinitions collection,
328 - // so if it's not in there, it better be a custom table. If the Id is just wrong,
329 - // instead of a custom table, we get an unresolved reference at link time.
330 - if (!this.Creator.TryGetSymbolDefinitionByName(tableName, out var _))
331 - {
332 - this.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.WixCustomTable, tableName);
333 - }
317 }
318
319 public string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false)
src/wix/test/Example.Extension/ExampleExtensionData.cs
+1 -1
@@ -20,4 +20,4 @@ namespace Example.Extension
20 return symbolDefinition != null;
21 }
22 }
23 -}
\ No newline at end of file
23 +}
src/wix/test/WixToolsetTest.CoreIntegration/MsiFixture.cs
+4 -4
@@ -846,8 +846,8 @@ namespace WixToolsetTest.CoreIntegration
846 }
847 }
848
849 - [Fact(Skip = "Test demonstrates failure")]
850 - public void FailsBuildAtLinkTimeForMissingEnsureTable()
849 + [Fact]
850 + public void FailsBuildAtBindTimeForMissingEnsureTable()
851 {
852 var folder = TestData.Get(@"TestData");
853 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
@@ -873,7 +873,7 @@ namespace WixToolsetTest.CoreIntegration
873 first =>
874 {
875 Assert.Equal(MessageLevel.Error, first.Level);
876 - 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());
876 + 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());
877 });
878
879 Assert.False(File.Exists(msiPath));
@@ -884,7 +884,7 @@ namespace WixToolsetTest.CoreIntegration
884 {
885 return table.Rows.Select(r => JoinFields(r.Fields)).ToArray();
886
887 - string JoinFields(Field[] fields)
887 + static string JoinFields(Field[] fields)
888 {
889 return String.Join('\t', fields.Select(f => f.ToString()));
890 }
src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
+35 -3
@@ -334,8 +334,40 @@ namespace WixToolsetTest.CoreIntegration
334 }
335 }
336
337 - [Fact(Skip = "Test demonstrates failure")]
338 - public void PopulatesExampleTableBecauseOfEnsureTable()
337 + [Fact]
338 + public void CanBuildMsiWithEmptyStandardTableBecauseOfEnsureTable()
339 + {
340 + var folder = TestData.Get(@"TestData");
341 + var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
342 +
343 + using (var fs = new DisposableFileSystem())
344 + {
345 + var baseFolder = fs.GetFolder();
346 + var intermediateFolder = Path.Combine(baseFolder, "obj");
347 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
348 +
349 + var result = WixRunner.Execute(new[]
350 + {
351 + "build",
352 + Path.Combine(folder, "EnsureTable", "EnsureModuleSignature.wxs"),
353 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
354 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
355 + "-ext", extensionPath,
356 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
357 + "-intermediateFolder", intermediateFolder,
358 + "-o", msiPath
359 + });
360 +
361 + result.AssertSuccess();
362 +
363 + Assert.True(File.Exists(msiPath));
364 + var results = Query.QueryDatabaseByTable(msiPath, new[] { "ModuleSignature" });
365 + WixAssert.StringCollectionEmpty(results["ModuleSignature"]);
366 + }
367 + }
368 +
369 + [Fact]
370 + public void CanBuildMsiWithEmptyTableFromExtensionBecauseOfEnsureTable()
371 {
372 var folder = TestData.Get(@"TestData");
373 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
@@ -349,7 +381,7 @@ namespace WixToolsetTest.CoreIntegration
381 var result = WixRunner.Execute(new[]
382 {
383 "build",
352 - Path.Combine(folder, "EnsureTable", "EnsureTable.wxs"),
384 + Path.Combine(folder, "EnsureTable", "EnsureExtensionTable.wxs"),
385 Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
386 Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
387 "-ext", extensionPath,
src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureExtensionTable.wxs renamed
src/wix/test/WixToolsetTest.CoreIntegration/TestData/EnsureTable/EnsureModuleSignature.wxs new
+10
@@ -0,0 +1,10 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents">
5 + <ComponentGroupRef Id="MinimalComponentGroup" />
6 + </ComponentGroup>
7 +
8 + <EnsureTable Id="ModuleSignature" />
9 + </Fragment>
10 +</Wix>