From d0462be8000f18aa7dc0791d02142f000bb19fbf Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 22 May 2019 00:58:13 -0700 Subject: Integrate latest changes to tuple definitions --- .../Bind/AssignMediaCommand.cs | 35 ++++---- .../Bind/BindDatabaseCommand.cs | 7 +- .../Bind/BindSummaryInfoCommand.cs | 44 +++++----- .../Bind/BindTransformCommand.cs | 1 + .../Bind/CabinetBuilder.cs | 6 +- .../Bind/CabinetResolver.cs | 2 +- .../Bind/CalculateComponentGuids.cs | 16 ++-- .../Bind/CreateCabinetsCommand.cs | 31 ++----- .../Bind/CreateOutputFromIRCommand.cs | 95 +++++++++++++++++++--- .../Bind/CreateSpecialPropertiesCommand.cs | 9 +- .../Bind/ExtractMergeModuleFilesCommand.cs | 25 ++---- .../Bind/GetFileFacadesCommand.cs | 26 +++--- .../Bind/MergeModulesCommand.cs | 2 +- .../Bind/ModularizeCommand.cs | 4 +- .../Bind/ProcessUncompressedFilesCommand.cs | 13 +-- .../Bind/SequenceActionsCommand.cs | 60 +++++++------- .../Bind/UpdateFileFacadesCommand.cs | 26 +++--- .../Bind/UpdateMediaSequencesCommand.cs | 11 ++- .../Decompile/Decompiler.cs | 2 +- src/WixToolset.Core.WindowsInstaller/Differ.cs | 3 +- .../Rows/WixActionRowCollection.cs | 10 +-- 21 files changed, 235 insertions(+), 193 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs index 0f278640..8c6a3e67 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs @@ -16,6 +16,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// internal class AssignMediaCommand { + private const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB + public AssignMediaCommand(IntermediateSection section, IMessaging messaging) { this.CabinetNameTemplate = "Cab{0}.cab"; @@ -82,7 +84,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - this.AutoAssignFiles(mediaTable, this.FileFacades, filesByCabinetMedia, mediaRows, uncompressedFiles); + this.AutoAssignFiles(mediaTable, filesByCabinetMedia, mediaRows, uncompressedFiles); } this.FileFacadesByCabinetMedia = new Dictionary>(); @@ -101,7 +103,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// Assign files to cabinets based on MediaTemplate authoring. /// /// FileRowCollection - private void AutoAssignFiles(List mediaTable, IEnumerable fileFacades, Dictionary> filesByCabinetMedia, Dictionary mediaRows, List uncompressedFiles) + private void AutoAssignFiles(List mediaTable, Dictionary> filesByCabinetMedia, Dictionary mediaRows, List uncompressedFiles) { const int MaxCabIndex = 999; @@ -140,7 +142,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - maxPreCabSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize; + maxPreCabSizeInMB = mediaTemplateRow.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; } maxPreCabSizeInBytes = (ulong)maxPreCabSizeInMB * 1024 * 1024; @@ -212,8 +214,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind // If there are uncompressed files and no MediaRow, create a default one. if (uncompressedFiles.Count > 0 && !this.Section.Tuples.OfType().Any()) { - var defaultMediaRow = new MediaTuple(null, new Identifier(1, AccessModifier.Private)); - defaultMediaRow.DiskId = 1; + var defaultMediaRow = new MediaTuple(null, new Identifier(AccessModifier.Private, 1)) + { + DiskId = 1 + }; mediaRows.Add(1, defaultMediaRow); this.Section.Tuples.Add(defaultMediaRow); @@ -282,7 +286,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - this.Messaging.Write(ErrorMessages.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.File, facade.WixFile.DiskId)); + this.Messaging.Write(ErrorMessages.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.Id.Id, facade.WixFile.DiskId)); } } } @@ -294,21 +298,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// /// - private MediaTuple AddMediaRow(WixMediaTemplateTuple mediaTemplateRow, int cabIndex) + private MediaTuple AddMediaRow(WixMediaTemplateTuple mediaTemplateTuple, int cabIndex) { - var currentMediaRow = new MediaTuple(mediaTemplateRow.SourceLineNumbers, new Identifier(cabIndex, AccessModifier.Private)); - currentMediaRow.DiskId = cabIndex; - currentMediaRow.Cabinet = String.Format(CultureInfo.InvariantCulture, this.CabinetNameTemplate, cabIndex); - - this.Section.Tuples.Add(currentMediaRow); - - var row = new WixMediaTuple(mediaTemplateRow.SourceLineNumbers, new Identifier(cabIndex, AccessModifier.Private)); - row.DiskId_ = cabIndex; - row.CompressionLevel = mediaTemplateRow.CompressionLevel; + var currentMediaTuple = new MediaTuple(mediaTemplateTuple.SourceLineNumbers, new Identifier(AccessModifier.Private, cabIndex)); + currentMediaTuple.DiskId = cabIndex; + currentMediaTuple.Cabinet = String.Format(CultureInfo.InvariantCulture, this.CabinetNameTemplate, cabIndex); + currentMediaTuple.CompressionLevel = mediaTemplateTuple.CompressionLevel; - this.Section.Tuples.Add(row); + this.Section.Tuples.Add(currentMediaTuple); - return currentMediaRow; + return currentMediaTuple; } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index f78cb42c..cf7fe423 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -128,7 +128,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind foreach (var propertyRow in section.Tuples.OfType()) { // Set the ProductCode if it is to be generated. - if ("ProductCode".Equals(propertyRow.Property, StringComparison.Ordinal) && "*".Equals(propertyRow.Value, StringComparison.Ordinal)) + if ("ProductCode".Equals(propertyRow.Id.Id, StringComparison.Ordinal) && "*".Equals(propertyRow.Value, StringComparison.Ordinal)) { propertyRow.Value = Common.GenerateGuid(); @@ -159,7 +159,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Add the property name and value to the variableCache. if (variableCache != null) { - var key = String.Concat("property.", propertyRow.Property); + var key = String.Concat("property.", propertyRow.Id.Id); variableCache[key] = propertyRow.Value; } } @@ -312,7 +312,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Update file sequence. { - var command = new UpdateMediaSequencesCommand(output, fileFacades, assignedMediaRows); + var command = new UpdateMediaSequencesCommand(output, fileFacades); command.Execute(); } @@ -400,7 +400,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.ResolveMedia = this.ResolveMedia; command.TableDefinitions = this.TableDefinitions; command.TempFilesLocation = this.IntermediateFolder; - command.WixMediaTuples = section.Tuples.OfType(); command.Execute(); fileTransfers.AddRange(command.FileTransfers); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs index c9286a38..8aa6047f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs @@ -49,13 +49,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind bool foundCreatingApplication = false; string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture); - foreach (var summaryInformationRow in this.Section.Tuples.OfType<_SummaryInformationTuple>()) + foreach (var summaryInformationTuple in this.Section.Tuples.OfType()) { - switch (summaryInformationRow.PropertyId) + switch (summaryInformationTuple.PropertyId) { - case 1: // PID_CODEPAGE - // make sure the code page is an int and not a web name or null - var codepage = summaryInformationRow.Value; + case SumaryInformationType.Codepage: // PID_CODEPAGE + // make sure the code page is an int and not a web name or null + var codepage = summaryInformationTuple.Value; if (String.IsNullOrEmpty(codepage)) { @@ -63,11 +63,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - summaryInformationRow.Value = Common.GetValidCodePage(codepage, false, false, summaryInformationRow.SourceLineNumbers).ToString(CultureInfo.InvariantCulture); + summaryInformationTuple.Value = Common.GetValidCodePage(codepage, false, false, summaryInformationTuple.SourceLineNumbers).ToString(CultureInfo.InvariantCulture); } break; - case 9: // PID_REVNUMBER - var packageCode = summaryInformationRow.Value; + case SumaryInformationType.PackageCode: // PID_REVNUMBER + var packageCode = summaryInformationTuple.Value; if (SectionType.Module == this.Section.Type) { @@ -76,19 +76,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind else if ("*" == packageCode) { // set the revision number (package/patch code) if it should be automatically generated - summaryInformationRow.Value = Common.GenerateGuid(); + summaryInformationTuple.Value = Common.GenerateGuid(); } break; - case 12: // PID_CREATE_DTM + case SumaryInformationType.Created: foundCreateDataTime = true; break; - case 13: // PID_LASTSAVE_DTM + case SumaryInformationType.LastSaved: foundLastSaveDataTime = true; break; - case 14: - this.InstallerVersion = summaryInformationRow[_SummaryInformationTupleFields.Value].AsNumber(); + case SumaryInformationType.WindowsInstallerVersion: + this.InstallerVersion = summaryInformationTuple[SummaryInformationTupleFields.Value].AsNumber(); break; - case 15: // PID_WORDCOUNT + case SumaryInformationType.WordCount: if (SectionType.Patch == this.Section.Type) { this.LongNames = true; @@ -96,12 +96,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - var attributes = summaryInformationRow[_SummaryInformationTupleFields.Value].AsNumber(); + var attributes = summaryInformationTuple[SummaryInformationTupleFields.Value].AsNumber(); this.LongNames = (0 == (attributes & 1)); this.Compressed = (2 == (attributes & 2)); } break; - case 18: // PID_APPNAME + case SumaryInformationType.CreatingApplication: // PID_APPNAME foundCreatingApplication = true; break; } @@ -110,8 +110,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind // add a summary information row for the create time/date property if its not already set if (!foundCreateDataTime) { - var createTimeDateRow = new _SummaryInformationTuple(null, new Identifier(12, AccessModifier.Private)); - createTimeDateRow.PropertyId = 12; + var createTimeDateRow = new SummaryInformationTuple(null); + createTimeDateRow.PropertyId = SumaryInformationType.Created; createTimeDateRow.Value = now; this.Section.Tuples.Add(createTimeDateRow); @@ -120,8 +120,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind // add a summary information row for the last save time/date property if its not already set if (!foundLastSaveDataTime) { - var lastSaveTimeDateRow = new _SummaryInformationTuple(null, new Identifier(13, AccessModifier.Private)); - lastSaveTimeDateRow.PropertyId = 13; + var lastSaveTimeDateRow = new SummaryInformationTuple(null); + lastSaveTimeDateRow.PropertyId = SumaryInformationType.LastSaved; lastSaveTimeDateRow.Value = now; this.Section.Tuples.Add(lastSaveTimeDateRow); @@ -130,8 +130,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind // add a summary information row for the creating application property if its not already set if (!foundCreatingApplication) { - var creatingApplicationRow = new _SummaryInformationTuple(null, new Identifier(18, AccessModifier.Private)); - creatingApplicationRow.PropertyId = 18; + var creatingApplicationRow = new SummaryInformationTuple(null); + creatingApplicationRow.PropertyId = SumaryInformationType.CreatingApplication; creatingApplicationRow.Value = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()); this.Section.Tuples.Add(creatingApplicationRow); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs index 0c0f3705..2936ad7b 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs @@ -8,6 +8,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.IO; using WixToolset.Core.WindowsInstaller.Msi; using WixToolset.Data; + using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; using WixToolset.Extensibility.Services; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index 0c167699..3725b480 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs @@ -148,7 +148,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { // Cabinet has Single File, Check if this is Large File than needs Splitting into Multiple cabs // Get the Value for Max Uncompressed Media Size - maxPreCompressedSizeInBytes = (ulong)MaximumUncompressedMediaSize * 1024 * 1024; + maxPreCompressedSizeInBytes = (ulong)this.MaximumUncompressedMediaSize * 1024 * 1024; foreach (FileFacade facade in cabinetWorkItem.FileFacades) // No other easy way than looping to get the only row { @@ -168,8 +168,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind var files = cabinetWorkItem.FileFacades .Select(facade => facade.Hash == null ? - new CabinetCompressFile(facade.WixFile.Source.Path, facade.File.File) : - new CabinetCompressFile(facade.WixFile.Source.Path, facade.File.File, facade.Hash.HashPart1, facade.Hash.HashPart2, facade.Hash.HashPart3, facade.Hash.HashPart4)) + new CabinetCompressFile(facade.WixFile.Source.Path, facade.File.Id.Id) : + new CabinetCompressFile(facade.WixFile.Source.Path, facade.File.Id.Id, facade.Hash.HashPart1, facade.Hash.HashPart2, facade.Hash.HashPart3, facade.Hash.HashPart4)) .ToList(); var cabinetCompressionLevel = (CabinetCompressionLevel)cabinetWorkItem.CompressionLevel; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs index 054e3c71..987266f4 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs @@ -112,7 +112,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private IBindFileWithPath CreateBindFileWithPath(FileFacade facade) { var result = this.ServiceProvider.GetService(); - result.Id = facade.File.File; + result.Id = facade.File.Id.Id; result.Path = facade.WixFile.Source.Path; return result; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs index a773519a..414984de 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CalculateComponentGuids.cs @@ -81,25 +81,25 @@ namespace WixToolset.Core.WindowsInstaller.Bind // If the directory Id already exists, we will skip it here since // checking for duplicate primary keys is done later when importing tables // into database - if (targetPathsByDirectoryId.ContainsKey(row.Directory)) + if (targetPathsByDirectoryId.ContainsKey(row.Id.Id)) { continue; } var targetName = Common.GetName(row.DefaultDir, false, true); - targetPathsByDirectoryId.Add(row.Directory, new ResolvedDirectory(row.Directory_Parent, targetName)); + targetPathsByDirectoryId.Add(row.Id.Id, new ResolvedDirectory(row.Directory_Parent, targetName)); } } // If the component id generation seeds have not been indexed - // from the WixDirectory table do that now. + // from the Directory tuples do that now. if (componentIdGenSeeds is null) { - // If there are any WixDirectory rows, build up the Component Guid + // If there are any Directory tuples, build up the Component Guid // generation seeds indexed by Directory/@Id. - componentIdGenSeeds = this.Section.Tuples.OfType() + componentIdGenSeeds = this.Section.Tuples.OfType() .Where(t => !String.IsNullOrEmpty(t.ComponentGuidGenerationSeed)) - .ToDictionary(t => t.Directory_, t => t.ComponentGuidGenerationSeed); + .ToDictionary(t => t.Id.Id, t => t.ComponentGuidGenerationSeed); } // if the file rows have not been indexed by File.Component yet @@ -123,13 +123,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // validate component meets all the conditions to have a generated guid - var currentComponentFiles = filesByComponentId[componentTuple.Component]; + var currentComponentFiles = filesByComponentId[componentTuple.Id.Id]; var numFilesInComponent = currentComponentFiles.Count; string path = null; foreach (var fileRow in currentComponentFiles) { - if (fileRow.File == componentTuple.KeyPath) + if (fileRow.Id.Id == componentTuple.KeyPath) { // calculate the key file's canonical target path string directoryPath = PathResolver.GetDirectoryPath(targetPathsByDirectoryId, componentIdGenSeeds, componentTuple.Directory_, true); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 890c446c..be3c720f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -26,11 +26,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) - private List fileTransfers; + private readonly List fileTransfers; - private List trackedFiles; + private readonly List trackedFiles; - private FileSplitCabNamesCallback newCabNamesCallBack; + private readonly FileSplitCabNamesCallback newCabNamesCallBack; private Dictionary lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence @@ -82,8 +82,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind public TableDefinitionCollection TableDefinitions { private get; set; } - public IEnumerable WixMediaTuples { private get; set; } - public IEnumerable FileTransfers => this.fileTransfers; public IEnumerable TrackedFiles => this.trackedFiles; @@ -94,14 +92,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// The uncompressed file rows. public void Execute() { - var wixMediaTuples = this.WixMediaTuples.ToDictionary(t => t.DiskId_); - this.lastCabinetAddedToMediaTable = new Dictionary(); this.SetCabbingThreadCount(); // Send Binder object to Facilitate NewCabNamesCallBack Callback - CabinetBuilder cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); + var cabinetBuilder = new CabinetBuilder(this.Messaging, this.CabbingThreadCount, Marshal.GetFunctionPointerForDelegate(this.newCabNamesCallBack)); // Supply Compile MediaTemplate Attributes to Cabinet Builder this.GetMediaTemplateAttributes(out var MaximumCabinetSizeForLargeFileSplitting, out var MaximumUncompressedMediaSize); @@ -111,22 +107,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind foreach (var entry in this.FileRowsByCabinet) { var mediaTuple = entry.Key; - IEnumerable files = entry.Value; - CompressionLevel compressionLevel = this.DefaultCompressionLevel ?? CompressionLevel.Medium; - - string mediaLayoutFolder = null; - - if (wixMediaTuples.TryGetValue(mediaTuple.DiskId, out var wixMediaRow)) - { - mediaLayoutFolder = wixMediaRow.Layout; - - if (wixMediaRow.CompressionLevel.HasValue) - { - compressionLevel = wixMediaRow.CompressionLevel.Value; - } - } - - string cabinetDir = this.ResolveMedia(mediaTuple, mediaLayoutFolder, this.LayoutDirectory); + var files = entry.Value; + var compressionLevel = mediaTuple.CompressionLevel ?? this.DefaultCompressionLevel ?? CompressionLevel.Medium; + var cabinetDir = this.ResolveMedia(mediaTuple, mediaTuple.Layout, this.LayoutDirectory); var cabinetWorkItem = this.CreateCabinetWorkItem(this.Output, cabinetDir, mediaTuple, compressionLevel, files); if (null != cabinetWorkItem) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index 6f33080d..e1781daf 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -14,6 +14,9 @@ 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(IntermediateSection section, TableDefinitionCollection tableDefinitions, IEnumerable backendExtensions) { this.Section = section; @@ -46,6 +49,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind { switch (tuple.Definition.Type) { + case TupleDefinitionType.Binary: + this.AddTupleDefaultly(tuple, output, true); + break; + case TupleDefinitionType.BBControl: this.AddBBControlTuple((BBControlTuple)tuple, output); break; @@ -66,6 +73,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddDialogTuple((DialogTuple)tuple, output); break; + case TupleDefinitionType.Directory: + this.AddDirectoryTuple((DirectoryTuple)tuple, output); + break; + case TupleDefinitionType.Environment: this.AddEnvironmentTuple((EnvironmentTuple)tuple, output); break; @@ -102,14 +113,26 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddMsiServiceConfigFailureActionsTuple((MsiServiceConfigFailureActionsTuple)tuple, output); break; + case TupleDefinitionType.MoveFile: + this.AddMoveFileTuple((MoveFileTuple)tuple, output); + break; + case TupleDefinitionType.Property: this.AddPropertyTuple((PropertyTuple)tuple, output); break; + case TupleDefinitionType.RemoveFile: + this.AddRemoveFileTuple((RemoveFileTuple)tuple, output); + break; + case TupleDefinitionType.Registry: this.AddRegistryTuple((RegistryTuple)tuple, output); break; + case TupleDefinitionType.RegLocator: + this.AddRegLocatorTuple((RegLocatorTuple)tuple, output); + break; + case TupleDefinitionType.RemoveRegistry: this.AddRemoveRegistryTuple((RemoveRegistryTuple)tuple, output); break; @@ -138,10 +161,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddWixActionTuple((WixActionTuple)tuple, output); break; - case TupleDefinitionType.WixMedia: - // Ignored. - break; - case TupleDefinitionType.WixMediaTemplate: this.AddWixMediaTemplateTuple((WixMediaTemplateTuple)tuple, output); break; @@ -150,6 +169,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddTupleFromExtension(tuple, output); break; + // ignored. + case TupleDefinitionType.WixFile: + case TupleDefinitionType.WixComponentGroup: + case TupleDefinitionType.WixDeltaPatchFile: + break; + default: this.AddTupleDefaultly(tuple, output); break; @@ -311,6 +336,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[9] = tuple.Control_Cancel; } + private void AddDirectoryTuple(DirectoryTuple tuple, Output output) + { + var table = output.EnsureTable(this.TableDefinitions["Directory"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.Id.Id; + row[1] = tuple.Directory_Parent; + row[2] = tuple.DefaultDir; + } + private void AddEnvironmentTuple(EnvironmentTuple tuple, Output output) { var action = String.Empty; @@ -373,7 +407,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var table = output.EnsureTable(this.TableDefinitions["File"]); var row = (FileRow)table.CreateRow(tuple.SourceLineNumbers); - row.File = tuple.File; + row.File = tuple.Id.Id; row.Component = tuple.Component_; row.FileName = GetMsiFilenameValue(tuple.ShortFileName, tuple.LongFileName); row.FileSize = tuple.FileSize; @@ -392,7 +426,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void AddIniFileTuple(IniFileTuple tuple, Output output) { - string tableName = (InifFileActionType.AddLine == tuple.Action || InifFileActionType.AddTag == tuple.Action || InifFileActionType.CreateLine == tuple.Action) ? "IniFile" : "RemoveIniFile"; + var tableName = (InifFileActionType.AddLine == tuple.Action || InifFileActionType.AddTag == tuple.Action || InifFileActionType.CreateLine == tuple.Action) ? "IniFile" : "RemoveIniFile"; var table = output.EnsureTable(this.TableDefinitions[tableName]); var row = table.CreateRow(tuple.SourceLineNumbers); @@ -487,6 +521,19 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[8] = tuple.Component_; } + private void AddMoveFileTuple(MoveFileTuple tuple, Output output) + { + var table = output.EnsureTable(this.TableDefinitions["MoveFile"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.Id.Id; + row[1] = tuple.Component_; + row[2] = tuple.SourceName; + row[3] = tuple.DestName; + row[4] = tuple.SourceFolder; + row[5] = tuple.DestFolder; + row[6] = tuple.Delete ? WindowsInstallerConstants.MsidbMoveFileOptionsMove : 0; + } + private void AddPropertyTuple(PropertyTuple tuple, Output output) { if (String.IsNullOrEmpty(tuple.Value)) @@ -496,10 +543,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind var table = output.EnsureTable(this.TableDefinitions["Property"]); var row = (PropertyRow)table.CreateRow(tuple.SourceLineNumbers); - row.Property = tuple.Property; + row.Property = tuple.Id.Id; row.Value = tuple.Value; } + private void AddRemoveFileTuple(RemoveFileTuple tuple, Output output) + { + var installMode = tuple.OnInstall == true ? WindowsInstallerConstants.MsidbRemoveFileInstallModeOnInstall : 0; + installMode |= tuple.OnUninstall == true ? WindowsInstallerConstants.MsidbRemoveFileInstallModeOnRemove : 0; + + var table = output.EnsureTable(this.TableDefinitions["RemoveFile"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.Id.Id; + row[1] = tuple.Component_; + row[2] = tuple.FileName; + row[3] = tuple.DirProperty; + row[4] = installMode; + } + private void AddRegistryTuple(RegistryTuple tuple, Output output) { var value = tuple.Value; @@ -552,6 +613,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[5] = tuple.Component_; } + private void AddRegLocatorTuple(RegLocatorTuple tuple, Output output) + { + var type = (int)tuple.Type; + type |= tuple.Win64 ? WindowsInstallerConstants.MsidbLocatorType64bit : 0; + + var table = output.EnsureTable(this.TableDefinitions["RegLocator"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.Id.Id; + row[1] = tuple.Root; + row[2] = tuple.Key; + row[3] = tuple.Name; + row[4] = type; + } + private void AddRemoveRegistryTuple(RemoveRegistryTuple tuple, Output output) { if (tuple.Action == RemoveRegistryActionType.RemoveOnInstall) @@ -684,7 +759,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind sequenceTableDefinition = this.TableDefinitions["AdminUISequence"]; } break; - case SequenceTable.AdvtExecuteSequence: + case SequenceTable.AdvertiseExecuteSequence: if (OutputType.Module == output.Type) { output.EnsureTable(this.TableDefinitions["AdvtExecuteSequence"]); @@ -754,8 +829,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind row.CompressionLevel = tuple.CompressionLevel; row.DiskPrompt = tuple.DiskPrompt; row.VolumeLabel = tuple.VolumeLabel; - row.MaximumUncompressedMediaSize = tuple.MaximumUncompressedMediaSize; - row.MaximumCabinetSizeForLargeFileSplitting = tuple.MaximumCabinetSizeForLargeFileSplitting; + row.MaximumUncompressedMediaSize = tuple.MaximumUncompressedMediaSize ?? DefaultMaximumUncompressedMediaSize; + row.MaximumCabinetSizeForLargeFileSplitting = tuple.MaximumCabinetSizeForLargeFileSplitting ?? MaxValueOfMaxCabSizeForLargeFileSplitting; } private void AddTupleFromExtension(IntermediateTuple tuple, Output output) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs index ab2e8201..b5e5069a 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs @@ -44,8 +44,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (0 < adminProperties.Count) { - var tuple = new PropertyTuple(null, new Identifier("AdminProperties", AccessModifier.Private)); - tuple.Property = "AdminProperties"; + var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "AdminProperties")); tuple.Value = String.Join(";", adminProperties); this.Section.Tuples.Add(tuple); @@ -53,8 +52,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (0 < secureProperties.Count) { - var tuple = new PropertyTuple(null, new Identifier("SecureCustomProperties", AccessModifier.Private)); - tuple.Property = "SecureCustomProperties"; + var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "SecureCustomProperties")); tuple.Value = String.Join(";", secureProperties); this.Section.Tuples.Add(tuple); @@ -62,8 +60,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (0 < hiddenProperties.Count) { - var tuple = new PropertyTuple(null, new Identifier("MsiHiddenProperties", AccessModifier.Private)); - tuple.Property = "MsiHiddenProperties"; + var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "MsiHiddenProperties")); tuple.Value = String.Join(";", hiddenProperties); this.Section.Tuples.Add(tuple); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index 48b208f2..85567471 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs @@ -57,7 +57,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Now since Merge Modules are already slow and generally less desirable than .wixlibs we'll let // this case be slightly more expensive because the cost of maintaining an indexed file row collection // is a lot more costly for the common cases. - var indexedFileFacades = this.FileFacades.ToDictionary(f => f.File.File, StringComparer.Ordinal); + var indexedFileFacades = this.FileFacades.ToDictionary(f => f.File.Id.Id, StringComparer.Ordinal); foreach (var wixMergeRow in this.WixMergeTuples) { @@ -101,42 +101,33 @@ namespace WixToolset.Core.WindowsInstaller.Bind // NOTE: this is very tricky - the merge module file rows are not added to the // file table because they should not be created via idt import. Instead, these // rows are created by merging in the actual modules. - var fileRow = new FileTuple(wixMergeRow.SourceLineNumbers, new Identifier(record[1], AccessModifier.Private)); - fileRow.File = record[1]; + var fileRow = new FileTuple(wixMergeRow.SourceLineNumbers, new Identifier(AccessModifier.Private, record[1])); fileRow.Compressed = wixMergeRow.FileCompression; - //FileRow fileRow = (FileRow)this.FileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); - //fileRow.File = record[1]; - //fileRow.Compressed = wixMergeRow.FileCompression; var wixFileRow = new WixFileTuple(wixMergeRow.SourceLineNumbers); wixFileRow.Directory_ = record[2]; wixFileRow.DiskId = wixMergeRow.DiskId; wixFileRow.PatchGroup = -1; wixFileRow.Source = new IntermediateFieldPathValue { Path = Path.Combine(this.IntermediateFolder, wixMergeRow.Id.Id, record[1]) }; - //WixFileRow wixFileRow = (WixFileRow)this.WixFileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); - //wixFileRow.Directory = record[2]; - //wixFileRow.DiskId = wixMergeRow.DiskId; - //wixFileRow.PatchGroup = -1; - //wixFileRow.Source = Path.Combine(this.IntermediateFolder, "MergeId.", wixMergeRow.Number.ToString(CultureInfo.InvariantCulture), record[1]); var mergeModuleFileFacade = new FileFacade(true, fileRow, wixFileRow); // If case-sensitive collision with another merge module or a user-authored file identifier. - if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.File, out var collidingFacade)) + if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.Id.Id, out var collidingFacade)) { - this.Messaging.Write(ErrorMessages.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.File.File)); + this.Messaging.Write(ErrorMessages.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, collidingFacade.File.Id.Id)); } - else if (uniqueModuleFileIdentifiers.TryGetValue(mergeModuleFileFacade.File.File, out collidingFacade)) // case-insensitive collision with another file identifier in the same merge module + else if (uniqueModuleFileIdentifiers.TryGetValue(mergeModuleFileFacade.File.Id.Id, out collidingFacade)) // case-insensitive collision with another file identifier in the same merge module { - this.Messaging.Write(ErrorMessages.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.File.File, collidingFacade.File.File)); + this.Messaging.Write(ErrorMessages.DuplicateModuleCaseInsensitiveFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id.Id, mergeModuleFileFacade.File.Id.Id, collidingFacade.File.Id.Id)); } else // no collision { mergeModulesFileFacades.Add(mergeModuleFileFacade); // Keep updating the indexes as new rows are added. - indexedFileFacades.Add(mergeModuleFileFacade.File.File, mergeModuleFileFacade); - uniqueModuleFileIdentifiers.Add(mergeModuleFileFacade.File.File, mergeModuleFileFacade); + indexedFileFacades.Add(mergeModuleFileFacade.File.Id.Id, mergeModuleFileFacade); + uniqueModuleFileIdentifiers.Add(mergeModuleFileFacade.File.Id.Id, mergeModuleFileFacade); } containsFiles = true; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs index 70ba971f..3b7627c8 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs @@ -25,14 +25,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var facades = new List(); - var wixFiles = this.Section.Tuples.OfType().ToDictionary(t => t.File_); - var deltaPatchFiles = this.Section.Tuples.OfType().ToDictionary(t => t.File_); + var wixFiles = this.Section.Tuples.OfType().ToDictionary(t => t.Id.Id); + var deltaPatchFiles = this.Section.Tuples.OfType().ToDictionary(t => t.Id.Id); foreach (var file in this.Section.Tuples.OfType()) { - var wixFile = wixFiles[file.File]; + var wixFile = wixFiles[file.Id.Id]; - deltaPatchFiles.TryGetValue(file.File, out var deltaPatchFile); + deltaPatchFiles.TryGetValue(file.Id.Id, out var deltaPatchFile); facades.Add(new FileFacade(file, wixFile, deltaPatchFile)); } @@ -51,12 +51,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind ILookup filesByDirectory = null; ILookup filesByDiskId = null; - foreach (var row in this.Section.Tuples.OfType().OrderBy(r => r.Type)) + foreach (var row in this.Section.Tuples.OfType().OrderBy(r => r.SymbolType)) { - switch (row.Type) + switch (row.SymbolType) { case SymbolPathType.File: - this.MergeSymbolPaths(row, deltaPatchFiles[row.Id]); + this.MergeSymbolPaths(row, deltaPatchFiles[row.SymbolId]); break; case SymbolPathType.Component: @@ -65,9 +65,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind filesByComponent = facades.ToLookup(f => f.File.Component_); } - foreach (var facade in filesByComponent[row.Id]) + foreach (var facade in filesByComponent[row.SymbolId]) { - this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]); + this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.Id.Id]); } break; @@ -77,9 +77,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind filesByDirectory = facades.ToLookup(f => f.WixFile.Directory_); } - foreach (var facade in filesByDirectory[row.Id]) + foreach (var facade in filesByDirectory[row.SymbolId]) { - this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]); + this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.Id.Id]); } break; @@ -89,9 +89,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind filesByDiskId = facades.ToLookup(f => f.WixFile.DiskId.ToString(CultureInfo.InvariantCulture)); } - foreach (var facade in filesByDiskId[row.Id]) + foreach (var facade in filesByDiskId[row.SymbolId]) { - this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.File]); + this.MergeSymbolPaths(row, deltaPatchFiles[facade.File.Id.Id]); } break; diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs index 4000c923..db887f09 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs @@ -286,7 +286,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using (Record record = new Record(1)) { - record.SetString(1, file.File.File); + record.SetString(1, file.File.Id.Id); view.Execute(record); } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs index ba6af986..f0a43085 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs @@ -1,4 +1,4 @@ -// 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. +// 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. namespace WixToolset.Core.WindowsInstaller.Bind { @@ -21,7 +21,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.ModularizationGuid = modularizationGuid; // Gather all the unique suppress modularization identifiers. - this.SuppressModularizationIdentifiers = new HashSet(suppressTuples.Select(s => s.WixSuppressModularization)); + this.SuppressModularizationIdentifiers = new HashSet(suppressTuples.Select(s => s.Id.Id)); } private Output Output { get; } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index f5561b42..369c241c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs @@ -54,8 +54,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind var mediaRows = this.Section.Tuples.OfType().ToDictionary(t => t.DiskId); - var wixMediaRows = this.Section.Tuples.OfType().ToDictionary(t => t.DiskId_); - using (Database db = new Database(this.DatabasePath, OpenDatabase.ReadOnly)) { using (View directoryView = db.OpenExecuteView("SELECT `Directory`, `Directory_Parent`, `DefaultDir` FROM `Directory`")) @@ -85,25 +83,20 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var mediaTuple = mediaRows[facade.WixFile.DiskId]; string relativeFileLayoutPath = null; - string mediaLayoutFolder = null; - - if (wixMediaRows.TryGetValue(facade.WixFile.DiskId, out var wixMediaRow)) - { - mediaLayoutFolder = wixMediaRow.Layout; - } + string mediaLayoutFolder = mediaTuple.Layout; var mediaLayoutDirectory = this.ResolveMedia(mediaTuple, mediaLayoutFolder, this.LayoutDirectory); // setup up the query record and find the appropriate file in the // previously executed file view - fileQueryRecord[1] = facade.File.File; + fileQueryRecord[1] = facade.File.Id.Id; fileView.Execute(fileQueryRecord); using (Record fileRecord = fileView.Fetch()) { if (null == fileRecord) { - throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.File)); + throw new WixException(ErrorMessages.FileIdentifierNotFound(facade.File.SourceLineNumbers, facade.File.Id.Id)); } relativeFileLayoutPath = PathResolver.GetFileSourcePath(directories, fileRecord[1], fileRecord[2], this.Compressed, this.LongNamesInImage); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs index f1a47f70..3cba0f51 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs @@ -6,7 +6,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.Collections.Generic; using System.Globalization; using System.Linq; - using WixToolset.Core.Native; using WixToolset.Data; using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; @@ -31,20 +30,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind public IMessaging Messaging { private get; set; } - public void Execute() - { - var actions = this.Section.Tuples.OfType().ToList(); - var suppressActions = this.Section.Tuples.OfType().ToList(); - - this.SequenceActions(actions, suppressActions); - } - /// /// Set sequence numbers for all the actions and create rows in the output object. /// - /// Collection of actions to schedule. - /// Collection of actions to suppress. - private void SequenceActions(List actionRows, List suppressActionRows) + public void Execute() { var overridableActionRows = new Dictionary(); var requiredActionRows = new Dictionary(); @@ -118,7 +107,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // Suppress the required actions that are overridable. - foreach (var suppressActionRow in suppressActionRows) + foreach (var suppressActionRow in this.Section.Tuples.OfType()) { var key = suppressActionRow.Id.Id; @@ -233,7 +222,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (sequenceScheduledActionRow.Sequence == actionRow.Sequence) { - this.Messaging.Write(WarningMessages.ActionSequenceCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, sequenceScheduledActionRow.Action, actionRow.Sequence)); + this.Messaging.Write(WarningMessages.ActionSequenceCollision(actionRow.SourceLineNumbers, actionRow.SequenceTable.ToString(), actionRow.Action, sequenceScheduledActionRow.Action, actionRow.Sequence ?? 0)); if (null != sequenceScheduledActionRow.SourceLineNumbers) { this.Messaging.Write(WarningMessages.ActionSequenceCollision2(sequenceScheduledActionRow.SourceLineNumbers)); @@ -245,7 +234,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } - absoluteActionRows.Sort((x, y) => x.Sequence.CompareTo(y.Sequence)); + absoluteActionRows.Sort((x, y) => (x.Sequence ?? 0).CompareTo(y.Sequence ?? 0)); // Schedule the relatively scheduled actions (by resolving the dependency trees). var previousUsedSequence = 0; @@ -310,7 +299,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var nextUsedSequence = Int16.MaxValue + 1; if (absoluteActionRows.Count > j + 1) { - nextUsedSequence = absoluteActionRows[j + 1].Sequence; + nextUsedSequence = absoluteActionRows[j + 1].Sequence ?? 0; } // Schedule the action rows after this one. @@ -337,7 +326,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // keep track of this sequence number as the previous used sequence number for the next iteration - previousUsedSequence = absoluteActionRow.Sequence; + previousUsedSequence = absoluteActionRow.Sequence ?? 0; } // add the absolutely and relatively scheduled actions to the list of scheduled actions @@ -412,9 +401,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind set.Add("InstallExecuteSequence/AppSearch"); set.Add("InstallUISequence/AppSearch"); break; - case TupleDefinitionType.BindImage: - set.Add("InstallExecuteSequence/BindImage"); - break; case TupleDefinitionType.CCPSearch: set.Add("InstallExecuteSequence/AppSearch"); set.Add("InstallExecuteSequence/CCPSearch"); @@ -452,10 +438,32 @@ namespace WixToolset.Core.WindowsInstaller.Bind case TupleDefinitionType.File: set.Add("InstallExecuteSequence/InstallFiles"); set.Add("InstallExecuteSequence/RemoveFiles"); - break; - case TupleDefinitionType.Font: - set.Add("InstallExecuteSequence/RegisterFonts"); - set.Add("InstallExecuteSequence/UnregisterFonts"); + + var foundFont = false; + var foundSelfReg = false; + var foundBindPath = false; + foreach (var file in this.Section.Tuples.OfType()) + { + if (!foundFont && !String.IsNullOrEmpty(file.FontTitle)) + { + set.Add("InstallExecuteSequence/RegisterFonts"); + set.Add("InstallExecuteSequence/UnregisterFonts"); + foundFont = true; + } + + if (!foundSelfReg && file.SelfRegCost.HasValue) + { + set.Add("InstallExecuteSequence/SelfRegModules"); + set.Add("InstallExecuteSequence/SelfUnregModules"); + foundSelfReg = true; + } + + if (!foundBindPath && !String.IsNullOrEmpty(file.BindPath)) + { + set.Add("InstallExecuteSequence/BindImage"); + foundBindPath = true; + } + } break; case TupleDefinitionType.IniFile: case TupleDefinitionType.RemoveIniFile: @@ -511,10 +519,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind case TupleDefinitionType.RemoveFile: set.Add("InstallExecuteSequence/RemoveFiles"); break; - case TupleDefinitionType.SelfReg: - set.Add("InstallExecuteSequence/SelfRegModules"); - set.Add("InstallExecuteSequence/SelfUnregModules"); - break; case TupleDefinitionType.ServiceControl: set.Add("InstallExecuteSequence/StartServices"); set.Add("InstallExecuteSequence/StopServices"); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs index 0df5329a..c8451a1e 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs @@ -79,7 +79,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (!fileInfo.Exists) { - this.Messaging.Write(ErrorMessages.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.CannotFindFile(file.File.SourceLineNumbers, file.File.Id.Id, file.File.LongFileName, file.WixFile.Source.Path)); return; } @@ -127,16 +127,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind // // Also, if we do not find a matching file identifier then the user provided a default version and is providing a version // for unversioned file. That's allowed but generally a dangerous thing to do so let's point that out to the user. - if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.File, StringComparison.Ordinal))) + if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.Id.Id, StringComparison.Ordinal))) { - this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.Id.Id)); } } else { if (null != file.File.Language) { - this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.Id.Id)); } int[] hash; @@ -162,7 +162,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Section.Tuples.Add(file.Hash); } - file.Hash.File_ = file.File.File; + file.Hash.File_ = file.File.Id.Id; file.Hash.Options = 0; file.Hash.HashPart1 = hash[0]; file.Hash.HashPart2 = hash[1]; @@ -178,7 +178,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { file.File.Version = version; } - else if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.File, StringComparison.Ordinal))) // this looks expensive, but see explanation below. + else if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.Id.Id, StringComparison.Ordinal))) // this looks expensive, but see explanation below. { // The user provided a default version for the file row so we looked for a companion file (a file row with Id matching // the version value). We didn't find it so, we will override the default version they provided with the actual @@ -194,7 +194,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (!String.IsNullOrEmpty(file.File.Language) && String.IsNullOrEmpty(language)) { - this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.File)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.Id.Id)); } else // override the default provided by the user (usually nothing) with the actual language from the file itself. { @@ -206,13 +206,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (!String.IsNullOrEmpty(file.File.Version)) { - var key = String.Format(CultureInfo.InvariantCulture, "fileversion.{0}", file.File.File); + var key = String.Format(CultureInfo.InvariantCulture, "fileversion.{0}", file.File.Id.Id); this.VariableCache[key] = file.File.Version; } if (!String.IsNullOrEmpty(file.File.Language)) { - var key = String.Format(CultureInfo.InvariantCulture, "filelanguage.{0}", file.File.File); + var key = String.Format(CultureInfo.InvariantCulture, "filelanguage.{0}", file.File.Id.Id); this.VariableCache[key] = file.File.Language; } } @@ -256,7 +256,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // add the assembly name to the information cache if (null != this.VariableCache) { - this.VariableCache[$"assemblyfullname.{file.File.File}"] = assemblyName.GetFullName(); + this.VariableCache[$"assemblyfullname.{file.File.Id.Id}"] = assemblyName.GetFullName(); } } catch (WixException e) @@ -269,10 +269,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind // TODO: Consider passing in the this.FileFacades as an indexed collection instead of searching through // all files like this. Even though this is a rare case it looks like we might be able to index the // file earlier. - var fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); + var fileManifest = this.FileFacades.FirstOrDefault(r => r.File.Id.Id.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); if (null == fileManifest) { - this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); + this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.Id.Id, file.WixFile.File_AssemblyManifest)); } try @@ -358,7 +358,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (this.VariableCache != null) { - var key = String.Format(CultureInfo.InvariantCulture, "assembly{0}.{1}", name, file.File.File).ToLowerInvariant(); + var key = String.Format(CultureInfo.InvariantCulture, "assembly{0}.{1}", name, file.File.Id.Id).ToLowerInvariant(); this.VariableCache[key] = value; } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs index 0767adb0..e6738bb7 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs @@ -1,4 +1,4 @@ -// 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. +// 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. namespace WixToolset.Core.WindowsInstaller.Bind { @@ -6,13 +6,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind using System.Linq; using WixToolset.Core.Bind; using WixToolset.Data; - using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; internal class UpdateMediaSequencesCommand { - public UpdateMediaSequencesCommand(Output output, List fileFacades, Dictionary assignedMediaRows) + public UpdateMediaSequencesCommand(Output output, List fileFacades) { this.Output = output; this.FileFacades = fileFacades; @@ -34,7 +33,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Order by Component to group the files by directory. var optimized = this.OptimizedFileFacades(); - foreach (var fileId in optimized.Select(f => f.File.File)) + foreach (var fileId in optimized.Select(f => f.File.Id.Id)) { var fileRow = fileRows.Get(fileId); fileRow.Sequence = ++lastSequence; @@ -77,7 +76,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - var fileRow = fileRows.Get(facade.File.File); + var fileRow = fileRows.Get(facade.File.Id.Id); fileRow.Sequence = ++lastSequence; } } @@ -103,7 +102,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind mediaRow = mediaRows.Get(facade.WixFile.DiskId); } - var fileRow = fileRows.Get(facade.File.File); + var fileRow = fileRows.Get(facade.File.Id.Id); fileRow.Sequence = ++lastSequence; } } diff --git a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs index b6b6b8c3..b4d25786 100644 --- a/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs +++ b/src/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs @@ -375,7 +375,7 @@ namespace WixToolset.Core.WindowsInstaller case SequenceTable.AdminUISequence: sequenceElement = new Wix.AdminUISequence(); break; - case SequenceTable.AdvtExecuteSequence: + case SequenceTable.AdvertiseExecuteSequence: sequenceElement = new Wix.AdvertiseExecuteSequence(); break; case SequenceTable.InstallExecuteSequence: diff --git a/src/WixToolset.Core.WindowsInstaller/Differ.cs b/src/WixToolset.Core.WindowsInstaller/Differ.cs index c7fe8960..209773e0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Differ.cs +++ b/src/WixToolset.Core.WindowsInstaller/Differ.cs @@ -8,6 +8,7 @@ namespace WixToolset.Core.WindowsInstaller using System.Globalization; using WixToolset.Core.WindowsInstaller.Msi; using WixToolset.Data; + using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility; @@ -18,7 +19,7 @@ namespace WixToolset.Core.WindowsInstaller /// public sealed class Differ { - private List inspectorExtensions; + private readonly List inspectorExtensions; private bool showPedanticMessages; private bool suppressKeepingSpecialRows; private bool preserveUnchangedRows; diff --git a/src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs b/src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs index 9964b414..5abf02ce 100644 --- a/src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs +++ b/src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs @@ -16,7 +16,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows // TODO: Remove this internal sealed class WixActionRowCollection : ICollection { - private SortedList collection; + private readonly SortedList collection; /// /// Creates a new action table object. @@ -235,7 +235,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows string id = null; string condition = null; bool empty = reader.IsEmptyElement; - int sequence = int.MinValue; + int sequence = Int32.MinValue; int sequenceCount = 0; SequenceTable[] sequenceTables = new SequenceTable[Enum.GetValues(typeof(SequenceTable)).Length]; @@ -263,7 +263,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows case "AdvtExecuteSequence": if (reader.Value.Equals("yes")) { - sequenceTables[sequenceCount] = SequenceTable.AdvtExecuteSequence; + sequenceTables[sequenceCount] = SequenceTable.AdvertiseExecuteSequence; ++sequenceCount; } break; @@ -295,7 +295,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows throw new XmlException(); } - if (int.MinValue == sequence) + if (Int32.MinValue == sequence) { throw new XmlException(); } @@ -316,7 +316,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows // create the actions WixActionRow[] actionRows = new WixActionRow[sequenceCount]; - for (int i = 0; i < sequenceCount; i++) + for (var i = 0; i < sequenceCount; i++) { //WixActionRow actionRow = new WixActionRow(sequenceTables[i], id, condition, sequence); //actionRows[i] = actionRow; -- cgit v1.2.3-55-g6feb