From a71235e1a666b105fab46f125afc83ec3c8042a2 Mon Sep 17 00:00:00 2001 From: Christopher Painter Date: Tue, 9 May 2023 12:24:24 -0500 Subject: [PATCH] Fix CustomTables for V4 schema changes --- .../CustomTablesDesigner/CustomTables.cs | 31 ++++++++++++++++--- .../IsWiX/Properties/launchSettings.json | 2 +- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Application/Designers/CustomTablesDesigner/CustomTables.cs b/Application/Designers/CustomTablesDesigner/CustomTables.cs index 7636521..124df04 100644 --- a/Application/Designers/CustomTablesDesigner/CustomTables.cs +++ b/Application/Designers/CustomTablesDesigner/CustomTables.cs @@ -303,7 +303,14 @@ where myitem.Attribute("Id").Value == item.Text foreach (var data in row.Elements(ns + "Data")) { string columnName = data.Attribute("Column").Value; - dr[columnName] = data.Value; + if (_documentManager.Document.GetWiXVersion() == WiXVersion.v4) + { + dr[columnName] = data.GetOptionalAttribute("Value"); + } + else + { + dr[columnName] = data.Value; + } } _customTable.Rows.Add(dr); @@ -369,7 +376,14 @@ private void SaveTable() { var xcolumn = new XElement(ns + "Data"); xcolumn.Add(new XAttribute("Column", column.ColumnName)); - xcolumn.Value = row[column.ColumnName].ToString(); + if (_documentManager.Document.GetWiXVersion() == WiXVersion.v4) + { + xcolumn.SetAttributeValue("Value", row[column.ColumnName].ToString()); + } + else + { + xcolumn.Value = row[column.ColumnName].ToString(); + } xrow.Add(xcolumn); } @@ -530,12 +544,17 @@ private void toolStripMenuItemTableCreate_Click(object sender, EventArgs e) var dialog = new FormTableName(string.Empty, tables); if (dialog.ShowDialog() == DialogResult.OK) - { + { + string identifier = "Identifier"; + if(_documentManager.Document.GetWiXVersion() == WiXVersion.v4) + { + identifier = identifier.ToLower(); + } XElement previousElement = _documentManager.Document.GetElementToAddAfterSelf("CustomTable"); XElement newElement = new XElement(ns + "CustomTable", new XAttribute("Id", dialog.TableName), new XElement( ns + "Column", new XAttribute( "Id", "Id" ), - new XAttribute( "Category", "Identifier" ), + new XAttribute( "Category", identifier ), new XAttribute( "PrimaryKey", "yes" ), new XAttribute( "Nullable", "no" ), new XAttribute( "Type", "string" ), @@ -549,6 +568,10 @@ private void toolStripMenuItemTableCreate_Click(object sender, EventArgs e) { previousElement.AddAfterSelf(newElement); } + if (_documentManager.Document.GetWiXVersion() == WiXVersion.v4) + { + newElement.AddAfterSelf(new XElement(ns + "EnsureTable", new XAttribute("Id", dialog.TableName))); + } LoadData(); } } diff --git a/Application/IsWiX/Properties/launchSettings.json b/Application/IsWiX/Properties/launchSettings.json index 0ceb5b1..7c78153 100644 --- a/Application/IsWiX/Properties/launchSettings.json +++ b/Application/IsWiX/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "IsWiX": { "commandName": "Project", - "commandLineArgs": "C:\\GitHub\\TestApp\\Installer\\TestAppLib\\TestAppLib.wxs" + "commandLineArgs": "\"C:\\GitHub\\TestApp\\Installer\\TestAppSetup\\TestAppFiles.wxs\"" } } } \ No newline at end of file