From 63b588262aa0b7869741aa888905c1eeda7ae2f8 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 3 Sep 2022 16:08:33 -0700 Subject: Implement single pass patch build This new implementation of patching in WiX v4 creates an MSP's transforms and MSP file in a single pass. This single pass allows the build to use MSI as the source of files for diffing purposes. Completes 6401 Fixes 4629 --- src/api/wix/WixToolset.Data/ErrorMessages.cs | 3 +- .../Symbols/WixPatchBaselineSymbol.cs | 8 ---- .../WixToolset.Extensibility/Data/IBindContext.cs | 5 +++ .../WixToolset.Extensibility/Data/IFileFacade.cs | 48 ++++------------------ .../Data/IWindowsInstallerDecompileContext.cs | 5 --- .../Services/IBackendHelper.cs | 24 ----------- .../Services/IFileResolver.cs | 38 +++++++++++++++++ .../Services/IWindowsInstallerBackendHelper.cs | 17 ++++++++ 8 files changed, 70 insertions(+), 78 deletions(-) create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IFileResolver.cs (limited to 'src/api') diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index 40378a2e..77ce73aa 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs @@ -651,7 +651,8 @@ namespace WixToolset.Data public static Message FileNotFound(SourceLineNumber sourceLineNumbers, string file, string fileType, IEnumerable checkedPaths) { var combinedCheckedPaths = String.Join(", ", checkedPaths); - return Message(sourceLineNumbers, Ids.FileNotFound, "The system cannot find the file '{0}' with type '{1}'. The following paths were checked: {2}", file, fileType, combinedCheckedPaths); + var withType = String.IsNullOrEmpty(fileType) ? String.Empty : $" with type '{fileType}'"; + return Message(sourceLineNumbers, Ids.FileNotFound, "The system cannot find the file '{0}'{1}. The following paths were checked: {2}", file, withType, combinedCheckedPaths); } public static Message FileOrDirectoryPathRequired(string parameter) diff --git a/src/api/wix/WixToolset.Data/Symbols/WixPatchBaselineSymbol.cs b/src/api/wix/WixToolset.Data/Symbols/WixPatchBaselineSymbol.cs index d7295424..cbf51e2e 100644 --- a/src/api/wix/WixToolset.Data/Symbols/WixPatchBaselineSymbol.cs +++ b/src/api/wix/WixToolset.Data/Symbols/WixPatchBaselineSymbol.cs @@ -14,7 +14,6 @@ namespace WixToolset.Data new IntermediateFieldDefinition(nameof(WixPatchBaselineSymbolFields.ValidationFlags), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(WixPatchBaselineSymbolFields.BaselineFile), IntermediateFieldType.Path), new IntermediateFieldDefinition(nameof(WixPatchBaselineSymbolFields.UpdateFile), IntermediateFieldType.Path), - new IntermediateFieldDefinition(nameof(WixPatchBaselineSymbolFields.TransformFile), IntermediateFieldType.Path), }, typeof(WixPatchBaselineSymbol)); } @@ -28,7 +27,6 @@ namespace WixToolset.Data.Symbols ValidationFlags, BaselineFile, UpdateFile, - TransformFile, } public class WixPatchBaselineSymbol : IntermediateSymbol @@ -66,11 +64,5 @@ namespace WixToolset.Data.Symbols get => this.Fields[(int)WixPatchBaselineSymbolFields.UpdateFile].AsPath(); set => this.Set((int)WixPatchBaselineSymbolFields.UpdateFile, value); } - - public IntermediateFieldPathValue TransformFile - { - get => this.Fields[(int)WixPatchBaselineSymbolFields.TransformFile].AsPath(); - set => this.Set((int)WixPatchBaselineSymbolFields.TransformFile, value); - } } } diff --git a/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs index 671da292..9d663c65 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs @@ -17,6 +17,11 @@ namespace WixToolset.Extensibility.Data /// IServiceProvider ServiceProvider { get; } + /// + /// Bind paths used during resolution. + /// + IReadOnlyCollection BindPaths { get; set; } + /// /// Counnt of threads to use in cabbing. /// diff --git a/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs b/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs index fea00d4e..8a9e3fee 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs @@ -5,33 +5,12 @@ namespace WixToolset.Extensibility.Data using System.Collections.Generic; using WixToolset.Data; using WixToolset.Data.Symbols; - using WixToolset.Data.WindowsInstaller.Rows; /// - /// Interface that provides a common facade over FileSymbol and FileRow. + /// Interface that provides a common facade over file information. /// public interface IFileFacade { - /// - /// Reference to assembly application for this file. - /// - string AssemblyApplicationFileRef { get; } - - /// - /// Reference to assembly manifest for this file. - /// - string AssemblyManifestFileRef { get; } - - /// - /// List of assembly name values in the file. - /// - List AssemblyNames { get; set; } - - /// - /// Optionally indicates what sort of assembly the file is. - /// - AssemblyType? AssemblyType { get; } - /// /// Component containing the file. /// @@ -57,21 +36,6 @@ namespace WixToolset.Extensibility.Data /// int FileSize { get; set; } - /// - /// Indicates whether the file came from a merge module. - /// - bool FromModule { get; } - - /// - /// Indicates whether the file came from a transform. - /// - bool FromTransform { get; } - - /// - /// Hash symbol of the file. - /// - MsiFileHashSymbol Hash { get; set; } - /// /// Underlying identifier of the file. /// @@ -118,9 +82,13 @@ namespace WixToolset.Extensibility.Data string Version { get; set; } /// - /// Gets the underlying FileRow if one is present. + /// Calculated hash of the file. + /// + MsiFileHashSymbol MsiFileHashSymbol { get; set; } + + /// + /// Assembly names found in the file. /// - /// FileRow if one is present, otherwise throws. - FileRow GetFileRow(); + ICollection AssemblyNameSymbols { get; } } } diff --git a/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs index 27d30a5a..7b974942 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/IWindowsInstallerDecompileContext.cs @@ -62,11 +62,6 @@ namespace WixToolset.Extensibility.Data /// string IntermediateFolder { get; set; } - /// - /// Gets or sets whether the decompiler admin image. - /// - bool IsAdminImage { get; set; } - /// /// Gets or sets where to output the result. /// diff --git a/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs index eff42b99..8bb1b2d6 100644 --- a/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs +++ b/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs @@ -5,8 +5,6 @@ namespace WixToolset.Extensibility.Services using System; using System.Collections.Generic; using WixToolset.Data; - using WixToolset.Data.Symbols; - using WixToolset.Data.WindowsInstaller.Rows; using WixToolset.Extensibility.Data; /// @@ -14,28 +12,6 @@ namespace WixToolset.Extensibility.Services /// public interface IBackendHelper : ILayoutServices { - /// - /// Creates a file facade from a FileSymbol and possible AssemblySymbol. - /// - /// FileSymbol backing the facade. - /// AssemblySymbol backing the facade. - /// - IFileFacade CreateFileFacade(FileSymbol file, AssemblySymbol assembly); - - /// - /// Creates a file facade from a File row. - /// - /// FileRow - /// New IFileFacade. - IFileFacade CreateFileFacade(FileRow fileRow); - - /// - /// Creates a file facade from a Merge Module's File symbol. - /// - /// FileSymbol created from a Merge Module. - /// New IFileFacade. - IFileFacade CreateFileFacadeFromMergeModule(FileSymbol fileSymbol); - /// /// Creates a MSI compatible GUID. /// diff --git a/src/api/wix/WixToolset.Extensibility/Services/IFileResolver.cs b/src/api/wix/WixToolset.Extensibility/Services/IFileResolver.cs new file mode 100644 index 00000000..2804cc28 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IFileResolver.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Services +{ + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + /// + /// Interface to resolve file paths using extensions and bind paths. + /// + public interface IFileResolver + { + /// + /// Resolves the source path of a file using binder extensions. + /// + /// Original source value. + /// Extensions used to resolve the file path. + /// Collection of bind paths for the binding stage. + /// Optional source line of source file being resolved. + /// Optional type of source file being resolved. + /// Should return a valid path for the stream to be imported. + string ResolveFile(string source, IEnumerable librarianExtensions, IEnumerable bindPaths, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition); + + /// + /// Resolves the source path of a file using binder extensions. + /// + /// Original source value. + /// Extensions used to resolve the file path. + /// Collection of bind paths for the binding stage. + /// The binding stage used to determine what collection of bind paths will be used + /// Optional source line of source file being resolved. + /// Optional type of source file being resolved. + /// Optional collection of paths already checked. + /// Should return a valid path for the stream to be imported. + string ResolveFile(string source, IEnumerable resolverExtensions, IEnumerable bindPaths, BindStage bindStage, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, IEnumerable alreadyCheckedPaths = null); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs index 81325131..2216e957 100644 --- a/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs +++ b/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs @@ -3,13 +3,30 @@ namespace WixToolset.Extensibility.Services { using WixToolset.Data; + using WixToolset.Data.Symbols; using WixToolset.Data.WindowsInstaller; + using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility.Data; /// /// Interface provided to help Windows Installer backend extensions. /// public interface IWindowsInstallerBackendHelper : IBackendHelper { + /// + /// Creates a file facade from a FileSymbol. + /// + /// FileSymbol backing the facade. + /// + IFileFacade CreateFileFacade(FileSymbol file); + + /// + /// Creates a file facade from a File row. + /// + /// FileRow + /// New IFileFacade. + IFileFacade CreateFileFacade(FileRow fileRow); + /// /// Creates a in the specified table. /// -- cgit v1.2.3-55-g6feb