From 9c714a8f1baa6e0130e5cd00cbdca649cebaf6a5 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 25 Oct 2019 00:48:35 -0700 Subject: Update to WixOutput file structure to fix embedded file handling --- .../Bind/BindDatabaseCommand.cs | 66 +++++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 411f64bf..3e4806a7 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -17,11 +17,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// /// Binds a databse. /// - internal class BindDatabaseCommand + internal class BindDatabaseCommand : IDisposable { // As outlined in RFC 4122, this is our namespace for generating name-based (version 3) UUIDs. internal static readonly Guid WixComponentGuidNamespace = new Guid("{3064E5C6-FB63-4FE9-AC49-E446A792EFA5}"); + private bool disposed; + public BindDatabaseCommand(IBindContext context, IEnumerable backendExtension, Validator validator) { this.ServiceProvider = context.ServiceProvider; @@ -92,7 +94,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind public IEnumerable TrackedFiles { get; private set; } - public Pdb Pdb { get; private set; } + public WixOutput Wixout { get; private set; } public void Execute() { @@ -524,29 +526,41 @@ namespace WixToolset.Core.WindowsInstaller.Bind trackedFiles.AddRange(command.TrackedFiles); } - this.Pdb = new Pdb { Output = output }; - - if (!String.IsNullOrEmpty(this.OutputPdbPath)) - { - var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final); - trackedFiles.Add(trackPdb); - - this.Pdb.Save(trackPdb.Path); - } + this.Wixout = this.CreateWixout(trackedFiles, this.Intermediate, output); this.FileTransfers = fileTransfers; // TODO: this is not sufficient to collect all Input files (for example, it misses Binary and Icon tables). - trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers))); + trackedFiles.AddRange(fileFacades.Select(f => this.BackendHelper.TrackFile(f.File.Source.Path, TrackedFileType.Input, f.File.SourceLineNumbers))); this.TrackedFiles = trackedFiles; // TODO: Eventually this gets removed - var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase), this.Intermediate.EmbedFilePaths); + var intermediate = new Intermediate(this.Intermediate.Id, new[] { section }, this.Intermediate.Localizations.ToDictionary(l => l.Culture, StringComparer.OrdinalIgnoreCase)); var trackIntermediate = this.BackendHelper.TrackFile(Path.Combine(this.IntermediateFolder, Path.GetFileName(Path.ChangeExtension(this.OutputPath, "wir"))), TrackedFileType.Intermediate); intermediate.Save(trackIntermediate.Path); trackedFiles.Add(trackIntermediate); + } - //transfer = this.BackendHelper.CreateFileTransfer(intermediatePath, Path.ChangeExtension(this.OutputPath, "wir"), true, FileTransferType.Built); - //fileTransfers.Add(transfer); + private WixOutput CreateWixout(List trackedFiles, Intermediate intermediate, Output output) + { + WixOutput wixout; + + if (String.IsNullOrEmpty(this.OutputPdbPath)) + { + wixout = WixOutput.Create(); + } + else + { + var trackPdb = this.BackendHelper.TrackFile(this.OutputPdbPath, TrackedFileType.Final); + trackedFiles.Add(trackPdb); + + wixout = WixOutput.Create(trackPdb.Path); + } + + intermediate.Save(wixout); + + output.Save(wixout); + + return wixout; } #if TODO_FINISH_PATCH @@ -934,5 +948,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind return command.GeneratedTemporaryFiles; } + + #region IDisposable Support + + public void Dispose() + { + this.Dispose(true); + } + + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + this.Wixout?.Dispose(); + } + + this.disposed = true; + } + } + + #endregion } } -- cgit v1.2.3-55-g6feb