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 + src/WixToolset.Core/Bind/FileFacade.cs | 14 +-- src/WixToolset.Core/Compiler.cs | 128 ++++++++------------- src/WixToolset.Core/Compiler_2.cs | 1 - src/WixToolset.Core/Linker.cs | 2 +- .../ExtensionFixture.cs | 6 +- .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 36 +++--- .../WixiplFixture.cs | 18 +-- .../WixlibFixture.cs | 22 ++-- 22 files changed, 233 insertions(+), 253 deletions(-) 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 } /// diff --git a/src/WixToolset.Core/Bind/FileFacade.cs b/src/WixToolset.Core/Bind/FileFacade.cs index 825c2c7a..d631a3b5 100644 --- a/src/WixToolset.Core/Bind/FileFacade.cs +++ b/src/WixToolset.Core/Bind/FileFacade.cs @@ -7,27 +7,27 @@ namespace WixToolset.Core.Bind public class FileFacade { - public FileFacade(FileTuple file, WixFileTuple wixFile, WixDeltaPatchFileTuple deltaPatchFile) + public FileFacade(FileTuple file, AssemblyTuple assembly) { this.File = file; - this.WixFile = wixFile; - this.DeltaPatchFile = deltaPatchFile; + this.Assembly = assembly; } - public FileFacade(bool fromModule, FileTuple file, WixFileTuple wixFile) + public FileFacade(bool fromModule, FileTuple file) { this.FromModule = fromModule; this.File = file; - this.WixFile = wixFile; } public bool FromModule { get; } public FileTuple File { get; } - public WixFileTuple WixFile { get; } + public AssemblyTuple Assembly { get; } - public WixDeltaPatchFileTuple DeltaPatchFile { get; } + public int DiskId => this.File.DiskId ?? 0; + + public bool Uncompressed => (this.File.Attributes & FileTupleAttributes.Uncompressed) == FileTupleAttributes.Uncompressed; /// /// Gets the set of MsiAssemblyName rows created for this file. diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index d543c6b8..0dade46d 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -32,7 +32,6 @@ namespace WixToolset.Core private bool compilingModule; private bool compilingProduct; - private bool useShortFileNames; private string activeName; private string activeLanguage; @@ -4184,16 +4183,7 @@ namespace WixToolset.Core } else // add the appropriate part of this directory element to the file source. { - string append = null; - if (this.useShortFileNames) - { - append = !String.IsNullOrEmpty(shortSourceName) ? shortSourceName : shortName; - } - - if (String.IsNullOrEmpty(append)) - { - append = !String.IsNullOrEmpty(sourceName) ? sourceName : name; - } + string append = String.IsNullOrEmpty(sourceName) ? name : sourceName; if (!String.IsNullOrEmpty(append)) { @@ -5486,7 +5476,7 @@ namespace WixToolset.Core { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - var assemblyType = FileAssemblyType.NotAnAssembly; + var assemblyType = AssemblyType.NotAnAssembly; string assemblyApplication = null; string assemblyManifest = null; string bindPath = null; @@ -5538,13 +5528,13 @@ namespace WixToolset.Core switch (assemblyValue) { case ".net": - assemblyType = FileAssemblyType.DotNetAssembly; + assemblyType = AssemblyType.DotNetAssembly; break; case "no": - assemblyType = FileAssemblyType.NotAnAssembly; + assemblyType = AssemblyType.NotAnAssembly; break; case "win32": - assemblyType = FileAssemblyType.Win32Assembly; + assemblyType = AssemblyType.Win32Assembly; break; default: this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "File", "Assembly", assemblyValue, "no", "win32", ".net")); @@ -5743,7 +5733,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DefaultVersion", "CompanionFile", companionFile)); } - if (FileAssemblyType.NotAnAssembly == assemblyType) + if (AssemblyType.NotAnAssembly == assemblyType) { if (null != assemblyManifest) { @@ -5757,7 +5747,7 @@ namespace WixToolset.Core } else { - if (FileAssemblyType.Win32Assembly == assemblyType && null == assemblyManifest) + if (AssemblyType.Win32Assembly == assemblyType && null == assemblyManifest) { this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "AssemblyManifest", "Assembly", "win32")); } @@ -5765,7 +5755,7 @@ namespace WixToolset.Core // allow "*" guid components to omit explicit KeyPath as they can have only one file and therefore this file is the keypath if (YesNoType.Yes != keyPath && "*" != componentGuid) { - this.Core.Write(ErrorMessages.IllegalAttributeValueWithoutOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Assembly", (FileAssemblyType.DotNetAssembly == assemblyType ? ".net" : "win32"), "KeyPath", "yes")); + this.Core.Write(ErrorMessages.IllegalAttributeValueWithoutOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Assembly", (AssemblyType.DotNetAssembly == assemblyType ? ".net" : "win32"), "KeyPath", "yes")); } } @@ -5852,90 +5842,72 @@ namespace WixToolset.Core if (String.IsNullOrEmpty(source)) { - if (!this.useShortFileNames && null != name) - { - source = name; - } - else - { - source = shortName; - } + source = name ?? shortName; } else if (source.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal)) // if source relies on parent directories, append the file name { - if (!this.useShortFileNames && null != name) - { - source = Path.Combine(source, name); - } - else - { - source = Path.Combine(source, shortName); - } + source = null == name ? Path.Combine(source, shortName) : Path.Combine(source, name); } + var attributes = FileTupleAttributes.None; + attributes |= readOnly ? FileTupleAttributes.ReadOnly : 0; + attributes |= hidden ? FileTupleAttributes.Hidden : 0; + attributes |= system ? FileTupleAttributes.System : 0; + attributes |= vital ? FileTupleAttributes.Vital : 0; + attributes |= checksum ? FileTupleAttributes.Checksum : 0; + attributes |= compressed.HasValue && compressed == true ? FileTupleAttributes.Compressed : 0; + attributes |= compressed.HasValue && compressed == false ? FileTupleAttributes.Uncompressed : 0; + attributes |= generatedShortFileName ? FileTupleAttributes.GeneratedShortFileName : 0; + var tuple = new FileTuple(sourceLineNumbers, id) { ComponentRef = componentId, - ShortName = shortName, Name = name, + ShortName = shortName, FileSize = defaultSize, Version = companionFile ?? defaultVersion, Language = defaultLanguage, - ReadOnly = readOnly, - Hidden = hidden, - System = system, - Vital = vital, - Checksum = checksum, - Compressed = compressed, + Attributes = attributes, + + //ReadOnly = readOnly, + //Hidden = hidden, + //System = system, + //Vital = vital, + //Checksum = checksum, + //Compressed = compressed, + //GeneratedShortFileName = generatedShortFileName, + + DirectoryRef = directoryId, + DiskId = (CompilerConstants.IntegerNotSet == diskId) ? null : (int?)diskId, + Source = new IntermediateFieldPathValue { Path = source }, + FontTitle = fontTitle, SelfRegCost = selfRegCost, BindPath = bindPath, - }; - this.Core.AddTuple(tuple); + PatchGroup = (CompilerConstants.IntegerNotSet == patchGroup) ? null : (int?)patchGroup, + PatchAttributes = patchAttributes, - // TODO: Remove all this. - var wixFileRow = (WixFileTuple)this.Core.CreateTuple(sourceLineNumbers, TupleDefinitionType.WixFile, id); - wixFileRow.AssemblyType = assemblyType; - wixFileRow.AssemblyManifestFileRef = assemblyManifest; - wixFileRow.AssemblyApplicationFileRef = assemblyApplication; - wixFileRow.DirectoryRef = directoryId; - wixFileRow.DiskId = (CompilerConstants.IntegerNotSet == diskId) ? 0 : diskId; - wixFileRow.Source = new IntermediateFieldPathValue { Path = source }; - wixFileRow.ProcessorArchitecture = procArch; - wixFileRow.PatchGroup = (CompilerConstants.IntegerNotSet != patchGroup ? patchGroup : -1); - wixFileRow.Attributes = (generatedShortFileName ? 0x1 : 0x0); - wixFileRow.PatchAttributes = patchAttributes; - - // Always create a delta patch row for this file since other elements (like Component and Media) may - // want to add symbol paths to it. - this.Core.AddTuple(new WixDeltaPatchFileTuple(sourceLineNumbers, id) - { + // Delta patching information RetainLengths = protectLengths, IgnoreOffsets = ignoreOffsets, IgnoreLengths = ignoreLengths, - RetainOffsets = protectOffsets - }); + RetainOffsets = protectOffsets, + SymbolPaths = symbols + }; - if (null != symbols) - { - this.Core.AddTuple(new WixDeltaPatchSymbolPathsTuple(sourceLineNumbers) - { - SymbolType = SymbolPathType.File, - SymbolId = id.Id, - SymbolPaths = symbols - }); - } + this.Core.AddTuple(tuple); - if (FileAssemblyType.NotAnAssembly != assemblyType) + if (AssemblyType.NotAnAssembly != assemblyType) { - this.Core.AddTuple(new MsiAssemblyTuple(sourceLineNumbers) + this.Core.AddTuple(new AssemblyTuple(sourceLineNumbers, id) { ComponentRef = componentId, FeatureRef = Guid.Empty.ToString("B"), ManifestFileRef = assemblyManifest, ApplicationFileRef = assemblyApplication, - Type = assemblyType + Type = assemblyType, + ProcessorArchitecture = procArch, }); } } @@ -7599,7 +7571,7 @@ namespace WixToolset.Core var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; var configData = String.Empty; - bool? fileCompression = null; + FileTupleAttributes attributes = 0; string language = null; string sourceFile = null; @@ -7617,7 +7589,9 @@ namespace WixToolset.Core this.Core.CreateSimpleReference(sourceLineNumbers, "Media", diskId.ToString(CultureInfo.InvariantCulture.NumberFormat)); break; case "FileCompression": - fileCompression = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + var compress = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + attributes |= compress == YesNoType.Yes ? FileTupleAttributes.Compressed : 0; + attributes |= compress == YesNoType.No ? FileTupleAttributes.Uncompressed : 0; break; case "Language": language = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); @@ -7692,7 +7666,7 @@ namespace WixToolset.Core SourceFile = sourceFile, DiskId = diskId, ConfigurationData = configData, - FileCompression = fileCompression, + FileAttributes = attributes, FeatureRef = Guid.Empty.ToString("B") }; diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index 9e965465..3ad8acf9 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs @@ -760,7 +760,6 @@ namespace WixToolset.Core if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { sourceBits |= 1; - this.useShortFileNames = true; } break; case "SummaryCodepage": diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index 31b2ef8a..1f28802b 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -320,7 +320,7 @@ namespace WixToolset.Core break; #endif - case TupleDefinitionType.MsiAssembly: + case TupleDefinitionType.Assembly: if (SectionType.Product == resolvedSection.Type) { this.ResolveFeatures(tuple, 0, 1, componentsToFeatures, multipleFeatureComponents); diff --git a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs index 37ff1839..27256d41 100644 --- a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs @@ -58,9 +58,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"extest.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"example.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\example.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"example.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); var example = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single(); Assert.Equal("Foo", example.Id.Id); diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index a329c16a..e30441bf 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -43,9 +43,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().First(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().First(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -78,9 +78,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -309,9 +309,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -344,9 +344,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -444,9 +444,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -480,9 +480,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\candle.exe"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"candle.exe", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\candle.exe"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"candle.exe", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); var msiAssemblyNameTuples = section.Tuples.OfType(); Assert.Equal(new[] diff --git a/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs index d915d02b..dd730501 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixiplFixture.cs @@ -50,9 +50,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().First(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().First(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -120,9 +120,9 @@ namespace WixToolsetTest.CoreIntegration var section = intermediate.Sections.Single(); { - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } { @@ -175,9 +175,9 @@ namespace WixToolsetTest.CoreIntegration var section = intermediate.Sections.Single(); { - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } { diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs index 07044a1f..77daab06 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs @@ -50,9 +50,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().First(); - Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var wixFile = section.Tuples.OfType().First(); + Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"test.txt", wixFile[FileTupleFields.Source].PreviousValue.AsPath().Path); } } @@ -95,9 +95,9 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFile = section.Tuples.OfType().Single(); - Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"example.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuple = section.Tuples.OfType().Single(); + Assert.Equal(Path.Combine(folder, @"data\example.txt"), fileTuple[FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"example.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); var example = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single(); Assert.Equal("Foo", example.Id.Id); @@ -157,11 +157,11 @@ namespace WixToolsetTest.CoreIntegration var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); var section = intermediate.Sections.Single(); - var wixFiles = section.Tuples.OfType().OrderBy(t => Path.GetFileName(t.Source.Path)).ToArray(); - Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFiles[0][WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"example.txt", wixFiles[0][WixFileTupleFields.Source].PreviousValue.AsPath().Path); - Assert.Equal(Path.Combine(folder, @"data\other.txt"), wixFiles[1][WixFileTupleFields.Source].AsPath().Path); - Assert.Equal(@"other.txt", wixFiles[1][WixFileTupleFields.Source].PreviousValue.AsPath().Path); + var fileTuples = section.Tuples.OfType().OrderBy(t => Path.GetFileName(t.Source.Path)).ToArray(); + Assert.Equal(Path.Combine(folder, @"data\example.txt"), fileTuples[0][FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"example.txt", fileTuples[0][FileTupleFields.Source].PreviousValue.AsPath().Path); + Assert.Equal(Path.Combine(folder, @"data\other.txt"), fileTuples[1][FileTupleFields.Source].AsPath().Path); + Assert.Equal(@"other.txt", fileTuples[1][FileTupleFields.Source].PreviousValue.AsPath().Path); var examples = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).ToArray(); Assert.Equal(new[] { "Foo", "Other" }, examples.Select(t => t.Id.Id).ToArray()); -- cgit v1.2.3-55-g6feb