From c0f1332a0e18e9d506fe80c328548b001dcf93df Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 12 Jun 2020 12:55:28 -0700 Subject: Remove use of remaining WixXxxRows --- .../Bind/BindDatabaseCommand.cs | 6 +- .../Bind/CreateCabinetsCommand.cs | 89 +++++++++------------- .../Bind/CreateOutputFromIRCommand.cs | 23 +----- .../Bind/GenerateTransformCommand.cs | 2 + 4 files changed, 46 insertions(+), 74 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index b3f81212..6c2968ec 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -428,7 +428,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind { this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); - var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper); + var mediaTemplate = section.Tuples.OfType().FirstOrDefault(); + + var command = new CreateCabinetsCommand(this.ServiceProvider, this.BackendHelper, mediaTemplate); command.CabbingThreadCount = this.CabbingThreadCount; command.CabCachePath = this.CabCachePath; command.DefaultCompressionLevel = this.DefaultCompressionLevel; @@ -438,7 +440,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.LayoutDirectory = layoutDirectory; command.Compressed = compressed; command.ModularizationSuffix = modularizationSuffix; - command.FileRowsByCabinet = filesByCabinetMedia; + command.FileFacadesByCabinet = filesByCabinetMedia; command.ResolveMedia = this.ResolveMedia; command.TableDefinitions = tableDefinitions; command.IntermediateFolder = this.IntermediateFolder; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index f2f9895d..de357e53 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -12,7 +12,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Data; using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; - using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -33,7 +32,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private Dictionary lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence - public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper) + public CreateCabinetsCommand(IWixToolsetServiceProvider serviceProvider, IBackendHelper backendHelper, WixMediaTemplateTuple mediaTemplate) { this.fileTransfers = new List(); @@ -44,11 +43,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.ServiceProvider = serviceProvider; this.BackendHelper = backendHelper; + + this.MediaTemplate = mediaTemplate; } - public IWixToolsetServiceProvider ServiceProvider { get; } + private IWixToolsetServiceProvider ServiceProvider { get; } + + private IBackendHelper BackendHelper { get; } - public IBackendHelper BackendHelper { get; } + private WixMediaTemplateTuple MediaTemplate { get; } /// /// Sets the number of threads to use for cabinet creation. @@ -77,7 +80,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind public string ModularizationSuffix { private get; set; } - public Dictionary> FileRowsByCabinet { private get; set; } + public Dictionary> FileFacadesByCabinet { private get; set; } public Func ResolveMedia { private get; set; } @@ -90,7 +93,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// Output to generate image for. /// The directory in which the image should be layed out. /// Flag if source image should be compressed. - /// The uncompressed file rows. public void Execute() { this.lastCabinetAddedToMediaTable = new Dictionary(); @@ -109,7 +111,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind cabinetBuilder.MaximumCabinetSizeForLargeFileSplitting = maximumCabinetSizeForLargeFileSplitting; cabinetBuilder.MaximumUncompressedMediaSize = maximumUncompressedMediaSize; - foreach (var entry in this.FileRowsByCabinet) + foreach (var entry in this.FileFacadesByCabinet) { var mediaTuple = entry.Key; var files = entry.Value; @@ -175,28 +177,28 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Output for the current database. /// Directory to create cabinet in. - /// MediaRow containing information about the cabinet. + /// Media tuple containing information about the cabinet. /// Collection of files in this cabinet. /// created CabinetWorkItem object - private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable fileFacades) + private CabinetWorkItem CreateCabinetWorkItem(WindowsInstallerData output, string cabinetDir, MediaTuple mediaTuple, CompressionLevel compressionLevel, IEnumerable fileFacades) { CabinetWorkItem cabinetWorkItem = null; - string tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaRow.Cabinet); + var tempCabinetFileX = Path.Combine(this.IntermediateFolder, mediaTuple.Cabinet); // check for an empty cabinet if (!fileFacades.Any()) { // Remove the leading '#' from the embedded cabinet name to make the warning easier to understand - var cabinetName = mediaRow.Cabinet.TrimStart('#'); + var cabinetName = mediaTuple.Cabinet.TrimStart('#'); // If building a patch, remind them to run -p for torch. if (OutputType.Patch == output.Type) { - this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName, true)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName, true)); } else { - this.Messaging.Write(WarningMessages.EmptyCabinet(mediaRow.SourceLineNumbers, cabinetName)); + this.Messaging.Write(WarningMessages.EmptyCabinet(mediaTuple.SourceLineNumbers, cabinetName)); } } @@ -212,7 +214,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else // reuse the cabinet from the cabinet cache. { - this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaRow.SourceLineNumbers, mediaRow.Cabinet, resolvedCabinet.Path)); + this.Messaging.Write(VerboseMessages.ReusingCabCache(mediaTuple.SourceLineNumbers, mediaTuple.Cabinet, resolvedCabinet.Path)); try { @@ -226,27 +228,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind } catch (Exception e) { - this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaRow.SourceLineNumbers, resolvedCabinet.Path, e.Message)); + this.Messaging.Write(WarningMessages.CannotUpdateCabCache(mediaTuple.SourceLineNumbers, resolvedCabinet.Path, e.Message)); } } - var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaRow.SourceLineNumbers); + var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaTuple.SourceLineNumbers); this.trackedFiles.Add(trackResolvedCabinet); - if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) + if (mediaTuple.Cabinet.StartsWith("#", StringComparison.Ordinal)) { var streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); - var streamRow = streamsTable.CreateRow(mediaRow.SourceLineNumbers); - streamRow[0] = mediaRow.Cabinet.Substring(1); + var streamRow = streamsTable.CreateRow(mediaTuple.SourceLineNumbers); + streamRow[0] = mediaTuple.Cabinet.Substring(1); streamRow[1] = resolvedCabinet.Path; } else { - var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaRow.Cabinet), TrackedFileType.Final, mediaRow.SourceLineNumbers); + var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaTuple.Cabinet), TrackedFileType.Final, mediaTuple.SourceLineNumbers); this.trackedFiles.Add(trackDestination); - var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaRow.SourceLineNumbers); + var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaTuple.SourceLineNumbers); this.fileTransfers.Add(transfer); } @@ -417,36 +419,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Gets Compiler Values of MediaTemplate Attributes governing Maximum Cabinet Size after applying Environment Variable Overrides /// - /// Output to generate image for. - /// The indexed file rows. private void GetMediaTemplateAttributes(out int maxCabSizeForLargeFileSplitting, out int maxUncompressedMediaSize) { // Get Environment Variable Overrides for MediaTemplate Attributes governing Maximum Cabinet Size - string mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); - string mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); - int maxCabSizeForLargeFileInMB = 0; - int maxPreCompressedSizeInMB = 0; - ulong testOverFlow = 0; + var mcslfsString = Environment.GetEnvironmentVariable("WIX_MCSLFS"); + var mumsString = Environment.GetEnvironmentVariable("WIX_MUMS"); // Supply Compile MediaTemplate Attributes to Cabinet Builder - Table mediaTemplateTable = this.Output.Tables["WixMediaTemplate"]; - if (mediaTemplateTable != null) + if (this.MediaTemplate != null) { - WixMediaTemplateRow mediaTemplateRow = (WixMediaTemplateRow)mediaTemplateTable.Rows[0]; - // Get the Value for Max Cab Size for File Splitting + var maxCabSizeForLargeFileInMB = 0; try { // Override authored mcslfs value if environment variable is authored. - if (!String.IsNullOrEmpty(mcslfsString)) - { - maxCabSizeForLargeFileInMB = Int32.Parse(mcslfsString); - } - else - { - maxCabSizeForLargeFileInMB = mediaTemplateRow.MaximumCabinetSizeForLargeFileSplitting; - } - testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; + maxCabSizeForLargeFileInMB = !String.IsNullOrEmpty(mcslfsString) ? Int32.Parse(mcslfsString) : this.MediaTemplate.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; + + var testOverFlow = (ulong)maxCabSizeForLargeFileInMB * 1024 * 1024; + maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; } catch (FormatException) { @@ -457,18 +447,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind throw new WixException(ErrorMessages.MaximumCabinetSizeForLargeFileSplittingTooLarge(null, maxCabSizeForLargeFileInMB, MaxValueOfMaxCabSizeForLargeFileSplitting)); } + var maxPreCompressedSizeInMB = 0; try { // Override authored mums value if environment variable is authored. - if (!String.IsNullOrEmpty(mumsString)) - { - maxPreCompressedSizeInMB = Int32.Parse(mumsString); - } - else - { - maxPreCompressedSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize; - } - testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; + maxPreCompressedSizeInMB = !String.IsNullOrEmpty(mumsString) ? Int32.Parse(mumsString) : this.MediaTemplate.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; + + var testOverFlow = (ulong)maxPreCompressedSizeInMB * 1024 * 1024; + maxUncompressedMediaSize = maxPreCompressedSizeInMB; } catch (FormatException) { @@ -478,9 +464,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind { throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCompressedSizeInMB)); } - - maxCabSizeForLargeFileSplitting = maxCabSizeForLargeFileInMB; - maxUncompressedMediaSize = maxPreCompressedSizeInMB; } else { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index 21c39423..448ed607 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -15,9 +15,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind internal class CreateOutputFromIRCommand { - private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB - private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) - public CreateOutputFromIRCommand(IMessaging messaging, IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable backendExtensions, IWindowsInstallerBackendHelper backendHelper) { this.Messaging = messaging; @@ -189,10 +186,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddWixActionTuple((WixActionTuple)tuple); break; - case TupleDefinitionType.WixMediaTemplate: - this.AddWixMediaTemplateTuple((WixMediaTemplateTuple)tuple); - break; - case TupleDefinitionType.WixCustomTableCell: this.IndexCustomTableCellTuple((WixCustomTableCellTuple)tuple, cellsByTableAndRowId); break; @@ -202,6 +195,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; // Tuples used internally and are not added to the output. + case TupleDefinitionType.WixBuildInfo: case TupleDefinitionType.WixComponentGroup: case TupleDefinitionType.WixComplexReference: case TupleDefinitionType.WixDeltaPatchFile: @@ -211,6 +205,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind case TupleDefinitionType.WixInstanceComponent: case TupleDefinitionType.WixInstanceTransforms: case TupleDefinitionType.WixFeatureModules: + case TupleDefinitionType.WixGroup: + case TupleDefinitionType.WixMediaTemplate: case TupleDefinitionType.WixMerge: case TupleDefinitionType.WixOrdering: case TupleDefinitionType.WixPatchBaseline: @@ -946,7 +942,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - bool after = (null == tuple.Before); + var after = (null == tuple.Before); row[2] = after ? tuple.After : tuple.Before; row[3] = after ? 1 : 0; } @@ -1052,17 +1048,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Output.EnsureTable(tableDefinition); } - private void AddWixMediaTemplateTuple(WixMediaTemplateTuple tuple) - { - var row = (WixMediaTemplateRow)this.CreateRow(tuple, "WixMediaTemplate"); - row.CabinetTemplate = tuple.CabinetTemplate; - row.CompressionLevel = tuple.CompressionLevel; - row.DiskPrompt = tuple.DiskPrompt; - row.VolumeLabel = tuple.VolumeLabel; - row.MaximumUncompressedMediaSize = tuple.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; - row.MaximumCabinetSizeForLargeFileSplitting = tuple.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; - } - private bool AddTupleFromExtension(IntermediateTuple tuple) { foreach (var extension in this.BackendExtensions) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs index 201a890c..fc713954 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs @@ -160,6 +160,7 @@ namespace WixToolset.Core.WindowsInstaller { if (index.TryGetValue(primaryKey, out var collisionRow)) { +#if TODO_PATCH // This case doesn't seem like it can happen any longer. // Overriding WixActionRows have a primary key defined and take precedence in the index. if (row is WixActionRow actionRow) { @@ -176,6 +177,7 @@ namespace WixToolset.Core.WindowsInstaller // If we got this far, the row does not need to be indexed. return; } +#endif if (this.ShowPedanticMessages) { -- cgit v1.2.3-55-g6feb