From 4536440f8d76346bcd120fe9e1410e428f855ee9 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 23 Feb 2021 09:27:05 -0800 Subject: Complete implementation of extension handling for finalized symbols --- .../Bind/BindDatabaseCommand.cs | 68 ++++++++++------------ 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 4b3d554a..012c7c4c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -301,41 +301,49 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); } -#if TODO_FINISH_UPDATE // use symbols instead of rows - // Extended binder extensions can be called now that fields are resolved. + // Update symbols that reference text files on disk. { - Table updatedFiles = this.Output.EnsureTable(this.TableDefinitions["WixBindUpdatedFiles"]); - - foreach (IBinderExtension extension in this.Extensions) - { - extension.AfterResolvedFields(this.Output); - } + var command = new UpdateFromTextFilesCommand(this.Messaging, section); + command.Execute(); + } - List updatedFileFacades = new List(); + // Add missing CreateFolder symbols to null-keypath components. + { + var command = new AddCreateFoldersCommand(section); + command.Execute(); + } - foreach (Row updatedFile in updatedFiles.Rows) + // If there are any backend extensions, give them the opportunity to process + // the section now that the fields have all be resolved. + // + if (this.BackendExtensions.Any()) + { + using (new IntermediateFieldContext("wix.bind.finalize")) { - string updatedId = updatedFile.FieldAsString(0); + foreach (var extension in this.BackendExtensions) + { + extension.SymbolsFinalized(section); + } + + var reresolvedFiles = section.Symbols + .OfType() + .Where(s => s.Fields.Any(f => f?.Context == "wix.bind.finalize")) + .ToList(); - FileFacade updatedFacade = fileFacades.First(f => f.File.File.Equals(updatedId)); + if (reresolvedFiles.Any()) + { + var updatedFacades = reresolvedFiles.Select(f => fileFacades.First(ff => ff.Id == f.Id?.Id)); - updatedFileFacades.Add(updatedFacade); + var command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, updatedFacades, variableCache, overwriteHash: false); + command.Execute(); + } } - if (updatedFileFacades.Any()) + if (this.Messaging.EncounteredError) { - UpdateFileFacadesCommand command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, updateFileFacades, variableCache, overwriteHash: false); - //command.FileFacades = fileFacades; - //command.UpdateFileFacades = updatedFileFacades; - //command.ModularizationGuid = modularizationGuid; - //command.Output = this.Output; - //command.OverwriteHash = true; - //command.TableDefinitions = this.TableDefinitions; - //command.VariableCache = variableCache; - command.Execute(); + return null; } } -#endif // Set generated component guids. { @@ -348,18 +356,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); } - // Add missing CreateFolder symbols to null-keypath components. - { - var command = new AddCreateFoldersCommand(section); - command.Execute(); - } - - // Update symbols that reference text files on disk. - { - var command = new UpdateFromTextFilesCommand(this.Messaging, section); - command.Execute(); - } - // Assign files to media and update file sequences. Dictionary> filesByCabinetMedia; IEnumerable uncompressedFiles; -- cgit v1.2.3-55-g6feb