From 354f6d5b79404544cb7c0e11a0d9212b4780ce09 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 23 May 2019 15:37:56 -0700 Subject: Integrate latest Data changes for FileTuple and AssemblyTuple --- .../Bind/AssignMediaCommand.cs | 32 +++--- .../Bind/BindDatabaseCommand.cs | 2 +- .../Bind/CabinetBuilder.cs | 4 +- .../Bind/CabinetResolver.cs | 2 +- .../Bind/CreateCabinetsCommand.cs | 3 + .../Bind/CreateOutputFromIRCommand.cs | 14 +-- .../Bind/ExtractMergeModuleFilesCommand.cs | 15 ++- .../Bind/GetFileFacadesCommand.cs | 23 ++-- .../Bind/MergeModulesCommand.cs | 19 ++-- .../Bind/ProcessUncompressedFilesCommand.cs | 4 +- .../Bind/SequenceActionsCommand.cs | 2 +- .../Bind/UpdateFileFacadesCommand.cs | 118 ++++++++++----------- .../Bind/UpdateMediaSequencesCommand.cs | 18 ++-- .../Unbind/UnbindDatabaseCommand.cs | 3 + 14 files changed, 133 insertions(+), 126 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 8c6a3e67..2199bbde 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs @@ -156,13 +156,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind throw new WixException(ErrorMessages.MaximumUncompressedMediaSizeTooLarge(null, maxPreCabSizeInMB)); } - foreach (FileFacade facade in this.FileFacades) + foreach (var facade in this.FileFacades) { // When building a product, if the current file is not to be compressed or if // the package set not to be compressed, don't cab it. - if (SectionType.Product == this.Section.Type && - ((facade.File.Compressed.HasValue && !facade.File.Compressed.Value) || - (!facade.File.Compressed.HasValue && !this.FilesCompressed))) + if (SectionType.Product == this.Section.Type && (facade.Uncompressed || !this.FilesCompressed)) { uncompressedFiles.Add(facade); continue; @@ -171,8 +169,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (currentCabIndex == MaxCabIndex) { // Associate current file with last cab (irrespective of the size) and cab index is not incremented anymore. - List cabinetFiles = filesByCabinetMedia[currentMediaRow]; - facade.WixFile.DiskId = currentCabIndex; + var cabinetFiles = filesByCabinetMedia[currentMediaRow]; + facade.File.DiskId = currentCabIndex; cabinetFiles.Add(facade); continue; } @@ -187,8 +185,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind mediaRows.Add(currentMediaRow.DiskId, currentMediaRow); filesByCabinetMedia.Add(currentMediaRow, new List()); - List cabinetFileRows = filesByCabinetMedia[currentMediaRow]; - facade.WixFile.DiskId = currentCabIndex; + var cabinetFileRows = filesByCabinetMedia[currentMediaRow]; + facade.File.DiskId = currentCabIndex; cabinetFileRows.Add(facade); // Now files larger than MaxUncompressedMediaSize will be the only file in its cabinet so as to respect MaxUncompressedMediaSize currentPreCabSize = (ulong)facade.File.FileSize; @@ -205,8 +203,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind } // Associate current file with current cab. - List cabinetFiles = filesByCabinetMedia[currentMediaRow]; - facade.WixFile.DiskId = currentCabIndex; + var cabinetFiles = filesByCabinetMedia[currentMediaRow]; + facade.File.DiskId = currentCabIndex; cabinetFiles.Add(facade); } } @@ -264,17 +262,17 @@ namespace WixToolset.Core.WindowsInstaller.Bind foreach (FileFacade facade in fileFacades) { - if (!mediaRows.TryGetValue(facade.WixFile.DiskId, out var mediaRow)) + if (!mediaRows.TryGetValue(facade.DiskId, out var mediaRow)) { - this.Messaging.Write(ErrorMessages.MissingMedia(facade.File.SourceLineNumbers, facade.WixFile.DiskId)); + this.Messaging.Write(ErrorMessages.MissingMedia(facade.File.SourceLineNumbers, facade.DiskId)); continue; } - // When building a product, if the current file is not to be compressed or if + // When building a product, if the current file is to be uncompressed or if // the package set not to be compressed, don't cab it. - if (SectionType.Product == this.Section.Type && - ((!facade.File.Compressed.HasValue && !this.FilesCompressed) || - (facade.File.Compressed.HasValue && !facade.File.Compressed.Value))) + var compressed = (facade.File.Attributes & FileTupleAttributes.Compressed) == FileTupleAttributes.Compressed; + var uncompressed = (facade.File.Attributes & FileTupleAttributes.Uncompressed) == FileTupleAttributes.Uncompressed; + if (SectionType.Product == this.Section.Type && (uncompressed || (!compressed && !this.FilesCompressed))) { uncompressedFiles.Add(facade); } @@ -286,7 +284,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } else { - this.Messaging.Write(ErrorMessages.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.Id.Id, facade.WixFile.DiskId)); + this.Messaging.Write(ErrorMessages.ExpectedMediaCabinet(facade.File.SourceLineNumbers, facade.File.Id.Id, facade.DiskId)); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index cf7fe423..830880ee 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -526,7 +526,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind 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))); + 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 diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs index 24011214..abf1ef53 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs @@ -166,8 +166,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind var files = cabinetWorkItem.FileFacades .Select(facade => facade.Hash == null ? - 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)) + new CabinetCompressFile(facade.File.Source.Path, facade.File.Id.Id) : + new CabinetCompressFile(facade.File.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 987266f4..3fa3f3a0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetResolver.cs @@ -113,7 +113,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var result = this.ServiceProvider.GetService(); result.Id = facade.File.Id.Id; - result.Path = facade.WixFile.Source.Path; + result.Path = facade.File.Source.Path; return result; } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index be3c720f..95438f96 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs @@ -296,6 +296,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind /// The file token of the first file present in the splitting cabinet internal void NewCabNamesCallBack([MarshalAs(UnmanagedType.LPWStr)]string firstCabName, [MarshalAs(UnmanagedType.LPWStr)]string newCabinetName, [MarshalAs(UnmanagedType.LPWStr)]string fileToken) { + throw new NotImplementedException(); +#if TODO_CAB_SPANNING // Locking Mutex here as this callback can come from Multiple Cabinet Builder Threads var mutex = new Mutex(false, "WixCabinetSplitBinderCallback"); try @@ -417,6 +419,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // Releasing the Mutex here mutex.ReleaseMutex(); } +#endif } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index 57861502..9001b704 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -424,13 +424,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind row.Version = tuple.Version; row.Language = tuple.Language; - var attributes = tuple.Checksum ? WindowsInstallerConstants.MsidbFileAttributesChecksum : 0; - attributes |= (tuple.Compressed.HasValue && tuple.Compressed.Value) ? WindowsInstallerConstants.MsidbFileAttributesCompressed : 0; - attributes |= (tuple.Compressed.HasValue && !tuple.Compressed.Value) ? WindowsInstallerConstants.MsidbFileAttributesNoncompressed : 0; - attributes |= tuple.Hidden ? WindowsInstallerConstants.MsidbFileAttributesHidden : 0; - attributes |= tuple.ReadOnly ? WindowsInstallerConstants.MsidbFileAttributesReadOnly : 0; - attributes |= tuple.System ? WindowsInstallerConstants.MsidbFileAttributesSystem : 0; - attributes |= tuple.Vital ? WindowsInstallerConstants.MsidbFileAttributesVital : 0; + var attributes = (tuple.Attributes & FileTupleAttributes.Checksum) == FileTupleAttributes.Checksum ? WindowsInstallerConstants.MsidbFileAttributesChecksum : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.Compressed) == FileTupleAttributes.Compressed ? WindowsInstallerConstants.MsidbFileAttributesCompressed : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.Uncompressed) == FileTupleAttributes.Uncompressed ? WindowsInstallerConstants.MsidbFileAttributesNoncompressed : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.Hidden) == FileTupleAttributes.Hidden ? WindowsInstallerConstants.MsidbFileAttributesHidden : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.ReadOnly) == FileTupleAttributes.ReadOnly ? WindowsInstallerConstants.MsidbFileAttributesReadOnly : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.System) == FileTupleAttributes.System ? WindowsInstallerConstants.MsidbFileAttributesSystem : 0; + attributes |= (tuple.Attributes & FileTupleAttributes.Vital) == FileTupleAttributes.Vital ? WindowsInstallerConstants.MsidbFileAttributesVital : 0; row.Attributes = attributes; } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index f1a6653c..4105cb8f 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs @@ -101,16 +101,13 @@ 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(AccessModifier.Private, record[1])); - fileRow.Compressed = wixMergeRow.FileCompression; + var fileTuple = new FileTuple(wixMergeRow.SourceLineNumbers, new Identifier(AccessModifier.Private, record[1])); + fileTuple.Attributes = wixMergeRow.FileAttributes; + fileTuple.DirectoryRef = record[2]; + fileTuple.DiskId = wixMergeRow.DiskId; + fileTuple.Source = new IntermediateFieldPathValue { Path = Path.Combine(this.IntermediateFolder, wixMergeRow.Id.Id, record[1]) }; - var wixFileRow = new WixFileTuple(wixMergeRow.SourceLineNumbers); - wixFileRow.DirectoryRef = record[2]; - wixFileRow.DiskId = wixMergeRow.DiskId; - wixFileRow.PatchGroup = -1; - wixFileRow.Source = new IntermediateFieldPathValue { Path = Path.Combine(this.IntermediateFolder, wixMergeRow.Id.Id, record[1]) }; - - var mergeModuleFileFacade = new FileFacade(true, fileRow, wixFileRow); + var mergeModuleFileFacade = new FileFacade(true, fileTuple); // If case-sensitive collision with another merge module or a user-authored file identifier. if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.Id.Id, out var collidingFacade)) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs index db85a6fa..0da6a6b0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs @@ -25,23 +25,29 @@ namespace WixToolset.Core.WindowsInstaller.Bind { var facades = new List(); - var wixFiles = this.Section.Tuples.OfType().ToDictionary(t => t.Id.Id); - var deltaPatchFiles = this.Section.Tuples.OfType().ToDictionary(t => t.Id.Id); + var assemblyFile = this.Section.Tuples.OfType().ToDictionary(t => t.Id.Id); + //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.Id.Id]; + //var wixFile = wixFiles[file.Id.Id]; - deltaPatchFiles.TryGetValue(file.Id.Id, out var deltaPatchFile); + //deltaPatchFiles.TryGetValue(file.Id.Id, out var deltaPatchFile); - facades.Add(new FileFacade(file, wixFile, deltaPatchFile)); + //facades.Add(new FileFacade(file, wixFile, deltaPatchFile)); + + assemblyFile.TryGetValue(file.Id.Id, out var assembly); + + facades.Add(new FileFacade(file, assembly)); } - this.ResolveDeltaPatchSymbolPaths(deltaPatchFiles, facades); + //this.ResolveDeltaPatchSymbolPaths(deltaPatchFiles, facades); this.FileFacades = facades; } +#if FIX_THIS /// /// Merge data from the WixPatchSymbolPaths rows into the WixDeltaPatchFile rows. /// @@ -74,7 +80,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind case SymbolPathType.Directory: if (null == filesByDirectory) { - filesByDirectory = facades.ToLookup(f => f.WixFile.DirectoryRef); + filesByDirectory = facades.ToLookup(f => f.File.DirectoryRef); } foreach (var facade in filesByDirectory[row.SymbolId]) @@ -86,7 +92,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind case SymbolPathType.Media: if (null == filesByDiskId) { - filesByDiskId = facades.ToLookup(f => f.WixFile.DiskId.ToString(CultureInfo.InvariantCulture)); + filesByDiskId = facades.ToLookup(f => f.File.DiskId.ToString(CultureInfo.InvariantCulture)); } foreach (var facade in filesByDiskId[row.SymbolId]) @@ -141,5 +147,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind } #endif } +#endif } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs index db887f09..3c8b4999 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs @@ -11,6 +11,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind using WixToolset.Core.Bind; using WixToolset.Core.WindowsInstaller.Msi; using WixToolset.Data; + using WixToolset.Data.Tuples; using WixToolset.Data.WindowsInstaller; using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility.Services; @@ -297,8 +298,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind throw new InvalidOperationException("Failed to fetch a File row from the database that was merged in from a module."); } - //recordUpdate.SetInteger(1, file.File.Sequence); - throw new NotImplementedException(); + recordUpdate.SetInteger(1, file.File.Sequence); // Update the file attributes to match the compression specified // on the Merge element or on the Package element. @@ -310,22 +310,21 @@ namespace WixToolset.Core.WindowsInstaller.Bind attributes = recordUpdate.GetInteger(2); } - if (!file.File.Compressed.HasValue) - { - // Clear all compression bits. - attributes &= ~WindowsInstallerConstants.MsidbFileAttributesCompressed; - attributes &= ~WindowsInstallerConstants.MsidbFileAttributesNoncompressed; - } - else if (file.File.Compressed.Value) + if ((file.File.Attributes & FileTupleAttributes.Compressed) == FileTupleAttributes.Compressed) { attributes |= WindowsInstallerConstants.MsidbFileAttributesCompressed; attributes &= ~WindowsInstallerConstants.MsidbFileAttributesNoncompressed; } - else if (!file.File.Compressed.Value) + else if ((file.File.Attributes & FileTupleAttributes.Uncompressed) == FileTupleAttributes.Uncompressed) { attributes |= WindowsInstallerConstants.MsidbFileAttributesNoncompressed; attributes &= ~WindowsInstallerConstants.MsidbFileAttributesCompressed; } + else // clear all compression bits. + { + attributes &= ~WindowsInstallerConstants.MsidbFileAttributesCompressed; + attributes &= ~WindowsInstallerConstants.MsidbFileAttributesNoncompressed; + } recordUpdate.SetInteger(2, attributes); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index 369c241c..61e82f68 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs @@ -81,7 +81,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind // for each file in the array of uncompressed files foreach (FileFacade facade in this.FileFacades) { - var mediaTuple = mediaRows[facade.WixFile.DiskId]; + var mediaTuple = mediaRows[facade.DiskId]; string relativeFileLayoutPath = null; string mediaLayoutFolder = mediaTuple.Layout; @@ -105,7 +105,7 @@ 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, facade.File.SourceLineNumbers); + var transfer = this.BackendHelper.CreateFileTransfer(facade.File.Source.Path, fileLayoutPath, false, facade.File.SourceLineNumbers); fileTransfers.Add(transfer); // Track the location where the cabinet will be placed. If the transfer is diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs index 3cba0f51..97602afa 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs @@ -485,7 +485,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind case TupleDefinitionType.MoveFile: set.Add("InstallExecuteSequence/MoveFiles"); break; - case TupleDefinitionType.MsiAssembly: + case TupleDefinitionType.Assembly: set.Add("AdvtExecuteSequence/MsiPublishAssemblies"); set.Add("InstallExecuteSequence/MsiPublishAssemblies"); set.Add("InstallExecuteSequence/MsiUnpublishAssemblies"); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs index 0d15bf2e..397092c4 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs @@ -48,7 +48,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } - private void UpdateFileFacade(FileFacade file) + private void UpdateFileFacade(FileFacade facade) { var assemblyNameTuples = new Dictionary(); foreach (var assemblyTuple in this.Section.Tuples.OfType()) @@ -59,27 +59,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind FileInfo fileInfo = null; try { - fileInfo = new FileInfo(file.WixFile.Source.Path); + fileInfo = new FileInfo(facade.File.Source.Path); } catch (ArgumentException) { - this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(facade.File.SourceLineNumbers, facade.File.Source.Path)); return; } catch (PathTooLongException) { - this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(facade.File.SourceLineNumbers, facade.File.Source.Path)); return; } catch (NotSupportedException) { - this.Messaging.Write(ErrorMessages.InvalidFileName(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.InvalidFileName(facade.File.SourceLineNumbers, facade.File.Source.Path)); return; } if (!fileInfo.Exists) { - this.Messaging.Write(ErrorMessages.CannotFindFile(file.File.SourceLineNumbers, file.File.Id.Id, file.File.Name, file.WixFile.Source.Path)); + this.Messaging.Write(ErrorMessages.CannotFindFile(facade.File.SourceLineNumbers, facade.File.Id.Id, facade.File.Name, facade.File.Source.Path)); return; } @@ -87,10 +87,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (Int32.MaxValue < fileStream.Length) { - throw new WixException(ErrorMessages.FileTooLarge(file.File.SourceLineNumbers, file.WixFile.Source.Path)); + throw new WixException(ErrorMessages.FileTooLarge(facade.File.SourceLineNumbers, facade.File.Source.Path)); } - file.File.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); + facade.File.FileSize = Convert.ToInt32(fileStream.Length, CultureInfo.InvariantCulture); } string version = null; @@ -103,7 +103,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND { - throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); + throw new WixException(ErrorMessages.FileNotFound(facade.File.SourceLineNumbers, fileInfo.FullName)); } else { @@ -118,7 +118,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { // not overwriting hash, so don't do the rest of these options. } - else if (null != file.File.Version) + else if (null != facade.File.Version) { // Search all of the file rows available to see if the specified version is actually a companion file. Yes, this looks // very expensive and you're probably thinking it would be better to create an index of some sort to do an O(1) look up. @@ -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.Id.Id, StringComparison.Ordinal))) + if (!this.FileFacades.Any(r => facade.File.Version.Equals(r.File.Id.Id, StringComparison.Ordinal))) { - this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Version, file.File.Id.Id)); + this.Messaging.Write(WarningMessages.DefaultVersionUsedForUnversionedFile(facade.File.SourceLineNumbers, facade.File.Version, facade.File.Id.Id)); } } else { - if (null != file.File.Language) + if (null != facade.File.Language) { - this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.Id.Id)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForUnversionedFile(facade.File.SourceLineNumbers, facade.File.Language, facade.File.Id.Id)); } int[] hash; @@ -148,7 +148,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (0x2 == e.NativeErrorCode) // ERROR_FILE_NOT_FOUND { - throw new WixException(ErrorMessages.FileNotFound(file.File.SourceLineNumbers, fileInfo.FullName)); + throw new WixException(ErrorMessages.FileNotFound(facade.File.SourceLineNumbers, fileInfo.FullName)); } else { @@ -156,29 +156,29 @@ namespace WixToolset.Core.WindowsInstaller.Bind } } - if (null == file.Hash) + if (null == facade.Hash) { - file.Hash = new MsiFileHashTuple(file.File.SourceLineNumbers, file.File.Id); - this.Section.Tuples.Add(file.Hash); + facade.Hash = new MsiFileHashTuple(facade.File.SourceLineNumbers, facade.File.Id); + this.Section.Tuples.Add(facade.Hash); } - file.Hash.FileRef = file.File.Id.Id; - file.Hash.Options = 0; - file.Hash.HashPart1 = hash[0]; - file.Hash.HashPart2 = hash[1]; - file.Hash.HashPart3 = hash[2]; - file.Hash.HashPart4 = hash[3]; + facade.Hash.FileRef = facade.File.Id.Id; + facade.Hash.Options = 0; + facade.Hash.HashPart1 = hash[0]; + facade.Hash.HashPart2 = hash[1]; + facade.Hash.HashPart3 = hash[2]; + facade.Hash.HashPart4 = hash[3]; } } else // update the file row with the version and language information. { // If no version was provided by the user, use the version from the file itself. // This is the most common case. - if (String.IsNullOrEmpty(file.File.Version)) + if (String.IsNullOrEmpty(facade.File.Version)) { - file.File.Version = version; + facade.File.Version = version; } - else if (!this.FileFacades.Any(r => file.File.Version.Equals(r.File.Id.Id, StringComparison.Ordinal))) // this looks expensive, but see explanation below. + else if (!this.FileFacades.Any(r => facade.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 @@ -189,49 +189,49 @@ namespace WixToolset.Core.WindowsInstaller.Bind // // Also note this case can occur when the file is being updated using the WixBindUpdatedFiles extension mechanism. // That's typically even more rare than companion files so again, no index, just search. - file.File.Version = version; + facade.File.Version = version; } - if (!String.IsNullOrEmpty(file.File.Language) && String.IsNullOrEmpty(language)) + if (!String.IsNullOrEmpty(facade.File.Language) && String.IsNullOrEmpty(language)) { - this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(file.File.SourceLineNumbers, file.File.Language, file.File.Id.Id)); + this.Messaging.Write(WarningMessages.DefaultLanguageUsedForVersionedFile(facade.File.SourceLineNumbers, facade.File.Language, facade.File.Id.Id)); } else // override the default provided by the user (usually nothing) with the actual language from the file itself. { - file.File.Language = language; + facade.File.Language = language; } // Populate the binder variables for this file information if requested. if (null != this.VariableCache) { - if (!String.IsNullOrEmpty(file.File.Version)) + if (!String.IsNullOrEmpty(facade.File.Version)) { - var key = String.Format(CultureInfo.InvariantCulture, "fileversion.{0}", file.File.Id.Id); - this.VariableCache[key] = file.File.Version; + var key = String.Format(CultureInfo.InvariantCulture, "fileversion.{0}", facade.File.Id.Id); + this.VariableCache[key] = facade.File.Version; } - if (!String.IsNullOrEmpty(file.File.Language)) + if (!String.IsNullOrEmpty(facade.File.Language)) { - var key = String.Format(CultureInfo.InvariantCulture, "filelanguage.{0}", file.File.Id.Id); - this.VariableCache[key] = file.File.Language; + var key = String.Format(CultureInfo.InvariantCulture, "filelanguage.{0}", facade.File.Id.Id); + this.VariableCache[key] = facade.File.Language; } } } // If this is a CLR assembly, load the assembly and get the assembly name information - if (FileAssemblyType.DotNetAssembly == file.WixFile.AssemblyType) + if (AssemblyType.DotNetAssembly == facade.Assembly?.Type) { try { - var assemblyName = AssemblyNameReader.ReadAssembly(file.File.SourceLineNumbers, fileInfo.FullName, version); + var assemblyName = AssemblyNameReader.ReadAssembly(facade.File.SourceLineNumbers, fileInfo.FullName, version); - this.SetMsiAssemblyName(assemblyNameTuples, file, "name", assemblyName.Name); - this.SetMsiAssemblyName(assemblyNameTuples, file, "culture", assemblyName.Culture); - this.SetMsiAssemblyName(assemblyNameTuples, file, "version", assemblyName.Version); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "name", assemblyName.Name); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "culture", assemblyName.Culture); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "version", assemblyName.Version); if (!String.IsNullOrEmpty(assemblyName.Architecture)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "processorArchitecture", assemblyName.Architecture); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "processorArchitecture", assemblyName.Architecture); } // TODO: WiX v3 seemed to do this but not clear it should actually be done. //else if (!String.IsNullOrEmpty(file.WixFile.ProcessorArchitecture)) @@ -241,22 +241,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind if (assemblyName.StrongNamedSigned) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "publicKeyToken", assemblyName.PublicKeyToken); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "publicKeyToken", assemblyName.PublicKeyToken); } - else if (file.WixFile.AssemblyApplicationFileRef == null) + else if (facade.Assembly.ApplicationFileRef == null) { - throw new WixException(ErrorMessages.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.ComponentRef)); + throw new WixException(ErrorMessages.GacAssemblyNoStrongName(facade.File.SourceLineNumbers, fileInfo.FullName, facade.File.ComponentRef)); } if (!String.IsNullOrEmpty(assemblyName.FileVersion)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "fileVersion", assemblyName.FileVersion); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "fileVersion", assemblyName.FileVersion); } // add the assembly name to the information cache if (null != this.VariableCache) { - this.VariableCache[$"assemblyfullname.{file.File.Id.Id}"] = assemblyName.GetFullName(); + this.VariableCache[$"assemblyfullname.{facade.File.Id.Id}"] = assemblyName.GetFullName(); } } catch (WixException e) @@ -264,44 +264,44 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.Messaging.Write(e.Error); } } - else if (FileAssemblyType.Win32Assembly == file.WixFile.AssemblyType) + else if (AssemblyType.Win32Assembly == facade.Assembly?.Type) { // 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.FirstOrDefault(r => r.File.Id.Id.Equals(file.WixFile.AssemblyManifestFileRef, StringComparison.Ordinal)); + var fileManifest = this.FileFacades.FirstOrDefault(r => r.File.Id.Id.Equals(facade.Assembly.ManifestFileRef, StringComparison.Ordinal)); if (null == fileManifest) { - this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.Id.Id, file.WixFile.AssemblyManifestFileRef)); + this.Messaging.Write(ErrorMessages.MissingManifestForWin32Assembly(facade.File.SourceLineNumbers, facade.File.Id.Id, facade.Assembly.ManifestFileRef)); } try { - var assemblyName = AssemblyNameReader.ReadAssemblyManifest(file.File.SourceLineNumbers, fileManifest.WixFile.Source.Path); + var assemblyName = AssemblyNameReader.ReadAssemblyManifest(facade.File.SourceLineNumbers, fileManifest.File.Source.Path); if (!String.IsNullOrEmpty(assemblyName.Name)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "name", assemblyName.Name); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "name", assemblyName.Name); } if (!String.IsNullOrEmpty(assemblyName.Version)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "version", assemblyName.Version); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "version", assemblyName.Version); } if (!String.IsNullOrEmpty(assemblyName.Type)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "type", assemblyName.Type); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "type", assemblyName.Type); } if (!String.IsNullOrEmpty(assemblyName.Architecture)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "processorArchitecture", assemblyName.Architecture); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "processorArchitecture", assemblyName.Architecture); } if (!String.IsNullOrEmpty(assemblyName.PublicKeyToken)) { - this.SetMsiAssemblyName(assemblyNameTuples, file, "publicKeyToken", assemblyName.PublicKeyToken); + this.SetMsiAssemblyName(assemblyNameTuples, facade, "publicKeyToken", assemblyName.PublicKeyToken); } } catch (WixException e) @@ -329,8 +329,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind else { // if the assembly will be GAC'd and the name in the file table doesn't match the name in the MsiAssemblyName table, error because the install will fail. - if ("name" == name && FileAssemblyType.DotNetAssembly == file.WixFile.AssemblyType && - String.IsNullOrEmpty(file.WixFile.AssemblyApplicationFileRef) && + if ("name" == name && AssemblyType.DotNetAssembly == file.Assembly.Type && + String.IsNullOrEmpty(file.Assembly.ApplicationFileRef) && !String.Equals(Path.GetFileNameWithoutExtension(file.File.Name), value, StringComparison.OrdinalIgnoreCase)) { this.Messaging.Write(ErrorMessages.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.Name), value)); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs index f9df9636..889d5df2 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateMediaSequencesCommand.cs @@ -51,25 +51,25 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (null == mediaRow) { - mediaRow = mediaRows.Get(facade.WixFile.DiskId); + mediaRow = mediaRows.Get(facade.DiskId); if (OutputType.Patch == this.Output.Type) { // patch Media cannot start at zero lastSequence = mediaRow.LastSequence; } } - else if (mediaRow.DiskId != facade.WixFile.DiskId) + else if (mediaRow.DiskId != facade.DiskId) { mediaRow.LastSequence = lastSequence; - mediaRow = mediaRows.Get(facade.WixFile.DiskId); + mediaRow = mediaRows.Get(facade.DiskId); } - if (0 < facade.WixFile.PatchGroup) + if (facade.File.PatchGroup.HasValue) { - if (patchGroups.TryGetValue(facade.WixFile.PatchGroup, out var patchGroup)) + if (patchGroups.TryGetValue(facade.File.PatchGroup.Value, out var patchGroup)) { patchGroup = new List(); - patchGroups.Add(facade.WixFile.PatchGroup, patchGroup); + patchGroups.Add(facade.File.PatchGroup.Value, patchGroup); } patchGroup.Add(facade); @@ -94,12 +94,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind { if (null == mediaRow) { - mediaRow = mediaRows.Get(facade.WixFile.DiskId); + mediaRow = mediaRows.Get(facade.DiskId); } - else if (mediaRow.DiskId != facade.WixFile.DiskId) + else if (mediaRow.DiskId != facade.DiskId) { mediaRow.LastSequence = lastSequence; - mediaRow = mediaRows.Get(facade.WixFile.DiskId); + mediaRow = mediaRows.Get(facade.DiskId); } var fileRow = fileRows.Get(facade.File.Id.Id); diff --git a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs index 4c24ff7e..e671f6a1 100644 --- a/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs @@ -444,6 +444,8 @@ namespace WixToolset.Core.WindowsInstaller.Unbind /// The Output that represents the msi database. private void GenerateWixFileTable(string databaseFile, Output output) { + throw new NotImplementedException(); +#if TODO_FIX_UNBINDING_FILES var adminRootPath = Path.GetDirectoryName(databaseFile); var componentDirectoryIndex = new Hashtable(); @@ -495,6 +497,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind wixFileTable.Rows.Add(wixFileRow); } +#endif } /// -- cgit v1.2.3-55-g6feb