From 4d96895a19c79ced1543d44e181527824c82c8e8 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 16 May 2020 16:38:14 +1000 Subject: Process Unreal custom tables in CreateBootstrapperApplicationManifestCommand --- ...CreateBootstrapperApplicationManifestCommand.cs | 47 ++++++++++++++++++++++ .../BundleManifestFixture.cs | 39 ++++++++++++++++++ .../BundleCustomTable/BundleCustomTable.wxs | 26 ++++++++++++ .../WixToolsetTest.CoreIntegration.csproj | 1 + 4 files changed, 113 insertions(+) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs (limited to 'src') diff --git a/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs b/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs index 84c02ac9..2a230a90 100644 --- a/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs +++ b/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs @@ -16,6 +16,8 @@ namespace WixToolset.Core.Burn.Bundles internal class CreateBootstrapperApplicationManifestCommand { + private static readonly char[] ColonCharacter = new[] { ':' }; + public CreateBootstrapperApplicationManifestCommand(IntermediateSection section, WixBundleTuple bundleTuple, IEnumerable chainPackages, int lastUXPayloadIndex, Dictionary payloadTuples, string intermediateFolder) { this.Section = section; @@ -277,6 +279,51 @@ namespace WixToolset.Core.Burn.Bundles writer.WriteEndElement(); } } + + var dataTablesById = this.Section.Tuples.OfType() + .Where(t => t.Unreal && t.Id != null) + .ToDictionary(t => t.Id.Id); + var dataRowsByTable = this.Section.Tuples.OfType() + .GroupBy(t => t.Table); + foreach (var tableDataRows in dataRowsByTable) + { + var tableName = tableDataRows.Key; + if (!dataTablesById.TryGetValue(tableName, out var tableTuple)) + { + // This should have been a linker error. + continue; + } + + var columnNames = tableTuple.ColumnNames.Split('\t'); + + // We simply assert that the table (and field) name is valid, because + // this is up to the extension developer to get right. An author will + // only affect the attribute value, and that will get properly escaped. +#if DEBUG + Debug.Assert(Common.IsIdentifier(tableName)); + foreach (var columnName in columnNames) + { + Debug.Assert(Common.IsIdentifier(columnName)); + } +#endif // DEBUG + + foreach (var rowTuple in tableDataRows) + { + writer.WriteStartElement(tableName); + + //var rowFields = rowTuple.FieldDataSeparated; + foreach (var field in rowTuple.FieldDataSeparated) + { + var splitField = field.Split(ColonCharacter, 2); + if (splitField.Length == 2) + { + writer.WriteAttributeString(splitField[0], splitField[1]); + } + } + + writer.WriteEndElement(); + } + } } private WixBundlePayloadTuple CreateBootstrapperApplicationManifestPayloadRow(string baManifestPath) diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs index ebfdb872..53036919 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BundleManifestFixture.cs @@ -12,6 +12,45 @@ namespace WixToolsetTest.CoreIntegration public class BundleManifestFixture { + [Fact] + public void PopulatesBAManifestWithUnrealCustomTable() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var bundlePath = Path.Combine(baseFolder, @"bin\test.exe"); + var baFolderPath = Path.Combine(baseFolder, "ba"); + var extractFolderPath = Path.Combine(baseFolder, "extract"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "BundleCustomTable", "BundleCustomTable.wxs"), + Path.Combine(folder, "BundleWithPackageGroupRef", "MinimalPackageGroup.wxs"), + Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), + "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), + "-intermediateFolder", intermediateFolder, + "-o", bundlePath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(bundlePath)); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var customElements = extractResult.SelectBADataNodes("/ba:BootstrapperApplicationData/ba:BundleCustomTable"); + Assert.Equal(3, customElements.Count); + Assert.Equal("", customElements[0].GetTestXml()); + Assert.Equal("", customElements[1].GetTestXml()); + Assert.Equal("", customElements[2].GetTestXml()); + } + } + [Fact] public void PopulatesManifestWithBundleExtension() { diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs new file mode 100644 index 00000000..dacbc014 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + one + two + + + < + > + + + 1 + 2 + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 3989699d..0651ec7a 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -22,6 +22,7 @@ + -- cgit v1.2.3-55-g6feb