From 2a27f9032aa115bc2f88d9be695d9b049db1a894 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 11 Aug 2018 01:06:40 -0700 Subject: Track files to enable clean builds in MSBuild --- .../Bind/BindDatabaseCommand.cs | 52 +++++++++++++----- .../Bind/BindTransformCommand.cs | 2 +- .../Bind/CabinetResolver.cs | 14 ++--- .../Bind/CreateCabinetsCommand.cs | 62 +++++++++++++--------- .../Bind/GenerateDatabaseCommand.cs | 27 +++++++--- .../Bind/ProcessUncompressedFilesCommand.cs | 18 ++++++- src/WixToolset.Core.WindowsInstaller/MsiBackend.cs | 8 +-- src/WixToolset.Core.WindowsInstaller/MsmBackend.cs | 2 +- .../Unbind/UnbindTranformCommand.cs | 2 +- 9 files changed, 125 insertions(+), 62 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 9194c4c7..a7da13bb 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -39,6 +39,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.FileSystemExtensions = context.FileSystemExtensions; this.Intermediate = context.IntermediateRepresentation; this.OutputPath = context.OutputPath; + this.OutputPdbPath = context.OutputPdbPath; this.IntermediateFolder = context.IntermediateFolder; this.Validator = validator; @@ -71,6 +72,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private string OutputPath { get; } + private string OutputPdbPath { get; } + private bool SuppressAddingValidationRows { get; } private bool SuppressLayout { get; } @@ -83,7 +86,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind public IEnumerable FileTransfers { get; private set; } - public IEnumerable ContentFilePaths { get; private set; } + public IEnumerable TrackedFiles { get; private set; } public Pdb Pdb { get; private set; } @@ -92,6 +95,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var section = this.Intermediate.Sections.Single(); var fileTransfers = new List(); + var trackedFiles = new List(); var containsMergeModules = false; var suppressedTableNames = new HashSet(); @@ -396,6 +400,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Execute(); fileTransfers.AddRange(command.FileTransfers); + trackedFiles.AddRange(command.TrackedFiles); } #if TODO_FINISH_PATCH @@ -416,11 +421,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Generate database file. this.Messaging.Write(VerboseMessages.GeneratingDatabase()); - string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); - this.GenerateDatabase(output, tempDatabaseFile, false, false); - var transfer = this.BackendHelper.CreateFileTransfer(tempDatabaseFile, this.OutputPath, true, FileTransferType.Built); // note where this database needs to move in the future - fileTransfers.Add(transfer); + var trackMsi = this.BackendHelper.TrackFile(this.OutputPath, TrackedFileType.Final); + trackedFiles.Add(trackMsi); + + var temporaryFiles = this.GenerateDatabase(output, trackMsi.Path, false, false); + trackedFiles.AddRange(temporaryFiles); // Stop processing if an error previously occurred. if (this.Messaging.EncounteredError) @@ -455,7 +461,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var command = new MergeModulesCommand(); command.FileFacades = fileFacades; command.Output = output; - command.OutputPath = tempDatabaseFile; + command.OutputPath = this.OutputPath; command.SuppressedTableNames = suppressedTableNames; command.Execute(); } @@ -476,7 +482,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind Messaging.Instance.Write(WixVerboses.ValidatingDatabase()); - this.Validator.Validate(tempDatabaseFile); + this.Validator.Validate(this.OutputPath); stopwatch.Stop(); Messaging.Instance.Write(WixVerboses.ValidatedDatabase(stopwatch.ElapsedMilliseconds)); @@ -498,19 +504,36 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.LayoutDirectory = layoutDirectory; command.LongNamesInImage = longNames; command.ResolveMedia = this.ResolveMedia; - command.DatabasePath = tempDatabaseFile; + command.DatabasePath = this.OutputPath; command.Execute(); fileTransfers.AddRange(command.FileTransfers); + trackedFiles.AddRange(command.TrackedFiles); } - this.FileTransfers = fileTransfers; - this.ContentFilePaths = fileFacades.Select(r => r.WixFile.Source.Path).ToList(); 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.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.WixFile.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); - intermediate.Save(Path.ChangeExtension(this.OutputPath, "wir")); + 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); } #if TODO_FINISH_PATCH @@ -881,9 +904,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// The database file to create. /// Whether to keep columns added in a transform. /// Whether to use a subdirectory based on the file name for intermediate files. - private void GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory) + private IEnumerable GenerateDatabase(Output output, string databaseFile, bool keepAddedColumns, bool useSubdirectory) { var command = new GenerateDatabaseCommand(); + command.BackendHelper = this.BackendHelper; command.Extensions = this.FileSystemExtensions; command.Output = output; command.OutputPath = databaseFile; @@ -891,9 +915,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.UseSubDirectory = useSubdirectory; command.SuppressAddingValidationRows = this.SuppressAddingValidationRows; command.TableDefinitions = this.TableDefinitions; - command.TempFilesLocation = this.IntermediateFolder; + command.IntermediateFolder = this.IntermediateFolder; command.Codepage = this.Codepage; command.Execute(); + + return command.GeneratedTemporaryFiles; } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs index 8cb0e0de..3f5b9f05 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindTransformCommand.cs @@ -465,7 +465,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.Output = output; command.OutputPath = outputPath; command.TableDefinitions = this.TableDefinitions; - command.TempFilesLocation = this.TempFilesLocation; + command.IntermediateFolder = this.TempFilesLocation; command.SuppressAddingValidationRows = true; command.UseSubDirectory = true; command.Execute(); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs index 759fa586..541dacf8 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs @@ -48,7 +48,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // to be built to and check if there is a cabinet that can be reused. if (!String.IsNullOrEmpty(this.CabCachePath)) { - string cabinetName = Path.GetFileName(cabinetPath); + var cabinetName = Path.GetFileName(cabinetPath); resolved.Path = Path.Combine(this.CabCachePath, cabinetName); if (CheckFileExists(resolved.Path)) @@ -57,10 +57,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind // 1. any files are added or removed // 2. order of files changed or names changed // 3. modified time changed - bool cabinetValid = true; + var cabinetValid = true; var cabinet = new Cabinet(resolved.Path); - List fileList = cabinet.Enumerate(); + var fileList = cabinet.Enumerate(); if (filesWithPath.Count() != fileList.Count) { @@ -68,16 +68,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - int i = 0; - foreach (BindFileWithPath file in filesWithPath) + var i = 0; + foreach (var file in filesWithPath) { // First check that the file identifiers match because that is quick and easy. - CabinetFileInfo cabFileInfo = fileList[i]; + var cabFileInfo = fileList[i]; cabinetValid = (cabFileInfo.FileId == file.Id); if (cabinetValid) { // Still valid so ensure the file sizes are the same. - FileInfo fileInfo = new FileInfo(file.Path); + var fileInfo = new FileInfo(file.Path); cabinetValid = (cabFileInfo.Size == fileInfo.Length); if (cabinetValid) { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index ed8f0ece..a85312c4 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -28,6 +28,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private List fileTransfers; + private List trackedFiles; + private FileSplitCabNamesCallback newCabNamesCallBack; private Dictionary lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence @@ -36,6 +38,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind { this.fileTransfers = new List(); + this.trackedFiles = new List(); + this.newCabNamesCallBack = this.NewCabNamesCallBack; this.BackendHelper = backendHelper; @@ -78,8 +82,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind public IEnumerable FileTransfers => this.fileTransfers; + public IEnumerable TrackedFiles => this.trackedFiles; + /// Output to generate image for. - /// Array of files to be transfered. /// The directory in which the image should be layed out. /// Flag if source image should be compressed. /// The uncompressed file rows. @@ -119,7 +124,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind string cabinetDir = this.ResolveMedia(mediaTuple, mediaLayoutFolder, this.LayoutDirectory); - CabinetWorkItem cabinetWorkItem = this.CreateCabinetWorkItem(this.Output, cabinetDir, mediaTuple, compressionLevel, files, this.fileTransfers); + var cabinetWorkItem = this.CreateCabinetWorkItem(this.Output, cabinetDir, mediaTuple, compressionLevel, files); if (null != cabinetWorkItem) { cabinetBuilder.Enqueue(cabinetWorkItem); @@ -188,9 +193,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// Directory to create cabinet in. /// MediaRow containing information about the cabinet. /// Collection of files in this cabinet. - /// Array of files to be transfered. /// created CabinetWorkItem object - private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable fileFacades, List fileTransfers) + private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable fileFacades) { CabinetWorkItem cabinetWorkItem = null; string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); @@ -219,7 +223,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var cabinetResolver = new CabinetResolver(this.CabCachePath, this.BackendExtensions); - ResolvedCabinet resolvedCabinet = cabinetResolver.ResolveCabinet(tempCabinetFileX, fileFacades); + var resolvedCabinet = cabinetResolver.ResolveCabinet(tempCabinetFileX, fileFacades); // create a cabinet work item if it's not being skipped if (CabinetBuildOption.BuildAndCopy == resolvedCabinet.BuildOption || CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption) @@ -248,19 +252,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } + var trackResolvedCabinet = this.BackendHelper.TrackFile(resolvedCabinet.Path, TrackedFileType.Intermediate, mediaRow.SourceLineNumbers); + this.trackedFiles.Add(trackResolvedCabinet); + if (mediaRow.Cabinet.StartsWith("#", StringComparison.Ordinal)) { - Table streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); + var streamsTable = output.EnsureTable(this.TableDefinitions["_Streams"]); - Row streamRow = streamsTable.CreateRow(mediaRow.SourceLineNumbers); + var streamRow = streamsTable.CreateRow(mediaRow.SourceLineNumbers); streamRow[0] = mediaRow.Cabinet.Substring(1); streamRow[1] = resolvedCabinet.Path; } else { - var destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet); - var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, destinationPath, CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption, FileTransferType.Built, mediaRow.SourceLineNumbers); - fileTransfers.Add(transfer); + var trackDestination = this.BackendHelper.TrackFile(Path.Combine(cabinetDir, mediaRow.Cabinet), TrackedFileType.Final, mediaRow.SourceLineNumbers); + this.trackedFiles.Add(trackDestination); + + var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, trackDestination.Path, resolvedCabinet.BuildOption == CabinetBuildOption.BuildAndMove, mediaRow.SourceLineNumbers); + this.fileTransfers.Add(transfer); } return cabinetWorkItem; @@ -298,10 +307,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// The name of splitting cabinet without extention e.g. "cab1". /// The name of the new cabinet that would be formed by splitting e.g. "cab1b.cab" /// The file token of the first file present in the splitting cabinet - internal void NewCabNamesCallBack([MarshalAs(UnmanagedType.LPWStr)]string firstCabName, [MarshalAs(UnmanagedType.LPWStr)]string newCabName, [MarshalAs(UnmanagedType.LPWStr)]string fileToken) + internal void NewCabNamesCallBack([MarshalAs(UnmanagedType.LPWStr)]string firstCabName, [MarshalAs(UnmanagedType.LPWStr)]string newCabinetName, [MarshalAs(UnmanagedType.LPWStr)]string fileToken) { // Locking Mutex here as this callback can come from Multiple Cabinet Builder Threads - Mutex mutex = new Mutex(false, "WixCabinetSplitBinderCallback"); + var mutex = new Mutex(false, "WixCabinetSplitBinderCallback"); try { if (!mutex.WaitOne(0, false)) // Check if you can get the lock @@ -311,19 +320,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind mutex.WaitOne(); // Wait on other thread } - string firstCabinetName = firstCabName + ".cab"; - string newCabinetName = newCabName; - bool transferAdded = false; // Used for Error Handling + var firstCabinetName = firstCabName + ".cab"; + var transferAdded = false; // Used for Error Handling // Create File Transfer for new Cabinet using transfer of Base Cabinet foreach (var transfer in this.FileTransfers) { if (firstCabinetName.Equals(Path.GetFileName(transfer.Source), StringComparison.InvariantCultureIgnoreCase)) { - string newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); - string newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); + var newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); + var newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); + + var trackSource = this.BackendHelper.TrackFile(newCabSourcePath, TrackedFileType.Intermediate, transfer.SourceLineNumbers); + this.trackedFiles.Add(trackSource); + + var trackTarget = this.BackendHelper.TrackFile(newCabTargetPath, TrackedFileType.Final, transfer.SourceLineNumbers); + this.trackedFiles.Add(trackTarget); - var newTransfer = this.BackendHelper.CreateFileTransfer(newCabSourcePath, newCabTargetPath, transfer.Move, FileTransferType.Built, transfer.SourceLineNumbers); + var newTransfer = this.BackendHelper.CreateFileTransfer(trackSource.Path, trackTarget.Path, transfer.Move, transfer.SourceLineNumbers); this.fileTransfers.Add(newTransfer); transferAdded = true; @@ -338,13 +352,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // Add the new Cabinets to media table using LastSequence of Base Cabinet - Table mediaTable = this.Output.Tables["Media"]; - Table wixFileTable = this.Output.Tables["WixFile"]; - int diskIDForLastSplitCabAdded = 0; // The DiskID value for the first cab in this cabinet split chain - int lastSequenceForLastSplitCabAdded = 0; // The LastSequence value for the first cab in this cabinet split chain - bool lastSplitCabinetFound = false; // Used for Error Handling + var mediaTable = this.Output.Tables["Media"]; + var wixFileTable = this.Output.Tables["WixFile"]; + var diskIDForLastSplitCabAdded = 0; // The DiskID value for the first cab in this cabinet split chain + var lastSequenceForLastSplitCabAdded = 0; // The LastSequence value for the first cab in this cabinet split chain + var lastSplitCabinetFound = false; // Used for Error Handling - string lastCabinetOfThisSequence = String.Empty; + var lastCabinetOfThisSequence = String.Empty; // Get the Value of Last Cabinet Added in this split Sequence from Dictionary if (!this.lastCabinetAddedToMediaTable.TryGetValue(firstCabinetName, out lastCabinetOfThisSequence)) { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs index 3ab3b601..4e062696 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs @@ -14,11 +14,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Core.Native; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility.Services; + using WixToolset.Extensibility.Data; internal class GenerateDatabaseCommand { public int Codepage { private get; set; } + public IBackendHelper BackendHelper { private get; set; } + public IEnumerable Extensions { private get; set; } /// @@ -34,7 +37,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind public TableDefinitionCollection TableDefinitions { private get; set; } - public string TempFilesLocation { private get; set; } + public string IntermediateFolder { private get; set; } + + public List GeneratedTemporaryFiles { get; } = new List(); /// /// Whether to use a subdirectory based on the file name for intermediate files. @@ -103,7 +108,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // Set the base directory. - string baseDirectory = this.TempFilesLocation; + var baseDirectory = this.IntermediateFolder; if (this.UseSubDirectory) { @@ -114,7 +119,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind Directory.CreateDirectory(baseDirectory); } - var idtDirectory = Path.Combine(baseDirectory, "idts"); + var idtDirectory = Path.Combine(baseDirectory, "_idts"); Directory.CreateDirectory(idtDirectory); try @@ -137,6 +142,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Output.Codepage = this.Codepage; } + Directory.CreateDirectory(Path.GetDirectoryName(this.OutputPath)); + using (Database db = new Database(this.OutputPath, type)) { // if we're not using the default codepage, import a new one into our @@ -185,6 +192,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind var command = new CreateIdtFileCommand(this.Messaging, importTable, this.Output.Codepage, idtDirectory, this.KeepAddedColumns); command.Execute(); + var buildOutput = this.BackendHelper.TrackFile(command.IdtPath, TrackedFileType.Temporary); + this.GeneratedTemporaryFiles.Add(buildOutput); + db.Import(command.IdtPath); } catch (WixInvalidIdtException) @@ -309,7 +319,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { foreach (SubStorage subStorage in this.Output.SubStorages) { - string transformFile = Path.Combine(this.TempFilesLocation, String.Concat(subStorage.Name, ".mst")); + string transformFile = Path.Combine(this.IntermediateFolder, String.Concat(subStorage.Name, ".mst")); // Bind the transform. this.BindTransform(subStorage.Data, transformFile); @@ -346,7 +356,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind var command = new BindTransformCommand(); command.Messaging = this.Messaging; command.Extensions = this.Extensions; - command.TempFilesLocation = this.TempFilesLocation; + command.TempFilesLocation = this.IntermediateFolder; command.Transform = transform; command.OutputPath = outputPath; command.TableDefinitions = this.TableDefinitions; @@ -356,8 +366,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind private void SetDatabaseCodepage(Database db, int codepage, string idtDirectory) { // write out the _ForceCodepage IDT file - string idtPath = Path.Combine(idtDirectory, "_ForceCodepage.idt"); - using (StreamWriter idtFile = new StreamWriter(idtPath, false, Encoding.ASCII)) + var idtPath = Path.Combine(idtDirectory, "_ForceCodepage.idt"); + using (var idtFile = new StreamWriter(idtPath, false, Encoding.ASCII)) { idtFile.WriteLine(); // dummy column name record idtFile.WriteLine(); // dummy column definition record @@ -365,6 +375,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind idtFile.WriteLine("\t_ForceCodepage"); } + var trackId = this.BackendHelper.TrackFile(idtPath, TrackedFileType.Temporary); + this.GeneratedTemporaryFiles.Add(trackId); + // try to import the table into the MSI try { diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index b09f92bb..3ad74fd1 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs @@ -43,10 +43,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind public IEnumerable FileTransfers { get; private set; } + public IEnumerable TrackedFiles { get; private set; } + public void Execute() { var fileTransfers = new List(); + var trackedFiles = new List(); + var directories = new Dictionary(); var mediaRows = this.Section.Tuples.OfType().ToDictionary(t => t.DiskId); @@ -108,14 +112,26 @@ namespace WixToolset.Core.WindowsInstaller.Bind // finally put together the base media layout path and the relative file layout path var fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); - var transfer = this.BackendHelper.CreateFileTransfer(facade.WixFile.Source.Path, fileLayoutPath, false, FileTransferType.Content, facade.File.SourceLineNumbers); + + var transfer = this.BackendHelper.CreateFileTransfer(facade.WixFile.Source.Path, fileLayoutPath, false, facade.File.SourceLineNumbers); fileTransfers.Add(transfer); + + // Track the location where the cabinet will be placed. If the transfer is + // redundant then then the file should not be cleaned. This is important + // because if the source and destination of the transfer is the same, we + // don't want to clean the file because we'd be deleting the original + // (and that would be bad). + var tracked = this.BackendHelper.TrackFile(transfer.Destination, TrackedFileType.Final, facade.File.SourceLineNumbers); + tracked.Clean = !transfer.Redundant; + + trackedFiles.Add(tracked); } } } } this.FileTransfers = fileTransfers; + this.TrackedFiles = trackedFiles; } } } diff --git a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs index f72a7c66..c0c518f8 100644 --- a/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MsiBackend.cs @@ -29,18 +29,12 @@ namespace WixToolset.Core.WindowsInstaller var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); - var result = new BindResult { FileTransfers = command.FileTransfers, ContentFilePaths = command.ContentFilePaths }; + var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles }; foreach (var extension in backendExtensions) { extension.PostBackendBind(result, command.Pdb); } - - if (!String.IsNullOrEmpty(context.OutputPdbPath)) - { - command.Pdb?.Save(context.OutputPdbPath); - } - return result; } diff --git a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs index 91377b48..6c97f08d 100644 --- a/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs +++ b/src/WixToolset.Core.WindowsInstaller/MsmBackend.cs @@ -28,7 +28,7 @@ namespace WixToolset.Core.WindowsInstaller var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); - var result = new BindResult { FileTransfers = command.FileTransfers, ContentFilePaths = command.ContentFilePaths }; + var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles }; foreach (var extension in backendExtensions) { diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs index 80401822..3c32719e 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindTranformCommand.cs @@ -251,7 +251,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind command.UseSubDirectory = false; command.SuppressAddingValidationRows = true; command.TableDefinitions = this.TableDefinitions; - command.TempFilesLocation = this.IntermediateFolder; + command.IntermediateFolder = this.IntermediateFolder; command.Codepage = -1; command.Execute(); } -- cgit v1.2.3-55-g6feb