From 2bb37beda887d120a0ddabf874ad25357101faa1 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 1 Nov 2017 10:59:45 -0700 Subject: Update to WiX Intermediate Representation --- .../Bind/AssignMediaCommand.cs | 10 +++--- .../Bind/BindDatabaseCommand.cs | 11 ++++-- .../Bind/CreateDeltaPatchesCommand.cs | 3 ++ .../Bind/ExtractMergeModuleFilesCommand.cs | 31 +++++++++------- .../Bind/GenerateDatabaseCommand.cs | 2 +- .../Bind/GetFileFacadesCommand.cs | 7 ++-- .../Bind/MergeModulesCommand.cs | 22 ++++++------ .../Bind/UpdateFileFacadesCommand.cs | 41 ++++++++++++---------- 8 files changed, 75 insertions(+), 52 deletions(-) (limited to 'src/WixToolset.Core.WindowsInstaller/Bind') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs index 23c481b7..74e2cdb5 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs @@ -66,7 +66,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases // When building merge module, all the files go to "#MergeModule.CABinet". if (OutputType.Module == this.Output.Type) { - Table mergeModuleMediaTable = new Table(null, this.TableDefinitions["Media"]); + Table mergeModuleMediaTable = new Table(this.TableDefinitions["Media"]); mergeModuleMediaRow = (MediaRow)mergeModuleMediaTable.CreateRow(null); mergeModuleMediaRow.Cabinet = "#MergeModule.CABinet"; @@ -150,8 +150,8 @@ namespace WixToolset.Core.WindowsInstaller.Databases // 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 (OutputType.Product == this.Output.Type && - (YesNoType.No == facade.File.Compressed || - (YesNoType.NotSet == facade.File.Compressed && !this.FilesCompressed))) + (!facade.File.Compressed.Value || + (!facade.File.Compressed.HasValue && !this.FilesCompressed))) { uncompressedFiles.Add(facade); continue; @@ -270,8 +270,8 @@ namespace WixToolset.Core.WindowsInstaller.Databases // 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 (OutputType.Product == this.Output.Type && - (YesNoType.No == facade.File.Compressed || - (YesNoType.NotSet == facade.File.Compressed && !this.FilesCompressed))) + (!facade.File.Compressed.Value || + (!facade.File.Compressed.HasValue && !this.FilesCompressed))) { uncompressedFiles.Add(facade); } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 21fbb022..5a61b63c 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs @@ -39,7 +39,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.DelayedFields = context.DelayedFields; this.ExpectedEmbeddedFiles = context.ExpectedEmbeddedFiles; this.Extensions = context.Extensions; - this.Output = context.IntermediateRepresentation; + this.Intermediate = context.IntermediateRepresentation; this.OutputPath = context.OutputPath; this.PdbFile = context.OutputPdbPath; this.IntermediateFolder = context.IntermediateFolder; @@ -69,10 +69,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind private IEnumerable Extensions { get; } - private IEnumerable InspectorExtensions { get; } - private string PdbFile { get; } + private Intermediate Intermediate { get; } + private Output Output { get; } private string OutputPath { get; } @@ -95,6 +95,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind public void Execute() { + this.Intermediate.Save(this.OutputPath); +#if FINISH List fileTransfers = new List(); HashSet suppressedTableNames = new HashSet(); @@ -108,6 +110,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.LocalizeUI(this.Output.Tables); + this.Output = CreateOutputFromIR(this.Intermediate); + // Process the summary information table before the other tables. bool compressed; bool longNames; @@ -1278,6 +1282,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind command.TempFilesLocation = this.IntermediateFolder; command.Codepage = this.Codepage; command.Execute(); +#endif } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs index 767671b8..42a69310 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs @@ -23,6 +23,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases public void Execute() { +#if REVISIT_FOR_PATCHING bool optimizePatchSizeForLargeFiles = false; PatchSymbolFlagsType apiPatchingSymbolFlags = 0; @@ -82,6 +83,8 @@ namespace WixToolset.Core.WindowsInstaller.Databases } } } +#endif + throw new NotImplementedException(); } } } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs index ae76037d..0d3e7bd1 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs @@ -16,6 +16,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases using WixToolset.Core.Native; using WixToolset.Core.Bind; using WixToolset.Core.Cab; + using WixToolset.Data.Tuples; /// /// Retrieve files information and extract them from merge modules. @@ -34,7 +35,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases public bool SuppressLayout { private get; set; } - public string TempFilesLocation { private get; set; } + public string IntermediateFolder { private get; set; } public IEnumerable MergeModulesFileFacades { get; private set; } @@ -95,22 +96,28 @@ namespace WixToolset.Core.WindowsInstaller.Databases // 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. - FileRow fileRow = (FileRow)this.FileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); + var fileRow = new FileTuple(wixMergeRow.SourceLineNumbers, new Identifier(record[1], AccessModifier.Private)); fileRow.File = record[1]; - fileRow.Compressed = wixMergeRow.FileCompression; + fileRow.Compressed = (wixMergeRow.FileCompression == YesNoType.Yes) ? true : (wixMergeRow.FileCompression == YesNoType.No) ? (bool?)false : null; + //FileRow fileRow = (FileRow)this.FileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); + //fileRow.File = record[1]; + //fileRow.Compressed = wixMergeRow.FileCompression; - WixFileRow wixFileRow = (WixFileRow)this.WixFileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); - wixFileRow.Directory = record[2]; + var wixFileRow = new WixFileTuple(wixMergeRow.SourceLineNumbers); + wixFileRow.Directory_ = record[2]; wixFileRow.DiskId = wixMergeRow.DiskId; wixFileRow.PatchGroup = -1; - wixFileRow.Source = String.Concat(this.TempFilesLocation, Path.DirectorySeparatorChar, "MergeId.", wixMergeRow.Number.ToString(CultureInfo.InvariantCulture), Path.DirectorySeparatorChar, record[1]); + wixFileRow.Source = Path.Combine(this.IntermediateFolder, "MergeId.", wixMergeRow.Number.ToString(CultureInfo.InvariantCulture), record[1]); + //WixFileRow wixFileRow = (WixFileRow)this.WixFileTable.CreateRow(wixMergeRow.SourceLineNumbers, false); + //wixFileRow.Directory = record[2]; + //wixFileRow.DiskId = wixMergeRow.DiskId; + //wixFileRow.PatchGroup = -1; + //wixFileRow.Source = Path.Combine(this.IntermediateFolder, "MergeId.", wixMergeRow.Number.ToString(CultureInfo.InvariantCulture), record[1]); - FileFacade mergeModuleFileFacade = new FileFacade(true, fileRow, wixFileRow); - - FileFacade collidingFacade; + var mergeModuleFileFacade = new FileFacade(true, fileRow, wixFileRow); // If case-sensitive collision with another merge module or a user-authored file identifier. - if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.File, out collidingFacade)) + if (indexedFileFacades.TryGetValue(mergeModuleFileFacade.File.File, out var collidingFacade)) { Messaging.Instance.OnMessage(WixErrors.DuplicateModuleFileIdentifier(wixMergeRow.SourceLineNumbers, wixMergeRow.Id, collidingFacade.File.File)); } @@ -188,10 +195,10 @@ namespace WixToolset.Core.WindowsInstaller.Databases string safeMergeId = wixMergeRow.Number.ToString(CultureInfo.InvariantCulture.NumberFormat); // extract the module cabinet, then explode all of the files to a temp directory - string moduleCabPath = String.Concat(this.TempFilesLocation, Path.DirectorySeparatorChar, safeMergeId, ".module.cab"); + string moduleCabPath = String.Concat(this.IntermediateFolder, Path.DirectorySeparatorChar, safeMergeId, ".module.cab"); merge.ExtractCAB(moduleCabPath); - string mergeIdPath = String.Concat(this.TempFilesLocation, Path.DirectorySeparatorChar, "MergeId.", safeMergeId); + string mergeIdPath = String.Concat(this.IntermediateFolder, Path.DirectorySeparatorChar, "MergeId.", safeMergeId); Directory.CreateDirectory(mergeIdPath); using (var extractCab = new WixExtractCab()) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs index 26d254f2..47b58058 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GenerateDatabaseCommand.cs @@ -122,7 +122,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases { if (ColumnType.Object == columnDefinition.Type) { - importTable = new Table(table.Section, table.Definition); + importTable = new Table(table.Definition); hasBinaryColumn = true; break; } diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs index caf8b7a7..9bbb4763 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesCommand.cs @@ -24,6 +24,8 @@ namespace WixToolset.Core.WindowsInstaller.Databases public void Execute() { + throw new NotImplementedException(); +#if TODO List facades = new List(this.FileTable.Rows.Count); RowDictionary wixFiles = new RowDictionary(this.WixFileTable); @@ -44,6 +46,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases } this.FileFacades = facades; +#endif } /// @@ -66,7 +69,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases case SymbolPathType.Component: if (null == filesByComponent) { - filesByComponent = facades.ToLookup(f => f.File.Component); + filesByComponent = facades.ToLookup(f => f.File.Component_); } foreach (FileFacade facade in filesByComponent[row.Id]) @@ -78,7 +81,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases case SymbolPathType.Directory: if (null == filesByDirectory) { - filesByDirectory = facades.ToLookup(f => f.WixFile.Directory); + filesByDirectory = facades.ToLookup(f => f.WixFile.Directory_); } foreach (FileFacade facade in filesByDirectory[row.Id]) diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs index 624cbb43..f1605eca 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/MergeModulesCommand.cs @@ -304,7 +304,8 @@ namespace WixToolset.Core.WindowsInstaller.Databases 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); + //recordUpdate.SetInteger(1, file.File.Sequence); + throw new NotImplementedException(); // update the file attributes to match the compression specified // on the Merge element or on the Package element @@ -316,26 +317,25 @@ namespace WixToolset.Core.WindowsInstaller.Databases attributes = recordUpdate.GetInteger(2); } - if (YesNoType.Yes == file.File.Compressed) + // not specified + if (!file.File.Compressed.HasValue) + { + // clear any compression bits + attributes &= ~MsiInterop.MsidbFileAttributesCompressed; + attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed; + } + else if (file.File.Compressed.Value) { // these are mutually exclusive attributes |= MsiInterop.MsidbFileAttributesCompressed; attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed; } - else if (YesNoType.No == file.File.Compressed) + else if (!file.File.Compressed.Value) { // these are mutually exclusive attributes |= MsiInterop.MsidbFileAttributesNoncompressed; attributes &= ~MsiInterop.MsidbFileAttributesCompressed; } - else // not specified - { - Debug.Assert(YesNoType.NotSet == file.File.Compressed); - - // clear any compression bits - attributes &= ~MsiInterop.MsidbFileAttributesCompressed; - attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed; - } recordUpdate.SetInteger(2, attributes); diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs index cd9444ee..20058597 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs @@ -15,6 +15,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases using WixToolset.Core.Bind; using WixToolset.Data; using WixToolset.Data.Rows; + using WixToolset.Data.Tuples; using WixToolset.Msi; /// @@ -69,7 +70,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases if (!fileInfo.Exists) { - Messaging.Instance.OnMessage(WixErrors.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.FileName, file.WixFile.Source)); + Messaging.Instance.OnMessage(WixErrors.CannotFindFile(file.File.SourceLineNumbers, file.File.File, file.File.LongFileName, file.WixFile.Source)); return; } @@ -148,16 +149,17 @@ namespace WixToolset.Core.WindowsInstaller.Databases if (null == file.Hash) { - Table msiFileHashTable = this.Output.EnsureTable(this.TableDefinitions["MsiFileHash"]); - file.Hash = msiFileHashTable.CreateRow(file.File.SourceLineNumbers); + //Table msiFileHashTable = this.Output.EnsureTable(this.TableDefinitions["MsiFileHash"]); + //file.Hash = msiFileHashTable.CreateRow(file.File.SourceLineNumbers); + throw new NotImplementedException(); } - file.Hash[0] = file.File.File; - file.Hash[1] = 0; - file.Hash[2] = hash[0]; - file.Hash[3] = hash[1]; - file.Hash[4] = hash[2]; - file.Hash[5] = hash[3]; + file.Hash.File_ = file.File.File; + file.Hash.Options = 0; + file.Hash.HashPart1 = hash[0]; + file.Hash.HashPart2 = hash[1]; + file.Hash.HashPart3 = hash[2]; + file.Hash.HashPart4 = hash[3]; } } else // update the file row with the version and language information. @@ -250,9 +252,9 @@ namespace WixToolset.Core.WindowsInstaller.Databases assemblyNameValues.Add("publicKeyToken", publicKeyIsNeutral ? "null" : publicKeyToken.ToUpperInvariant()); assemblyNameValues.Add("publicKeyTokenPreservedCase", publicKeyIsNeutral ? "null" : publicKeyToken); } - else if (file.WixFile.AssemblyApplication == null) + else if (file.WixFile.File_AssemblyApplication == null) { - throw new WixException(WixErrors.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component)); + throw new WixException(WixErrors.GacAssemblyNoStrongName(file.File.SourceLineNumbers, fileInfo.FullName, file.File.Component_)); } string assemblyVersion = referenceIdentity.GetAttribute(null, "Version"); @@ -350,10 +352,10 @@ namespace WixToolset.Core.WindowsInstaller.Databases // 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. - FileFacade fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.AssemblyManifest, StringComparison.Ordinal)); + FileFacade fileManifest = this.FileFacades.SingleOrDefault(r => r.File.File.Equals(file.WixFile.File_AssemblyManifest, StringComparison.Ordinal)); if (null == fileManifest) { - Messaging.Instance.OnMessage(WixErrors.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.AssemblyManifest)); + Messaging.Instance.OnMessage(WixErrors.MissingManifestForWin32Assembly(file.File.SourceLineNumbers, file.File.File, file.WixFile.File_AssemblyManifest)); } string win32Type = null; @@ -476,7 +478,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases // check for null value (this can occur when grabbing the file version from an assembly without one) if (String.IsNullOrEmpty(value)) { - Messaging.Instance.OnMessage(WixWarnings.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component, name)); + Messaging.Instance.OnMessage(WixWarnings.NullMsiAssemblyNameValue(file.File.SourceLineNumbers, file.File.Component_, name)); } else { @@ -485,7 +487,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases // override directly authored value foreach (Row row in assemblyNameTable.Rows) { - if ((string)row[0] == file.File.Component && (string)row[1] == name) + if ((string)row[0] == file.File.Component_ && (string)row[1] == name) { assemblyNameRow = row; break; @@ -494,7 +496,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases // 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.AssemblyApplication) && + String.IsNullOrEmpty(file.WixFile.File_AssemblyApplication) && !String.Equals(Path.GetFileNameWithoutExtension(file.File.LongFileName), value, StringComparison.OrdinalIgnoreCase)) { Messaging.Instance.OnMessage(WixErrors.GACAssemblyIdentityWarning(file.File.SourceLineNumbers, Path.GetFileNameWithoutExtension(file.File.LongFileName), value)); @@ -502,8 +504,10 @@ namespace WixToolset.Core.WindowsInstaller.Databases if (null == assemblyNameRow) { + throw new NotImplementedException(); +#if TODO assemblyNameRow = assemblyNameTable.CreateRow(file.File.SourceLineNumbers); - assemblyNameRow[0] = file.File.Component; + assemblyNameRow[0] = file.File.Component_; assemblyNameRow[1] = name; assemblyNameRow[2] = value; @@ -512,10 +516,11 @@ namespace WixToolset.Core.WindowsInstaller.Databases if (null == file.AssemblyNames) { - file.AssemblyNames = new List(); + file.AssemblyNames = new List(); } file.AssemblyNames.Add(assemblyNameRow); +#endif } else { -- cgit v1.2.3-55-g6feb