diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-07 14:17:45 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-07 14:17:45 -0800 |
| commit | 54cacc5653a0c8a053d6641badf4470d1b54e865 (patch) | |
| tree | 2a97e4d15e3c715e78c25db02ca7b6f74d20a777 /src | |
| parent | b6e9ba894bafe216348292b7c46212c974d02c39 (diff) | |
| download | wix-54cacc5653a0c8a053d6641badf4470d1b54e865.tar.gz wix-54cacc5653a0c8a053d6641badf4470d1b54e865.tar.bz2 wix-54cacc5653a0c8a053d6641badf4470d1b54e865.zip | |
Enable MSI backends to add custom tables from tuples
Diffstat (limited to 'src')
6 files changed, 73 insertions, 80 deletions
diff --git a/src/WixToolset.Extensibility/BasePreprocessorExtension.cs b/src/WixToolset.Extensibility/BasePreprocessorExtension.cs index acfcd5b9..f5d89103 100644 --- a/src/WixToolset.Extensibility/BasePreprocessorExtension.cs +++ b/src/WixToolset.Extensibility/BasePreprocessorExtension.cs | |||
| @@ -16,7 +16,7 @@ namespace WixToolset.Extensibility | |||
| 16 | protected IPreprocessContext Context { get; private set; } | 16 | protected IPreprocessContext Context { get; private set; } |
| 17 | 17 | ||
| 18 | /// <summary> | 18 | /// <summary> |
| 19 | /// ParserHelper for use by the extension. | 19 | /// PreprocessHelper for use by the extension. |
| 20 | /// </summary> | 20 | /// </summary> |
| 21 | protected IPreprocessHelper PreprocessHelper { get; private set; } | 21 | protected IPreprocessHelper PreprocessHelper { get; private set; } |
| 22 | 22 | ||
diff --git a/src/WixToolset.Extensibility/BaseWindowsInstallerBackendExtension.cs b/src/WixToolset.Extensibility/BaseWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..0bcfce01 --- /dev/null +++ b/src/WixToolset.Extensibility/BaseWindowsInstallerBackendExtension.cs | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensibility | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using WixToolset.Data; | ||
| 7 | using WixToolset.Data.Bind; | ||
| 8 | using WixToolset.Data.Tuples; | ||
| 9 | using WixToolset.Data.WindowsInstaller; | ||
| 10 | using WixToolset.Extensibility.Services; | ||
| 11 | |||
| 12 | /// <summary> | ||
| 13 | /// Base class for creating a preprocessor extension. | ||
| 14 | /// </summary> | ||
| 15 | public abstract class BaseWindowsInstallerBackendExtension : IWindowsInstallerBackendExtension | ||
| 16 | { | ||
| 17 | /// <summary> | ||
| 18 | /// Context for use by the extension. | ||
| 19 | /// </summary> | ||
| 20 | protected IBindContext Context { get; private set; } | ||
| 21 | |||
| 22 | /// <summary> | ||
| 23 | /// Backend helper for use by the extension. | ||
| 24 | /// </summary> | ||
| 25 | protected IWindowsInstallerBackendHelper BackendHelper { get; private set; } | ||
| 26 | |||
| 27 | public virtual void PreBackendBind(IBindContext context) | ||
| 28 | { | ||
| 29 | this.Context = context; | ||
| 30 | |||
| 31 | this.BackendHelper = context.ServiceProvider.GetService<IWindowsInstallerBackendHelper>(); | ||
| 32 | } | ||
| 33 | |||
| 34 | public virtual ResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable<BindFileWithPath> files) | ||
| 35 | { | ||
| 36 | return null; | ||
| 37 | } | ||
| 38 | |||
| 39 | public virtual string ResolveMedia(MediaTuple mediaRow, string mediaLayoutDirectory, string layoutDirectory) | ||
| 40 | { | ||
| 41 | return null; | ||
| 42 | } | ||
| 43 | |||
| 44 | public virtual bool TryAddTupleToOutput(IntermediateTuple tuple, Output output) | ||
| 45 | { | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | |||
| 49 | public virtual void PostBackendBind(BindResult result) | ||
| 50 | { | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
diff --git a/src/WixToolset.Extensibility/ExtensionData.cs b/src/WixToolset.Extensibility/ExtensionData.cs deleted file mode 100644 index 0cd0c420..00000000 --- a/src/WixToolset.Extensibility/ExtensionData.cs +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensibility | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using System.Reflection; | ||
| 8 | using System.Xml; | ||
| 9 | using WixToolset.Data; | ||
| 10 | |||
| 11 | #if BRING_BACK_LATER | ||
| 12 | public abstract class ExtensionData : IExtensionData | ||
| 13 | { | ||
| 14 | /// <summary> | ||
| 15 | /// Gets the optional table definitions for this extension. | ||
| 16 | /// </summary> | ||
| 17 | /// <value>Table definisions for this extension or null if there are no table definitions.</value> | ||
| 18 | public virtual TableDefinitionCollection TableDefinitions | ||
| 19 | { | ||
| 20 | get { return null; } | ||
| 21 | } | ||
| 22 | |||
| 23 | /// <summary> | ||
| 24 | /// Gets the optional default culture. | ||
| 25 | /// </summary> | ||
| 26 | /// <value>The optional default culture.</value> | ||
| 27 | public virtual string DefaultCulture | ||
| 28 | { | ||
| 29 | get { return null; } | ||
| 30 | } | ||
| 31 | |||
| 32 | /// <summary> | ||
| 33 | /// Gets the optional library associated with this extension. | ||
| 34 | /// </summary> | ||
| 35 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
| 36 | /// <returns>The library for this extension or null if there is no library.</returns> | ||
| 37 | public virtual Library GetLibrary(TableDefinitionCollection tableDefinitions) | ||
| 38 | { | ||
| 39 | return null; | ||
| 40 | } | ||
| 41 | |||
| 42 | /// <summary> | ||
| 43 | /// Help for loading a library from an embedded resource. | ||
| 44 | /// </summary> | ||
| 45 | /// <param name="assembly">The assembly containing the embedded resource.</param> | ||
| 46 | /// <param name="resourceName">The name of the embedded resource being requested.</param> | ||
| 47 | /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> | ||
| 48 | /// <returns>The loaded library.</returns> | ||
| 49 | protected static Library LoadLibraryHelper(Assembly assembly, string resourceName, TableDefinitionCollection tableDefinitions) | ||
| 50 | { | ||
| 51 | using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) | ||
| 52 | { | ||
| 53 | UriBuilder uriBuilder = new UriBuilder(assembly.CodeBase); | ||
| 54 | uriBuilder.Scheme = "embeddedresource"; | ||
| 55 | uriBuilder.Fragment = resourceName; | ||
| 56 | |||
| 57 | return Library.Load(resourceStream, uriBuilder.Uri, tableDefinitions, false); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | /// <summary> | ||
| 62 | /// Helper for loading table definitions from an embedded resource. | ||
| 63 | /// </summary> | ||
| 64 | /// <param name="assembly">The assembly containing the embedded resource.</param> | ||
| 65 | /// <param name="resourceName">The name of the embedded resource being requested.</param> | ||
| 66 | /// <returns>The loaded table definitions.</returns> | ||
| 67 | protected static TableDefinitionCollection LoadTableDefinitionHelper(Assembly assembly, string resourceName) | ||
| 68 | { | ||
| 69 | using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) | ||
| 70 | using (XmlReader reader = XmlReader.Create(resourceStream)) | ||
| 71 | { | ||
| 72 | return TableDefinitionCollection.Load(reader); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | #endif | ||
| 77 | } | ||
diff --git a/src/WixToolset.Extensibility/IPreprocessorExtension.cs b/src/WixToolset.Extensibility/IPreprocessorExtension.cs index 8511abbc..68f82693 100644 --- a/src/WixToolset.Extensibility/IPreprocessorExtension.cs +++ b/src/WixToolset.Extensibility/IPreprocessorExtension.cs | |||
| @@ -2,9 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
| 4 | { | 4 | { |
| 5 | using System; | ||
| 6 | using System.Xml.Linq; | 5 | using System.Xml.Linq; |
| 7 | using WixToolset.Data; | ||
| 8 | 6 | ||
| 9 | /// <summary> | 7 | /// <summary> |
| 10 | /// Interface for extending the WiX toolset preprocessor. | 8 | /// Interface for extending the WiX toolset preprocessor. |
diff --git a/src/WixToolset.Extensibility/IWindowsInstallerBackendExtension.cs b/src/WixToolset.Extensibility/IWindowsInstallerBackendExtension.cs index f6ffc69c..ed10a077 100644 --- a/src/WixToolset.Extensibility/IWindowsInstallerBackendExtension.cs +++ b/src/WixToolset.Extensibility/IWindowsInstallerBackendExtension.cs | |||
| @@ -3,8 +3,10 @@ | |||
| 3 | namespace WixToolset.Extensibility | 3 | namespace WixToolset.Extensibility |
| 4 | { | 4 | { |
| 5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
| 6 | using WixToolset.Data; | ||
| 6 | using WixToolset.Data.Bind; | 7 | using WixToolset.Data.Bind; |
| 7 | using WixToolset.Data.Tuples; | 8 | using WixToolset.Data.Tuples; |
| 9 | using WixToolset.Data.WindowsInstaller; | ||
| 8 | using WixToolset.Extensibility.Services; | 10 | using WixToolset.Extensibility.Services; |
| 9 | 11 | ||
| 10 | /// <summary> | 12 | /// <summary> |
| @@ -21,6 +23,8 @@ namespace WixToolset.Extensibility | |||
| 21 | 23 | ||
| 22 | string ResolveMedia(MediaTuple mediaRow, string mediaLayoutDirectory, string layoutDirectory); | 24 | string ResolveMedia(MediaTuple mediaRow, string mediaLayoutDirectory, string layoutDirectory); |
| 23 | 25 | ||
| 26 | bool TryAddTupleToOutput(IntermediateTuple tuple, Output output); | ||
| 27 | |||
| 24 | /// <summary> | 28 | /// <summary> |
| 25 | /// Called after all output changes occur and right before the output is bound into its final format. | 29 | /// Called after all output changes occur and right before the output is bound into its final format. |
| 26 | /// </summary> | 30 | /// </summary> |
diff --git a/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs b/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs new file mode 100644 index 00000000..2de455fd --- /dev/null +++ b/src/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensibility.Services | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Data.WindowsInstaller; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Interface provided to help Windows Installer backend extensions. | ||
| 10 | /// </summary> | ||
| 11 | public interface IWindowsInstallerBackendHelper | ||
| 12 | { | ||
| 13 | bool TryAddTupleToOutputMatchingTableDefinitions(IntermediateTuple tuple, Output output, TableDefinition[] tableDefinitions); | ||
| 14 | } | ||
| 15 | } | ||
