diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-10-23 12:53:27 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-10-23 12:57:55 -0700 |
| commit | 752301ba571020717862d2232e3fad585de6a39a (patch) | |
| tree | a97ceeb6b762af2dd18d0d561dadeaceda3bf387 /src/WixToolset.Core.WindowsInstaller | |
| parent | 11355d03334e300886512411d4649536a5ee65e3 (diff) | |
| download | wix-752301ba571020717862d2232e3fad585de6a39a.tar.gz wix-752301ba571020717862d2232e3fad585de6a39a.tar.bz2 wix-752301ba571020717862d2232e3fad585de6a39a.zip | |
Fix custom tables, small fixes in linker and update latest Data
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
4 files changed, 352 insertions, 16 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 53451752..411f64bf 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -32,8 +32,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 32 | 32 | ||
| 33 | this.PathResolver = this.ServiceProvider.GetService<IPathResolver>(); | 33 | this.PathResolver = this.ServiceProvider.GetService<IPathResolver>(); |
| 34 | 34 | ||
| 35 | this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); | ||
| 36 | |||
| 37 | this.CabbingThreadCount = context.CabbingThreadCount; | 35 | this.CabbingThreadCount = context.CabbingThreadCount; |
| 38 | this.CabCachePath = context.CabCachePath; | 36 | this.CabCachePath = context.CabCachePath; |
| 39 | this.Codepage = context.Codepage; | 37 | this.Codepage = context.Codepage; |
| @@ -86,8 +84,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 86 | 84 | ||
| 87 | private bool SuppressLayout { get; } | 85 | private bool SuppressLayout { get; } |
| 88 | 86 | ||
| 89 | private TableDefinitionCollection TableDefinitions { get; } | ||
| 90 | |||
| 91 | private string IntermediateFolder { get; } | 87 | private string IntermediateFolder { get; } |
| 92 | 88 | ||
| 93 | private Validator Validator { get; } | 89 | private Validator Validator { get; } |
| @@ -111,6 +107,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 111 | // If there are any fields to resolve later, create the cache to populate during bind. | 107 | // If there are any fields to resolve later, create the cache to populate during bind. |
| 112 | var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null; | 108 | var variableCache = this.DelayedFields.Any() ? new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) : null; |
| 113 | 109 | ||
| 110 | TableDefinitionCollection tableDefinitions; | ||
| 111 | { | ||
| 112 | var command = new LoadTableDefinitionsCommand(section); | ||
| 113 | command.Execute(); | ||
| 114 | |||
| 115 | tableDefinitions = command.TableDefinitions; | ||
| 116 | } | ||
| 117 | |||
| 114 | // Process the summary information table before the other tables. | 118 | // Process the summary information table before the other tables. |
| 115 | bool compressed; | 119 | bool compressed; |
| 116 | bool longNames; | 120 | bool longNames; |
| @@ -231,7 +235,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 231 | command.FileFacades = fileFacades; | 235 | command.FileFacades = fileFacades; |
| 232 | command.UpdateFileFacades = fileFacades.Where(f => !f.FromModule); | 236 | command.UpdateFileFacades = fileFacades.Where(f => !f.FromModule); |
| 233 | command.OverwriteHash = true; | 237 | command.OverwriteHash = true; |
| 234 | command.TableDefinitions = this.TableDefinitions; | 238 | command.TableDefinitions = tableDefinitions; |
| 235 | command.VariableCache = variableCache; | 239 | command.VariableCache = variableCache; |
| 236 | command.Execute(); | 240 | command.Execute(); |
| 237 | } | 241 | } |
| @@ -308,7 +312,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 308 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. | 312 | // Time to create the output object. Try to put as much above here as possible, updating the IR is better. |
| 309 | Output output; | 313 | Output output; |
| 310 | { | 314 | { |
| 311 | var command = new CreateOutputFromIRCommand(section, this.TableDefinitions, this.BackendExtensions); | 315 | var command = new CreateOutputFromIRCommand(this.Messaging, section, tableDefinitions, this.BackendExtensions); |
| 312 | command.Execute(); | 316 | command.Execute(); |
| 313 | 317 | ||
| 314 | output = command.Output; | 318 | output = command.Output; |
| @@ -402,7 +406,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 402 | command.Compressed = compressed; | 406 | command.Compressed = compressed; |
| 403 | command.FileRowsByCabinet = filesByCabinetMedia; | 407 | command.FileRowsByCabinet = filesByCabinetMedia; |
| 404 | command.ResolveMedia = this.ResolveMedia; | 408 | command.ResolveMedia = this.ResolveMedia; |
| 405 | command.TableDefinitions = this.TableDefinitions; | 409 | command.TableDefinitions = tableDefinitions; |
| 406 | command.TempFilesLocation = this.IntermediateFolder; | 410 | command.TempFilesLocation = this.IntermediateFolder; |
| 407 | command.Execute(); | 411 | command.Execute(); |
| 408 | 412 | ||
| @@ -429,11 +433,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 429 | // Generate database file. | 433 | // Generate database file. |
| 430 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); | 434 | this.Messaging.Write(VerboseMessages.GeneratingDatabase()); |
| 431 | 435 | ||
| 432 | var trackMsi = this.BackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); | 436 | { |
| 433 | trackedFiles.Add(trackMsi); | 437 | var trackMsi = this.BackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); |
| 438 | trackedFiles.Add(trackMsi); | ||
| 434 | 439 | ||
| 435 | var temporaryFiles = this.GenerateDatabase(output, trackMsi.Path, false, false); | 440 | var temporaryFiles = this.GenerateDatabase(output, tableDefinitions, trackMsi.Path, false, false); |
| 436 | trackedFiles.AddRange(temporaryFiles); | 441 | trackedFiles.AddRange(temporaryFiles); |
| 442 | } | ||
| 437 | 443 | ||
| 438 | // Stop processing if an error previously occurred. | 444 | // Stop processing if an error previously occurred. |
| 439 | if (this.Messaging.EncounteredError) | 445 | if (this.Messaging.EncounteredError) |
| @@ -456,7 +462,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 456 | 462 | ||
| 457 | if (null == sequenceTable) | 463 | if (null == sequenceTable) |
| 458 | { | 464 | { |
| 459 | sequenceTable = output.EnsureTable(this.TableDefinitions[sequenceTableName]); | 465 | sequenceTable = output.EnsureTable(tableDefinitions[sequenceTableName]); |
| 460 | } | 466 | } |
| 461 | 467 | ||
| 462 | if (0 == sequenceTable.Rows.Count) | 468 | if (0 == sequenceTable.Rows.Count) |
| @@ -911,7 +917,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 911 | /// <param name="databaseFile">The database file to create.</param> | 917 | /// <param name="databaseFile">The database file to create.</param> |
| 912 | /// <param name="keepAddedColumns">Whether to keep columns added in a transform.</param> | 918 | /// <param name="keepAddedColumns">Whether to keep columns added in a transform.</param> |
| 913 | /// <param name="useSubdirectory">Whether to use a subdirectory based on the <paramref name="databaseFile"/> file name for intermediate files.</param> | 919 | /// <param name="useSubdirectory">Whether to use a subdirectory based on the <paramref name="databaseFile"/> file name for intermediate files.</param> |
| 914 | private IEnumerable<ITrackedFile> GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory) | 920 | private IEnumerable<ITrackedFile> GenerateDatabase(Output output, TableDefinitionCollection tableDefinitions, string databaseFile, bool keepAddedColumns, bool useSubdirectory) |
| 915 | { | 921 | { |
| 916 | var command = new GenerateDatabaseCommand(); | 922 | var command = new GenerateDatabaseCommand(); |
| 917 | command.BackendHelper = this.BackendHelper; | 923 | command.BackendHelper = this.BackendHelper; |
| @@ -921,7 +927,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 921 | command.KeepAddedColumns = keepAddedColumns; | 927 | command.KeepAddedColumns = keepAddedColumns; |
| 922 | command.UseSubDirectory = useSubdirectory; | 928 | command.UseSubDirectory = useSubdirectory; |
| 923 | command.SuppressAddingValidationRows = this.SuppressAddingValidationRows; | 929 | command.SuppressAddingValidationRows = this.SuppressAddingValidationRows; |
| 924 | command.TableDefinitions = this.TableDefinitions; | 930 | command.TableDefinitions = tableDefinitions; |
| 925 | command.IntermediateFolder = this.IntermediateFolder; | 931 | command.IntermediateFolder = this.IntermediateFolder; |
| 926 | command.Codepage = this.Codepage; | 932 | command.Codepage = this.Codepage; |
| 927 | command.Execute(); | 933 | command.Execute(); |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index ebb494c0..17cac83a 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs | |||
| @@ -11,14 +11,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 11 | using WixToolset.Data.WindowsInstaller; | 11 | using WixToolset.Data.WindowsInstaller; |
| 12 | using WixToolset.Data.WindowsInstaller.Rows; | 12 | using WixToolset.Data.WindowsInstaller.Rows; |
| 13 | using WixToolset.Extensibility; | 13 | using WixToolset.Extensibility; |
| 14 | using WixToolset.Extensibility.Services; | ||
| 14 | 15 | ||
| 15 | internal class CreateOutputFromIRCommand | 16 | internal class CreateOutputFromIRCommand |
| 16 | { | 17 | { |
| 17 | private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB | 18 | private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB |
| 18 | private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) | 19 | private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) |
| 19 | 20 | ||
| 20 | public CreateOutputFromIRCommand(IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions) | 21 | private static readonly char[] ColonCharacter = new[] { ':' }; |
| 22 | |||
| 23 | public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable<IWindowsInstallerBackendBinderExtension> backendExtensions) | ||
| 21 | { | 24 | { |
| 25 | this.Messaging = messaging; | ||
| 22 | this.Section = section; | 26 | this.Section = section; |
| 23 | this.TableDefinitions = tableDefinitions; | 27 | this.TableDefinitions = tableDefinitions; |
| 24 | this.BackendExtensions = backendExtensions; | 28 | this.BackendExtensions = backendExtensions; |
| @@ -26,6 +30,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 26 | 30 | ||
| 27 | private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; } | 31 | private IEnumerable<IWindowsInstallerBackendBinderExtension> BackendExtensions { get; } |
| 28 | 32 | ||
| 33 | private IMessaging Messaging { get; } | ||
| 34 | |||
| 29 | private TableDefinitionCollection TableDefinitions { get; } | 35 | private TableDefinitionCollection TableDefinitions { get; } |
| 30 | 36 | ||
| 31 | private IntermediateSection Section { get; } | 37 | private IntermediateSection Section { get; } |
| @@ -49,6 +55,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 49 | { | 55 | { |
| 50 | switch (tuple.Definition.Type) | 56 | switch (tuple.Definition.Type) |
| 51 | { | 57 | { |
| 58 | case TupleDefinitionType.AppSearch: | ||
| 59 | this.AddTupleDefaultly(tuple, output); | ||
| 60 | output.EnsureTable(this.TableDefinitions["Signature"]); | ||
| 61 | break; | ||
| 62 | |||
| 52 | case TupleDefinitionType.Binary: | 63 | case TupleDefinitionType.Binary: |
| 53 | this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); | 64 | this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); |
| 54 | break; | 65 | break; |
| @@ -133,6 +144,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 133 | this.AddMoveFileTuple((MoveFileTuple)tuple, output); | 144 | this.AddMoveFileTuple((MoveFileTuple)tuple, output); |
| 134 | break; | 145 | break; |
| 135 | 146 | ||
| 147 | case TupleDefinitionType.ProgId: | ||
| 148 | this.AddTupleDefaultly(tuple, output); | ||
| 149 | output.EnsureTable(this.TableDefinitions["Extension"]); | ||
| 150 | break; | ||
| 151 | |||
| 136 | case TupleDefinitionType.Property: | 152 | case TupleDefinitionType.Property: |
| 137 | this.AddPropertyTuple((PropertyTuple)tuple, output); | 153 | this.AddPropertyTuple((PropertyTuple)tuple, output); |
| 138 | break; | 154 | break; |
| @@ -197,6 +213,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 197 | this.AddTupleFromExtension(tuple, output); | 213 | this.AddTupleFromExtension(tuple, output); |
| 198 | break; | 214 | break; |
| 199 | 215 | ||
| 216 | case TupleDefinitionType.WixCustomRow: | ||
| 217 | this.AddWixCustomRowTuple((WixCustomRowTuple)tuple, output); | ||
| 218 | break; | ||
| 219 | |||
| 220 | case TupleDefinitionType.WixEnsureTable: | ||
| 221 | this.AddWixEnsureTableTuple((WixEnsureTableTuple)tuple, output); | ||
| 222 | break; | ||
| 223 | |||
| 200 | // ignored. | 224 | // ignored. |
| 201 | case TupleDefinitionType.WixFile: | 225 | case TupleDefinitionType.WixFile: |
| 202 | case TupleDefinitionType.WixComponentGroup: | 226 | case TupleDefinitionType.WixComponentGroup: |
| @@ -204,6 +228,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 204 | case TupleDefinitionType.WixFeatureGroup: | 228 | case TupleDefinitionType.WixFeatureGroup: |
| 205 | break; | 229 | break; |
| 206 | 230 | ||
| 231 | // Already processed. | ||
| 232 | case TupleDefinitionType.WixCustomTable: | ||
| 233 | break; | ||
| 234 | |||
| 207 | default: | 235 | default: |
| 208 | this.AddTupleDefaultly(tuple, output); | 236 | this.AddTupleDefaultly(tuple, output); |
| 209 | break; | 237 | break; |
| @@ -382,6 +410,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 382 | row[7] = tuple.FirstControlRef; | 410 | row[7] = tuple.FirstControlRef; |
| 383 | row[8] = tuple.DefaultControlRef; | 411 | row[8] = tuple.DefaultControlRef; |
| 384 | row[9] = tuple.CancelControlRef; | 412 | row[9] = tuple.CancelControlRef; |
| 413 | |||
| 414 | output.EnsureTable(this.TableDefinitions["ListBox"]); | ||
| 385 | } | 415 | } |
| 386 | 416 | ||
| 387 | private void AddDirectoryTuple(DirectoryTuple tuple, Output output) | 417 | private void AddDirectoryTuple(DirectoryTuple tuple, Output output) |
| @@ -929,6 +959,93 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 929 | row[2] = tuple.Sequence; | 959 | row[2] = tuple.Sequence; |
| 930 | } | 960 | } |
| 931 | } | 961 | } |
| 962 | |||
| 963 | private void AddWixCustomRowTuple(WixCustomRowTuple tuple, Output output) | ||
| 964 | { | ||
| 965 | var customTableDefinition = this.TableDefinitions[tuple.Table]; | ||
| 966 | |||
| 967 | if (customTableDefinition.Unreal) | ||
| 968 | { | ||
| 969 | |||
| 970 | return; | ||
| 971 | } | ||
| 972 | |||
| 973 | var customTable = output.EnsureTable(customTableDefinition); | ||
| 974 | var customRow = customTable.CreateRow(tuple.SourceLineNumbers); | ||
| 975 | |||
| 976 | #if TODO // SectionId seems like a good thing to preserve. | ||
| 977 | customRow.SectionId = tuple.SectionId; | ||
| 978 | #endif | ||
| 979 | |||
| 980 | var data = tuple.FieldDataSeparated; | ||
| 981 | |||
| 982 | for (var i = 0; i < data.Length; ++i) | ||
| 983 | { | ||
| 984 | var foundColumn = false; | ||
| 985 | var item = data[i].Split(ColonCharacter, 2); | ||
| 986 | |||
| 987 | for (var j = 0; j < customRow.Fields.Length; ++j) | ||
| 988 | { | ||
| 989 | if (customRow.Fields[j].Column.Name == item[0]) | ||
| 990 | { | ||
| 991 | if (0 < item[1].Length) | ||
| 992 | { | ||
| 993 | if (ColumnType.Number == customRow.Fields[j].Column.Type) | ||
| 994 | { | ||
| 995 | try | ||
| 996 | { | ||
| 997 | customRow.Fields[j].Data = Convert.ToInt32(item[1], CultureInfo.InvariantCulture); | ||
| 998 | } | ||
| 999 | catch (FormatException) | ||
| 1000 | { | ||
| 1001 | this.Messaging.Write(ErrorMessages.IllegalIntegerValue(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name, item[1])); | ||
| 1002 | } | ||
| 1003 | catch (OverflowException) | ||
| 1004 | { | ||
| 1005 | this.Messaging.Write(ErrorMessages.IllegalIntegerValue(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name, item[1])); | ||
| 1006 | } | ||
| 1007 | } | ||
| 1008 | else if (ColumnCategory.Identifier == customRow.Fields[j].Column.Category) | ||
| 1009 | { | ||
| 1010 | if (Common.IsIdentifier(item[1]) || Common.IsValidBinderVariable(item[1]) || ColumnCategory.Formatted == customRow.Fields[j].Column.Category) | ||
| 1011 | { | ||
| 1012 | customRow.Fields[j].Data = item[1]; | ||
| 1013 | } | ||
| 1014 | else | ||
| 1015 | { | ||
| 1016 | this.Messaging.Write(ErrorMessages.IllegalIdentifier(tuple.SourceLineNumbers, "Data", item[1])); | ||
| 1017 | } | ||
| 1018 | } | ||
| 1019 | else | ||
| 1020 | { | ||
| 1021 | customRow.Fields[j].Data = item[1]; | ||
| 1022 | } | ||
| 1023 | } | ||
| 1024 | foundColumn = true; | ||
| 1025 | break; | ||
| 1026 | } | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | if (!foundColumn) | ||
| 1030 | { | ||
| 1031 | this.Messaging.Write(ErrorMessages.UnexpectedCustomTableColumn(tuple.SourceLineNumbers, item[0])); | ||
| 1032 | } | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | for (var i = 0; i < customTableDefinition.Columns.Length; ++i) | ||
| 1036 | { | ||
| 1037 | if (!customTableDefinition.Columns[i].Nullable && (null == customRow.Fields[i].Data || 0 == customRow.Fields[i].Data.ToString().Length)) | ||
| 1038 | { | ||
| 1039 | this.Messaging.Write(ErrorMessages.NoDataForColumn(tuple.SourceLineNumbers, customTableDefinition.Columns[i].Name, customTableDefinition.Name)); | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | } | ||
| 1043 | |||
| 1044 | private void AddWixEnsureTableTuple(WixEnsureTableTuple tuple, Output output) | ||
| 1045 | { | ||
| 1046 | var tableDefinition = this.TableDefinitions[tuple.Table]; | ||
| 1047 | output.EnsureTable(tableDefinition); | ||
| 1048 | } | ||
| 932 | 1049 | ||
| 933 | private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple, Output output) | 1050 | private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple, Output output) |
| 934 | { | 1051 | { |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs new file mode 100644 index 00000000..05f865fa --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/LoadTableDefinitionsCommand.cs | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Globalization; | ||
| 8 | using System.Linq; | ||
| 9 | using WixToolset.Data; | ||
| 10 | using WixToolset.Data.Tuples; | ||
| 11 | using WixToolset.Data.WindowsInstaller; | ||
| 12 | |||
| 13 | internal class LoadTableDefinitionsCommand | ||
| 14 | { | ||
| 15 | public LoadTableDefinitionsCommand(IntermediateSection section) => this.Section = section; | ||
| 16 | |||
| 17 | public TableDefinitionCollection TableDefinitions { get; private set; } | ||
| 18 | |||
| 19 | private IntermediateSection Section { get; } | ||
| 20 | |||
| 21 | public TableDefinitionCollection Execute() | ||
| 22 | { | ||
| 23 | var tableDefinitions = new TableDefinitionCollection(WindowsInstallerStandardInternal.GetTableDefinitions()); | ||
| 24 | |||
| 25 | foreach (var tuple in this.Section.Tuples.OfType<WixCustomTableTuple>()) | ||
| 26 | { | ||
| 27 | var customTableDefinition = this.CreateCustomTable(tuple); | ||
| 28 | tableDefinitions.Add(customTableDefinition); | ||
| 29 | } | ||
| 30 | |||
| 31 | this.TableDefinitions = tableDefinitions; | ||
| 32 | return this.TableDefinitions; | ||
| 33 | } | ||
| 34 | |||
| 35 | private TableDefinition CreateCustomTable(WixCustomTableTuple row) | ||
| 36 | { | ||
| 37 | var columnNames = row.ColumnNames.Split('\t'); | ||
| 38 | var columnTypes = row.ColumnTypes.Split('\t'); | ||
| 39 | var primaryKeys = row.PrimaryKeys.Split('\t'); | ||
| 40 | var minValues = row.MinValues?.Split('\t'); | ||
| 41 | var maxValues = row.MaxValues?.Split('\t'); | ||
| 42 | var keyTables = row.KeyTables?.Split('\t'); | ||
| 43 | var keyColumns = row.KeyColumns?.Split('\t'); | ||
| 44 | var categories = row.Categories?.Split('\t'); | ||
| 45 | var sets = row.Sets?.Split('\t'); | ||
| 46 | var descriptions = row.Descriptions?.Split('\t'); | ||
| 47 | var modularizations = row.Modularizations?.Split('\t'); | ||
| 48 | |||
| 49 | var currentPrimaryKey = 0; | ||
| 50 | |||
| 51 | var columns = new List<ColumnDefinition>(columnNames.Length); | ||
| 52 | for (var i = 0; i < columnNames.Length; ++i) | ||
| 53 | { | ||
| 54 | var name = columnNames[i]; | ||
| 55 | var type = ColumnType.Unknown; | ||
| 56 | |||
| 57 | if (columnTypes[i].StartsWith("s", StringComparison.OrdinalIgnoreCase)) | ||
| 58 | { | ||
| 59 | type = ColumnType.String; | ||
| 60 | } | ||
| 61 | else if (columnTypes[i].StartsWith("l", StringComparison.OrdinalIgnoreCase)) | ||
| 62 | { | ||
| 63 | type = ColumnType.Localized; | ||
| 64 | } | ||
| 65 | else if (columnTypes[i].StartsWith("i", StringComparison.OrdinalIgnoreCase)) | ||
| 66 | { | ||
| 67 | type = ColumnType.Number; | ||
| 68 | } | ||
| 69 | else if (columnTypes[i].StartsWith("v", StringComparison.OrdinalIgnoreCase)) | ||
| 70 | { | ||
| 71 | type = ColumnType.Object; | ||
| 72 | } | ||
| 73 | |||
| 74 | var nullable = columnTypes[i].Substring(0, 1) == columnTypes[i].Substring(0, 1).ToUpperInvariant(); | ||
| 75 | var length = Convert.ToInt32(columnTypes[i].Substring(1), CultureInfo.InvariantCulture); | ||
| 76 | |||
| 77 | var primaryKey = false; | ||
| 78 | if (currentPrimaryKey < primaryKeys.Length && primaryKeys[currentPrimaryKey] == columnNames[i]) | ||
| 79 | { | ||
| 80 | primaryKey = true; | ||
| 81 | currentPrimaryKey++; | ||
| 82 | } | ||
| 83 | |||
| 84 | var minValue = String.IsNullOrEmpty(minValues?[i]) ? (int?)null : Convert.ToInt32(minValues[i], CultureInfo.InvariantCulture); | ||
| 85 | var maxValue = String.IsNullOrEmpty(maxValues?[i]) ? (int?)null : Convert.ToInt32(maxValues[i], CultureInfo.InvariantCulture); | ||
| 86 | var keyColumn = String.IsNullOrEmpty(keyColumns?[i]) ? (int?)null : Convert.ToInt32(keyColumns[i], CultureInfo.InvariantCulture); | ||
| 87 | |||
| 88 | var category = ColumnCategory.Unknown; | ||
| 89 | if (null != categories && null != categories[i] && 0 < categories[i].Length) | ||
| 90 | { | ||
| 91 | switch (categories[i]) | ||
| 92 | { | ||
| 93 | case "Text": | ||
| 94 | category = ColumnCategory.Text; | ||
| 95 | break; | ||
| 96 | case "UpperCase": | ||
| 97 | category = ColumnCategory.UpperCase; | ||
| 98 | break; | ||
| 99 | case "LowerCase": | ||
| 100 | category = ColumnCategory.LowerCase; | ||
| 101 | break; | ||
| 102 | case "Integer": | ||
| 103 | category = ColumnCategory.Integer; | ||
| 104 | break; | ||
| 105 | case "DoubleInteger": | ||
| 106 | category = ColumnCategory.DoubleInteger; | ||
| 107 | break; | ||
| 108 | case "TimeDate": | ||
| 109 | category = ColumnCategory.TimeDate; | ||
| 110 | break; | ||
| 111 | case "Identifier": | ||
| 112 | category = ColumnCategory.Identifier; | ||
| 113 | break; | ||
| 114 | case "Property": | ||
| 115 | category = ColumnCategory.Property; | ||
| 116 | break; | ||
| 117 | case "Filename": | ||
| 118 | category = ColumnCategory.Filename; | ||
| 119 | break; | ||
| 120 | case "WildCardFilename": | ||
| 121 | category = ColumnCategory.WildCardFilename; | ||
| 122 | break; | ||
| 123 | case "Path": | ||
| 124 | category = ColumnCategory.Path; | ||
| 125 | break; | ||
| 126 | case "Paths": | ||
| 127 | category = ColumnCategory.Paths; | ||
| 128 | break; | ||
| 129 | case "AnyPath": | ||
| 130 | category = ColumnCategory.AnyPath; | ||
| 131 | break; | ||
| 132 | case "DefaultDir": | ||
| 133 | category = ColumnCategory.DefaultDir; | ||
| 134 | break; | ||
| 135 | case "RegPath": | ||
| 136 | category = ColumnCategory.RegPath; | ||
| 137 | break; | ||
| 138 | case "Formatted": | ||
| 139 | category = ColumnCategory.Formatted; | ||
| 140 | break; | ||
| 141 | case "FormattedSddl": | ||
| 142 | category = ColumnCategory.FormattedSDDLText; | ||
| 143 | break; | ||
| 144 | case "Template": | ||
| 145 | category = ColumnCategory.Template; | ||
| 146 | break; | ||
| 147 | case "Condition": | ||
| 148 | category = ColumnCategory.Condition; | ||
| 149 | break; | ||
| 150 | case "Guid": | ||
| 151 | category = ColumnCategory.Guid; | ||
| 152 | break; | ||
| 153 | case "Version": | ||
| 154 | category = ColumnCategory.Version; | ||
| 155 | break; | ||
| 156 | case "Language": | ||
| 157 | category = ColumnCategory.Language; | ||
| 158 | break; | ||
| 159 | case "Binary": | ||
| 160 | category = ColumnCategory.Binary; | ||
| 161 | break; | ||
| 162 | case "CustomSource": | ||
| 163 | category = ColumnCategory.CustomSource; | ||
| 164 | break; | ||
| 165 | case "Cabinet": | ||
| 166 | category = ColumnCategory.Cabinet; | ||
| 167 | break; | ||
| 168 | case "Shortcut": | ||
| 169 | category = ColumnCategory.Shortcut; | ||
| 170 | break; | ||
| 171 | default: | ||
| 172 | break; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | |||
| 176 | var keyTable = keyTables?[i]; | ||
| 177 | var setValue = sets?[i]; | ||
| 178 | var description = descriptions?[i]; | ||
| 179 | var modString = modularizations?[i]; | ||
| 180 | var modularization = ColumnModularizeType.None; | ||
| 181 | |||
| 182 | switch (modString) | ||
| 183 | { | ||
| 184 | case null: | ||
| 185 | case "None": | ||
| 186 | modularization = ColumnModularizeType.None; | ||
| 187 | break; | ||
| 188 | case "Column": | ||
| 189 | modularization = ColumnModularizeType.Column; | ||
| 190 | break; | ||
| 191 | case "Property": | ||
| 192 | modularization = ColumnModularizeType.Property; | ||
| 193 | break; | ||
| 194 | case "Condition": | ||
| 195 | modularization = ColumnModularizeType.Condition; | ||
| 196 | break; | ||
| 197 | case "CompanionFile": | ||
| 198 | modularization = ColumnModularizeType.CompanionFile; | ||
| 199 | break; | ||
| 200 | case "SemicolonDelimited": | ||
| 201 | modularization = ColumnModularizeType.SemicolonDelimited; | ||
| 202 | break; | ||
| 203 | } | ||
| 204 | |||
| 205 | var columnDefinition = new ColumnDefinition(name, type, length, primaryKey, nullable, category, minValue, maxValue, keyTable, keyColumn, setValue, description, modularization, ColumnType.Localized == type, true); | ||
| 206 | columns.Add(columnDefinition); | ||
| 207 | } | ||
| 208 | |||
| 209 | var customTable = new TableDefinition(row.Id.Id, columns/*, unreal: bootstrapperApplicationData, bootstrapperApplicationData*/); | ||
| 210 | return customTable; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | } | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs index e671f6a1..0699199b 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs | |||
| @@ -271,7 +271,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind | |||
| 271 | } | 271 | } |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | var tableDefinition = new TableDefinition(tableName, columns, false, false); | 274 | var tableDefinition = new TableDefinition(tableName, columns, false); |
| 275 | 275 | ||
| 276 | // use our table definitions if core properties are the same; this allows us to take advantage | 276 | // use our table definitions if core properties are the same; this allows us to take advantage |
| 277 | // of wix concepts like localizable columns which current code assumes | 277 | // of wix concepts like localizable columns which current code assumes |
