@joebigelow / wix / commits / 4536440f

Complete implementation of extension handling for finalized symbols

Rob Mensching committed Feb 23, 2021 at 09:27 UTC 4536440f8d76346bcd120fe9e1410e428f855ee9
1 file changed +32 -36
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+32 -36
@@ -301,41 +301,49 @@ namespace WixToolset.Core.WindowsInstaller.Bind
301 command.Execute();
302 }
303
304 -#if TODO_FINISH_UPDATE // use symbols instead of rows
305 - // Extended binder extensions can be called now that fields are resolved.
304 + // Update symbols that reference text files on disk.
305 {
307 - Table updatedFiles = this.Output.EnsureTable(this.TableDefinitions["WixBindUpdatedFiles"]);
308 -
309 - foreach (IBinderExtension extension in this.Extensions)
310 - {
311 - extension.AfterResolvedFields(this.Output);
312 - }
306 + var command = new UpdateFromTextFilesCommand(this.Messaging, section);
307 + command.Execute();
308 + }
309
314 - List<FileFacade> updatedFileFacades = new List<FileFacade>();
310 + // Add missing CreateFolder symbols to null-keypath components.
311 + {
312 + var command = new AddCreateFoldersCommand(section);
313 + command.Execute();
314 + }
315
316 - foreach (Row updatedFile in updatedFiles.Rows)
316 + // If there are any backend extensions, give them the opportunity to process
317 + // the section now that the fields have all be resolved.
318 + //
319 + if (this.BackendExtensions.Any())
320 + {
321 + using (new IntermediateFieldContext("wix.bind.finalize"))
322 {
318 - string updatedId = updatedFile.FieldAsString(0);
323 + foreach (var extension in this.BackendExtensions)
324 + {
325 + extension.SymbolsFinalized(section);
326 + }
327 +
328 + var reresolvedFiles = section.Symbols
329 + .OfType<FileSymbol>()
330 + .Where(s => s.Fields.Any(f => f?.Context == "wix.bind.finalize"))
331 + .ToList();
332
320 - FileFacade updatedFacade = fileFacades.First(f => f.File.File.Equals(updatedId));
333 + if (reresolvedFiles.Any())
334 + {
335 + var updatedFacades = reresolvedFiles.Select(f => fileFacades.First(ff => ff.Id == f.Id?.Id));
336
322 - updatedFileFacades.Add(updatedFacade);
337 + var command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, updatedFacades, variableCache, overwriteHash: false);
338 + command.Execute();
339 + }
340 }
341
325 - if (updatedFileFacades.Any())
342 + if (this.Messaging.EncounteredError)
343 {
327 - UpdateFileFacadesCommand command = new UpdateFileFacadesCommand(this.Messaging, section, fileFacades, updateFileFacades, variableCache, overwriteHash: false);
328 - //command.FileFacades = fileFacades;
329 - //command.UpdateFileFacades = updatedFileFacades;
330 - //command.ModularizationGuid = modularizationGuid;
331 - //command.Output = this.Output;
332 - //command.OverwriteHash = true;
333 - //command.TableDefinitions = this.TableDefinitions;
334 - //command.VariableCache = variableCache;
335 - command.Execute();
344 + return null;
345 }
346 }
338 -#endif
347
348 // Set generated component guids.
349 {
@@ -348,18 +356,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
356 command.Execute();
357 }
358
351 - // Add missing CreateFolder symbols to null-keypath components.
352 - {
353 - var command = new AddCreateFoldersCommand(section);
354 - command.Execute();
355 - }
356 -
357 - // Update symbols that reference text files on disk.
358 - {
359 - var command = new UpdateFromTextFilesCommand(this.Messaging, section);
360 - command.Execute();
361 - }
362 -
359 // Assign files to media and update file sequences.
360 Dictionary<MediaSymbol, IEnumerable<FileFacade>> filesByCabinetMedia;
361 IEnumerable<FileFacade> uncompressedFiles;