From 7417dc10c4cf9da821984cbe9930d93ed879962e Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 22 Apr 2021 06:14:17 -0700 Subject: Move Extensiblity into API/wix --- src/api/wix/CSharp.Build.props | 13 + src/api/wix/Custom.Build.props | 6 + src/api/wix/Directory.Build.props | 29 ++ src/api/wix/Directory.Build.targets | 56 +++ src/api/wix/README-Extensibility.md | 2 + src/api/wix/WixToolset.Extensibility.sln | 36 ++ .../wix/WixToolset.Extensibility/AssemblyInfo.cs | 9 + .../BaseBinderExtension.cs | 47 +++ .../BaseBurnBackendBinderExtension.cs | 94 +++++ .../BaseCompilerExtension.cs | 87 ++++ .../BaseExtensionCommandLine.cs | 51 +++ .../WixToolset.Extensibility/BaseExtensionData.cs | 34 ++ .../BaseExtensionFactory.cs | 39 ++ .../BaseLayoutExtension.cs | 62 +++ .../BaseLibrarianExtension.cs | 71 ++++ .../BaseLinkerExtension.cs | 41 ++ .../BasePreprocessorExtension.cs | 91 ++++ .../BaseResolverExtension.cs | 59 +++ .../BaseWindowsInstallerBackendBinderExtension.cs | 93 ++++ .../WixToolset.Extensibility/CompilerConstants.cs | 42 ++ .../wix/WixToolset.Extensibility/Data/BindStage.cs | 25 ++ .../WixToolset.Extensibility/Data/BurnPlatforms.cs | 25 ++ .../Data/CabinetBuildOption.cs | 25 ++ .../Data/CustomActionPlatforms.cs | 25 ++ .../Data/ExtensionCommandLineSwitch.cs | 20 + .../WixToolset.Extensibility/Data/IBindContext.cs | 120 ++++++ .../Data/IBindFileWithPath.cs | 12 + .../wix/WixToolset.Extensibility/Data/IBindPath.cs | 25 ++ .../WixToolset.Extensibility/Data/IBindResult.cs | 29 ++ .../Data/ICommandLineArguments.cs | 39 ++ .../Data/ICommandLineCommand.cs | 39 ++ .../Data/ICommandLineContext.cs | 17 + .../Data/ICompileContext.cs | 52 +++ .../Data/IComponentKeyPath.cs | 14 + .../Data/IDecompileContext.cs | 59 +++ .../Data/IDecompileResult.cs | 18 + .../WixToolset.Extensibility/Data/IDelayedField.cs | 14 + .../Data/IExpectedExtractFile.cs | 16 + .../WixToolset.Extensibility/Data/IFileFacade.cs | 126 ++++++ .../Data/IFileSystemContext.cs | 24 ++ .../WixToolset.Extensibility/Data/IFileTransfer.cs | 27 ++ .../WixToolset.Extensibility/Data/IIncludedFile.cs | 24 ++ .../Data/IInscribeContext.cs | 21 + .../Data/ILayoutContext.cs | 64 +++ .../Data/ILibraryContext.cs | 55 +++ .../WixToolset.Extensibility/Data/ILinkContext.cs | 50 +++ .../Data/IPreprocessContext.cs | 56 +++ .../Data/IPreprocessResult.cs | 23 + .../Data/IResolveContext.cs | 65 +++ .../Data/IResolveFileResult.cs | 22 + .../Data/IResolveResult.cs | 43 ++ .../Data/IResolvedCabinet.cs | 12 + .../Data/IResolvedDirectory.cs | 19 + .../WixToolset.Extensibility/Data/ITrackedFile.cs | 32 ++ .../Data/IUnbindContext.cs | 24 ++ .../Data/PossibleKeyPathType.cs | 40 ++ .../Data/TrackedFileType.cs | 33 ++ .../DecompilerConstants.cs | 20 + .../DecompilerExtension.cs | 61 +++ .../WixToolset.Extensibility/ExtensionHelper.cs | 55 +++ src/api/wix/WixToolset.Extensibility/IBackend.cs | 19 + .../WixToolset.Extensibility/IBackendFactory.cs | 10 + .../WixToolset.Extensibility/IBinderExtension.cs | 22 + .../IBurnBackendBinderExtension.cs | 64 +++ .../WixToolset.Extensibility/ICompilerExtension.cs | 61 +++ .../IDecompilerExtension.cs | 22 + .../IExtensionCommandLine.cs | 48 +++ .../wix/WixToolset.Extensibility/IExtensionData.cs | 33 ++ .../WixToolset.Extensibility/IExtensionFactory.cs | 20 + .../IFileSystemExtension.cs | 17 + .../wix/WixToolset.Extensibility/IInspectorCore.cs | 15 + .../IInspectorExtension.cs | 60 +++ .../WixToolset.Extensibility/ILayoutExtension.cs | 28 ++ .../ILibrarianExtension.cs | 17 + .../WixToolset.Extensibility/ILinkerExtension.cs | 23 + .../WixToolset.Extensibility/IMessageListener.cs | 34 ++ .../IPreprocessorExtension.cs | 57 +++ .../WixToolset.Extensibility/IResolverExtension.cs | 28 ++ .../WixToolset.Extensibility/IUnbinderExtension.cs | 18 + .../IWindowsInstallerBackendBinderExtension.cs | 65 +++ .../IWindowsInstallerBackendDecompilerExtension.cs | 26 ++ .../WixToolset.Extensibility/InspectorExtension.cs | 63 +++ .../Services/IBackendHelper.cs | 183 ++++++++ .../Services/IBurnBackendHelper.cs | 50 +++ .../Services/ICommandLine.cs | 33 ++ .../Services/ICommandLineParser.cs | 40 ++ .../Services/IExtensionManager.cs | 42 ++ .../Services/IMessaging.cs | 73 ++++ .../Services/IParseHelper.cs | 466 +++++++++++++++++++++ .../Services/IPathResolver.cs | 43 ++ .../Services/IPreprocessHelper.cs | 90 ++++ .../Services/IVariableResolution.cs | 30 ++ .../Services/IVariableResolver.cs | 48 +++ .../Services/IWindowsInstallerBackendHelper.cs | 35 ++ .../Services/IWixBranding.cs | 26 ++ .../Services/IWixtoolsetCoreServiceProvider.cs | 34 ++ .../Services/ServiceProviderExtensions.cs | 48 +++ .../WixToolset.Extensibility.csproj | 23 + .../WixToolset.Extensibility.v3.ncrunchproject | 7 + src/api/wix/appveyor-Extensibility.cmd | 7 + src/api/wix/appveyor-Extensibility.yml | 40 ++ src/api/wix/nuget-Extensibility.config | 9 + 102 files changed, 4509 insertions(+) create mode 100644 src/api/wix/CSharp.Build.props create mode 100644 src/api/wix/Custom.Build.props create mode 100644 src/api/wix/Directory.Build.props create mode 100644 src/api/wix/Directory.Build.targets create mode 100644 src/api/wix/README-Extensibility.md create mode 100644 src/api/wix/WixToolset.Extensibility.sln create mode 100644 src/api/wix/WixToolset.Extensibility/AssemblyInfo.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseCompilerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseExtensionFactory.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseLayoutExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseLibrarianExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseLinkerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BasePreprocessorExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseResolverExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerBackendBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/CompilerConstants.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/BindStage.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/BurnPlatforms.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/CabinetBuildOption.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/CustomActionPlatforms.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IBindFileWithPath.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IBindPath.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IBindResult.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ICommandLineArguments.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ICommandLineContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IDelayedField.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IExpectedExtractFile.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IFileSystemContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IFileTransfer.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IIncludedFile.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IInscribeContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ILayoutContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ILibraryContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ILinkContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IPreprocessContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IPreprocessResult.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IResolveContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IResolveFileResult.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IResolveResult.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IResolvedCabinet.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IResolvedDirectory.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/ITrackedFile.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/PossibleKeyPathType.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/TrackedFileType.cs create mode 100644 src/api/wix/WixToolset.Extensibility/DecompilerConstants.cs create mode 100644 src/api/wix/WixToolset.Extensibility/DecompilerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/ExtensionHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IBackend.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IBackendFactory.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IBurnBackendBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/ICompilerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IExtensionData.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IExtensionFactory.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IFileSystemExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IInspectorCore.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IInspectorExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/ILayoutExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/ILibrarianExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/ILinkerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IMessageListener.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IPreprocessorExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IResolverExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendBinderExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/InspectorExtension.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IBurnBackendHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/ICommandLine.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IExtensionManager.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IPathResolver.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IPreprocessHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IVariableResolution.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IVariableResolver.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IWixBranding.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs create mode 100644 src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.csproj create mode 100644 src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.v3.ncrunchproject create mode 100644 src/api/wix/appveyor-Extensibility.cmd create mode 100644 src/api/wix/appveyor-Extensibility.yml create mode 100644 src/api/wix/nuget-Extensibility.config (limited to 'src/api') diff --git a/src/api/wix/CSharp.Build.props b/src/api/wix/CSharp.Build.props new file mode 100644 index 00000000..81d24ad1 --- /dev/null +++ b/src/api/wix/CSharp.Build.props @@ -0,0 +1,13 @@ + + + + + true + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false + + diff --git a/src/api/wix/Custom.Build.props b/src/api/wix/Custom.Build.props new file mode 100644 index 00000000..889fb62e --- /dev/null +++ b/src/api/wix/Custom.Build.props @@ -0,0 +1,6 @@ + + + + true + + diff --git a/src/api/wix/Directory.Build.props b/src/api/wix/Directory.Build.props new file mode 100644 index 00000000..f83cc154 --- /dev/null +++ b/src/api/wix/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + + + diff --git a/src/api/wix/Directory.Build.targets b/src/api/wix/Directory.Build.targets new file mode 100644 index 00000000..cb988931 --- /dev/null +++ b/src/api/wix/Directory.Build.targets @@ -0,0 +1,56 @@ + + + + + + + false + $(OutputPath)\$(AssemblyName).xml + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + + + + diff --git a/src/api/wix/README-Extensibility.md b/src/api/wix/README-Extensibility.md new file mode 100644 index 00000000..003acd4d --- /dev/null +++ b/src/api/wix/README-Extensibility.md @@ -0,0 +1,2 @@ +# Extensibility +WixToolset.Extensibility - interfaces to extend the WiX Toolset diff --git a/src/api/wix/WixToolset.Extensibility.sln b/src/api/wix/WixToolset.Extensibility.sln new file mode 100644 index 00000000..94ce905c --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility.sln @@ -0,0 +1,36 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.8 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Extensibility", "src\WixToolset.Extensibility\WixToolset.Extensibility.csproj", "{AA049009-D7D9-4C63-8E0D-83206ADCFBD1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x64.ActiveCfg = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x64.Build.0 = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x86.ActiveCfg = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Debug|x86.Build.0 = Debug|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|Any CPU.Build.0 = Release|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x64.ActiveCfg = Release|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x64.Build.0 = Release|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x86.ActiveCfg = Release|Any CPU + {AA049009-D7D9-4C63-8E0D-83206ADCFBD1}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BB8820D5-723D-426D-B4A0-4D221603C5FA} + EndGlobalSection +EndGlobal diff --git a/src/api/wix/WixToolset.Extensibility/AssemblyInfo.cs b/src/api/wix/WixToolset.Extensibility/AssemblyInfo.cs new file mode 100644 index 00000000..b3740b2a --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/AssemblyInfo.cs @@ -0,0 +1,9 @@ +// 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. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyCulture("")] +[assembly: CLSCompliant(true)] +[assembly: ComVisible(false)] diff --git a/src/api/wix/WixToolset.Extensibility/BaseBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseBinderExtension.cs new file mode 100644 index 00000000..3869d1ed --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseBinderExtension.cs @@ -0,0 +1,47 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a resolver extension. + /// + public abstract class BaseBinderExtension : IBinderExtension + { + /// + /// Context for use by the extension. + /// + protected IBindContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// BackendHelper for use by the extension. + /// + protected IBackendHelper BackendHelper { get; private set; } + + /// + /// Called at the beginning of bind. + /// + public virtual void PreBind(IBindContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + + this.BackendHelper = context.ServiceProvider.GetService(); + } + + /// + /// Called at the end of bind. + /// + public virtual void PostBind(IBindResult result) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs new file mode 100644 index 00000000..da570af0 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseBurnBackendBinderExtension.cs @@ -0,0 +1,94 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Linq; + using WixToolset.Data; + using WixToolset.Data.Burn; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a Burn backend extension. + /// + public abstract class BaseBurnBackendBinderExtension : IBurnBackendBinderExtension + { + /// + /// Context for use by the extension. + /// + protected IBindContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Backend helper for use by the extension. + /// + protected IBurnBackendHelper BackendHelper { get; private set; } + + /// + /// Optional symbol definitions. + /// + protected virtual IReadOnlyCollection SymbolDefinitions => Array.Empty(); + + /// + /// See + /// + public virtual void PreBackendBind(IBindContext context) + { + this.Context = context; + this.Messaging = context.ServiceProvider.GetService(); + this.BackendHelper = context.ServiceProvider.GetService(); + } + + /// + /// See + /// + public virtual IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers) + { + return null; + } + + /// + /// See + /// + public virtual void SymbolsFinalized(IntermediateSection section) + { + } + + /// + /// See + /// + public virtual string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName) + { + return null; + } + + /// + /// See + /// + public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol) + { + if (this.SymbolDefinitions.Any(t => t == symbol.Definition) && + symbol.Definition.HasTag(BurnConstants.BootstrapperApplicationDataSymbolDefinitionTag)) + { + this.BackendHelper.AddBootstrapperApplicationData(symbol); + return true; + } + + return false; + } + + /// + /// See + /// + /// + public virtual void PostBackendBind(IBindResult result) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseCompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseCompilerExtension.cs new file mode 100644 index 00000000..3e185e14 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseCompilerExtension.cs @@ -0,0 +1,87 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a compiler extension. + /// + public abstract class BaseCompilerExtension : ICompilerExtension + { + /// + /// Context for use by the extension. + /// + protected ICompileContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// ParserHelper for use by the extension. + /// + protected IParseHelper ParseHelper { get; private set; } + + /// + /// Gets the schema namespace for this extension. + /// + /// Schema namespace supported by this extension. + public abstract XNamespace Namespace { get; } + + /// + /// Creates a component key path. + /// + protected IComponentKeyPath CreateComponentKeyPath() => this.Context.ServiceProvider.GetService(); + + /// + /// Called at the beginning of the compilation of a source file. + /// + public virtual void PreCompile(ICompileContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + + this.ParseHelper = context.ServiceProvider.GetService(); + } + + /// + /// See + /// + public virtual void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) + { + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); + } + + /// + /// See + /// + public virtual void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseHelper.UnexpectedElement(parentElement, element); + } + + /// + /// See + /// + public virtual IComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + this.ParseElement(intermediate, section, parentElement, element, context); + return null; + } + + /// + /// Called at the end of the compilation of a source file. + /// + public virtual void PostCompile(Intermediate intermediate) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs b/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs new file mode 100644 index 00000000..c716ac7e --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs @@ -0,0 +1,51 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for extensions to be able to parse the command-line. + /// + public abstract class BaseExtensionCommandLine : IExtensionCommandLine + { + /// + /// See + /// + public virtual IReadOnlyCollection CommandLineSwitches => Array.Empty(); + + /// + /// See + /// + public virtual void PostParse() + { + } + + /// + /// See + /// + public virtual void PreParse(ICommandLineContext context) + { + } + + /// + /// See + /// + public virtual bool TryParseArgument(ICommandLineParser parser, string argument) + { + return false; + } + + /// + /// See + /// + public virtual bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command) + { + command = null; + return false; + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs b/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs new file mode 100644 index 00000000..e4a10fd9 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseExtensionData.cs @@ -0,0 +1,34 @@ +// 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 +{ + using WixToolset.Data; + + /// + /// Base class for creating a resolver extension. + /// + public abstract class BaseExtensionData : IExtensionData + { + /// + /// See + /// + public virtual string DefaultCulture => null; + + /// + /// See + /// + public virtual Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return null; + } + + /// + /// See + /// + public virtual bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = null; + return false; + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseExtensionFactory.cs b/src/api/wix/WixToolset.Extensibility/BaseExtensionFactory.cs new file mode 100644 index 00000000..8b6dc566 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseExtensionFactory.cs @@ -0,0 +1,39 @@ +// 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 +{ + using System; + using System.Collections.Generic; + + /// + /// Base class for extension factories. + /// + /// Implementations may request an IWixToolsetCoreServiceProvider at instantiation by having a single parameter constructor for it. + /// + public abstract class BaseExtensionFactory : IExtensionFactory + { + /// + /// The extension types of the WiX extension. + /// + protected abstract IReadOnlyCollection ExtensionTypes { get; } + + /// + /// See + /// + public virtual bool TryCreateExtension(Type extensionType, out object extension) + { + extension = null; + + foreach (var type in this.ExtensionTypes) + { + if (extensionType.IsAssignableFrom(type)) + { + extension = Activator.CreateInstance(type); + break; + } + } + + return extension != null; + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseLayoutExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseLayoutExtension.cs new file mode 100644 index 00000000..21b932ff --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseLayoutExtension.cs @@ -0,0 +1,62 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a resolver extension. + /// + public abstract class BaseLayoutExtension : ILayoutExtension + { + /// + /// Context for use by the extension. + /// + protected ILayoutContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Called at the beginning of layout. + /// + public virtual void PreLayout(ILayoutContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + } + + /// + /// See + /// + /// + /// + /// + public virtual bool CopyFile(string source, string destination) + { + return false; + } + + /// + /// See + /// + /// + /// + /// + public virtual bool MoveFile(string source, string destination) + { + return false; + } + + /// + /// Called at the end of ayout. + /// + public virtual void PostLayout() + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseLibrarianExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseLibrarianExtension.cs new file mode 100644 index 00000000..cbc9e4ba --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseLibrarianExtension.cs @@ -0,0 +1,71 @@ +// 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 +{ + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a librarian extension. + /// + public abstract class BaseLibrarianExtension : ILibrarianExtension + { + /// + /// Context for use by the extension. + /// + protected ILibraryContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Called at the beginning of combining. + /// + /// Librarian context. + public virtual void PreCombine(ILibraryContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + } + + /// + /// Resolves a path to a file path on disk. + /// + /// Source line number for the path to resolve. + /// Symbol related to the path to resolve. + /// Path to resolve. + /// Optional resolved file result. + public virtual IResolveFileResult ResolveFile(SourceLineNumber sourceLineNumber, IntermediateSymbolDefinition symbolDefinition, string path) + { + return null; + } + + /// + /// Called at the end of combining. + /// + /// Combined library intermediate. + public virtual void PostCombine(Intermediate library) + { + } + + /// + /// Creates an IResolveFileResult. + /// + /// Optional resolved path to file. + /// Optional collection of paths checked for the file. + /// Resolved file result. + protected IResolveFileResult CreateResolveFileResult(string path = null, IReadOnlyCollection checkedPaths = null) + { + var result = this.Context.ServiceProvider.GetService(); + result.Path = path; + result.CheckedPaths = checkedPaths; + + return result; + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseLinkerExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseLinkerExtension.cs new file mode 100644 index 00000000..91aefc2f --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseLinkerExtension.cs @@ -0,0 +1,41 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a linker extension. + /// + public abstract class BaseLinkerExtension : ILinkerExtension + { + /// + /// Context for use by the extension. + /// + protected ILinkContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Called at the beginning of the linking. + /// + public virtual void PreLink(ILinkContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + } + + /// + /// Called at the end of the linking. + /// + public virtual void PostLink(Intermediate intermediate) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BasePreprocessorExtension.cs b/src/api/wix/WixToolset.Extensibility/BasePreprocessorExtension.cs new file mode 100644 index 00000000..b9a856ec --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BasePreprocessorExtension.cs @@ -0,0 +1,91 @@ +// 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 +{ + using System.Xml.Linq; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a preprocessor extension. + /// + public abstract class BasePreprocessorExtension : IPreprocessorExtension + { + /// + /// Context for use by the extension. + /// + protected IPreprocessContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// PreprocessHelper for use by the extension. + /// + protected IPreprocessHelper PreprocessHelper { get; private set; } + + /// + /// Gets or sets the variable prefixes for the extension. + /// + /// The variable prefixes for the extension. + public string[] Prefixes { get; protected set; } + + /// + /// Called at the beginning of the preprocessing of a source file. + /// + public virtual void PrePreprocess(IPreprocessContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + + this.PreprocessHelper = context.ServiceProvider.GetService(); + } + + /// + /// Gets the value of a variable whose prefix matches the extension. + /// + /// The prefix of the variable to be processed by the extension. + /// The name of the variable. + /// The value of the variable or null if the variable is undefined. + public virtual string GetVariableValue(string prefix, string name) + { + return null; + } + + /// + /// Evaluates a function defined in the extension. + /// + /// The prefix of the function to be processed by the extension. + /// The name of the function. + /// The list of arguments. + /// The value of the function or null if the function is not defined. + public virtual string EvaluateFunction(string prefix, string function, string[] args) + { + return null; + } + + /// + /// Processes a pragma defined in the extension. + /// + /// The prefix of the pragma to be processed by the extension. + /// The name of the pragma. + /// The pragma's arguments. + /// The parent node of the pragma. + /// false if the pragma is not defined. + /// Don't return false for any condition except for unrecognized pragmas. Throw errors that are fatal to the compile. use core.OnMessage for warnings and messages. + public virtual bool ProcessPragma(string prefix, string pragma, string args, XContainer parent) + { + return false; + } + + /// + /// Called at the end of the preprocessing of a source file. + /// + public virtual void PostPreprocess(IPreprocessResult result) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseResolverExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseResolverExtension.cs new file mode 100644 index 00000000..72dc5c41 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseResolverExtension.cs @@ -0,0 +1,59 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a resolver extension. + /// + public abstract class BaseResolverExtension : IResolverExtension + { + /// + /// Context for use by the extension. + /// + protected IResolveContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Creates a resolve file result. + /// + protected IResolveFileResult CreateResolveFileResult() => this.Context.ServiceProvider.GetService(); + + /// + /// Called at the beginning of the resolving variables and files. + /// + public virtual void PreResolve(IResolveContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + } + + /// + /// See + /// + /// + /// + /// + /// + /// + public virtual IResolveFileResult ResolveFile(string source, IntermediateSymbolDefinition symbolDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage) + { + return null; + } + + /// + /// Called at the end of resolve. + /// + public virtual void PostResolve(IResolveResult result) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerBackendBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..ffff186b --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,93 @@ +// 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 +{ + using System; + using System.Collections.Generic; + using System.Linq; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for creating a preprocessor extension. + /// + public abstract class BaseWindowsInstallerBackendBinderExtension : IWindowsInstallerBackendBinderExtension + { + /// + /// Context for use by the extension. + /// + protected IBindContext Context { get; private set; } + + /// + /// Messaging for use by the extension. + /// + protected IMessaging Messaging { get; private set; } + + /// + /// Backend helper for use by the extension. + /// + protected IWindowsInstallerBackendHelper BackendHelper { get; private set; } + + /// + /// Optional table definitions. + /// + public virtual IReadOnlyCollection TableDefinitions => Array.Empty(); + + /// + /// Creates a resolved cabinet result. + /// + protected IResolvedCabinet CreateResolvedCabinet() => this.Context.ServiceProvider.GetService(); + + /// + /// See + /// + public virtual void PreBackendBind(IBindContext context) + { + this.Context = context; + + this.Messaging = context.ServiceProvider.GetService(); + + this.BackendHelper = context.ServiceProvider.GetService(); + } + + /// + /// See + /// + public virtual void SymbolsFinalized(IntermediateSection section) + { + } + + /// + /// See + /// + public virtual IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable files) => null; + + /// + /// See + /// + public virtual string ResolveMedia(MediaSymbol mediaRow, string mediaLayoutDirectory, string layoutDirectory) => null; + + /// + /// See + /// + public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions) + { + if (this.TableDefinitions.Any(t => t.SymbolDefinition == symbol.Definition)) + { + return this.BackendHelper.TryAddSymbolToMatchingTableDefinitions(section, symbol, data, tableDefinitions); + } + + return false; + } + + /// + /// See + /// + public virtual void PostBackendBind(IBindResult result) + { + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/CompilerConstants.cs b/src/api/wix/WixToolset.Extensibility/CompilerConstants.cs new file mode 100644 index 00000000..73ff685c --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/CompilerConstants.cs @@ -0,0 +1,42 @@ +// 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 +{ + using System; + + /// + /// Constants used by compiler. + /// + public static class CompilerConstants + { + /// + /// + /// + public const int IntegerNotSet = int.MinValue; + + /// + /// + /// + public const int IllegalInteger = int.MinValue + 1; + + /// + /// + /// + public const long LongNotSet = long.MinValue; + + /// + /// + /// + public const long IllegalLong = long.MinValue + 1; + + /// + /// + /// + public const string IllegalGuid = "IllegalGuid"; + + /// + /// + /// + public static readonly Version IllegalVersion = new Version(Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/BindStage.cs b/src/api/wix/WixToolset.Extensibility/Data/BindStage.cs new file mode 100644 index 00000000..a690a896 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/BindStage.cs @@ -0,0 +1,25 @@ +// 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.Data +{ + /// + /// + /// + public enum BindStage + { + /// + /// Normal binding + /// + Normal, + + /// + /// Bind the file path of the target build file + /// + Target, + + /// + /// Bind the file path of the updated build file + /// + Updated, + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/BurnPlatforms.cs b/src/api/wix/WixToolset.Extensibility/Data/BurnPlatforms.cs new file mode 100644 index 00000000..ab4beb7d --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/BurnPlatforms.cs @@ -0,0 +1,25 @@ +// 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.Data +{ + using System; + + /// + /// Platforms that have been supported by Burn. + /// + [Flags] + public enum BurnPlatforms + { + /// Not specified. + None = 0, + + /// x86. + X86 = 0x1, + + /// x64. + X64 = 0x2, + + /// arm64. + ARM64 = 0x4, + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/CabinetBuildOption.cs b/src/api/wix/WixToolset.Extensibility/Data/CabinetBuildOption.cs new file mode 100644 index 00000000..f9938814 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/CabinetBuildOption.cs @@ -0,0 +1,25 @@ +// 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.Data +{ + /// + /// Options for building the cabinet. + /// + public enum CabinetBuildOption + { + /// + /// Build the cabinet and move it to the target location. + /// + BuildAndMove, + + /// + /// Build the cabinet and copy it to the target location. + /// + BuildAndCopy, + + /// + /// Just copy the cabinet to the target location. + /// + Copy + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/CustomActionPlatforms.cs b/src/api/wix/WixToolset.Extensibility/Data/CustomActionPlatforms.cs new file mode 100644 index 00000000..eea8a419 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/CustomActionPlatforms.cs @@ -0,0 +1,25 @@ +// 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.Data +{ + using System; + + /// + /// Platforms supported by custom actions. + /// + [Flags] + public enum CustomActionPlatforms + { + /// Not specified. + None = 0, + + /// x86. + X86 = 0x1, + + /// x64. + X64 = 0x2, + + /// arm64. + ARM64 = 0x4, + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs b/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs new file mode 100644 index 00000000..14b5dabb --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs @@ -0,0 +1,20 @@ +// 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.Data +{ + /// + /// A command line option. + /// + public struct ExtensionCommandLineSwitch + { + /// + /// + /// + public string Switch { get; set; } + + /// + /// + /// + public string Description { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs new file mode 100644 index 00000000..d0c65683 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IBindContext.cs @@ -0,0 +1,120 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using WixToolset.Data; + + /// + /// Bind context. + /// + public interface IBindContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Counnt of threads to use in cabbing. + /// + int CabbingThreadCount { get; set; } + + /// + /// Cabinet cache path. + /// + string CabCachePath { get; set; } + + /// + /// Default compression level. + /// + CompressionLevel? DefaultCompressionLevel { get; set; } + + /// + /// Delayed fields that need to be resolved again. + /// + IReadOnlyCollection DelayedFields { get; set; } + + /// + /// Embedded files to extract. + /// + IReadOnlyCollection ExpectedEmbeddedFiles { get; set; } + + /// + /// Binder extensions. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// File system extensions. + /// + IReadOnlyCollection FileSystemExtensions { get; set; } + + /// + /// Set of ICEs to execute. + /// + IReadOnlyCollection Ices { get; set; } + + /// + /// Intermedaite folder. + /// + string IntermediateFolder { get; set; } + + /// + /// Intermediate representation to bind. + /// + Intermediate IntermediateRepresentation { get; set; } + + /// + /// Output path to bind to. + /// + string OutputPath { get; set; } + + /// + /// Type of PDB to create. + /// + PdbType PdbType { get; set; } + + /// + /// Output path for PDB. + /// + string PdbPath { get; set; } + + /// + /// Codepage from resolve. + /// + int? ResolvedCodepage { get; set; } + + /// + /// Summary information codepage from resolve. + /// + int? ResolvedSummaryInformationCodepage { get; set; } + + /// + /// LCID from resolve. + /// + int? ResolvedLcid { get; set; } + + /// + /// Set of ICEs to skip. + /// + IReadOnlyCollection SuppressIces { get; set; } + + /// + /// Skip all ICEs. + /// + bool SuppressValidation { get; set; } + + /// + /// Skip creation of output. + /// + bool SuppressLayout { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IBindFileWithPath.cs b/src/api/wix/WixToolset.Extensibility/Data/IBindFileWithPath.cs new file mode 100644 index 00000000..69036113 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IBindFileWithPath.cs @@ -0,0 +1,12 @@ +// 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.Data +{ +#pragma warning disable 1591 // TODO: add documentation + public interface IBindFileWithPath + { + string Id { get; set; } + + string Path { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IBindPath.cs b/src/api/wix/WixToolset.Extensibility/Data/IBindPath.cs new file mode 100644 index 00000000..46895e89 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IBindPath.cs @@ -0,0 +1,25 @@ +// 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.Data +{ + /// + /// Interface for a bind path. + /// + public interface IBindPath + { + /// + /// Name of the bind path or String.Empty if the path is unnamed. + /// + string Name { get; set; } + + /// + /// Path for the bind path. + /// + string Path { get; set; } + + /// + /// Stage for the bind path. + /// + BindStage Stage { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IBindResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IBindResult.cs new file mode 100644 index 00000000..3738ef17 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IBindResult.cs @@ -0,0 +1,29 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using WixToolset.Data; + + /// + /// Result of bind operation. + /// + public interface IBindResult : IDisposable + { + /// + /// Collection of file transfers to complete. + /// + IReadOnlyCollection FileTransfers { get; set; } + + /// + /// Collection of files tracked during binding. + /// + IReadOnlyCollection TrackedFiles { get; set; } + + /// + /// Output of binding. + /// + WixOutput Wixout { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineArguments.cs b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineArguments.cs new file mode 100644 index 00000000..32ee4c09 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineArguments.cs @@ -0,0 +1,39 @@ +// 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.Data +{ + using WixToolset.Extensibility.Services; + + /// + /// Parsed command-line arguments. + /// + public interface ICommandLineArguments + { +#pragma warning disable 1591 // TODO: add documentation + string[] OriginalArguments { get; set; } + + string[] Arguments { get; set; } + + string[] Extensions { get; set; } + + string ErrorArgument { get; set; } + + /// + /// Populate this argument from a string. + /// + /// String to parse. + void Populate(string commandLine); + + /// + /// Populate this argument from array of strings. + /// + /// Array of strings. + void Populate(string[] args); + + /// + /// Parses this arguments after it is populated. + /// + /// Parser for this arguments. + ICommandLineParser Parse(); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs new file mode 100644 index 00000000..b03a18f4 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs @@ -0,0 +1,39 @@ +// 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.Data +{ + using System.Threading; + using System.Threading.Tasks; + using WixToolset.Extensibility.Services; + + /// + /// Custom command. + /// + public interface ICommandLineCommand + { + /// + /// Indicates the command-line should show the command-line logo. + /// + bool ShowLogo { get; } + + /// + /// Indicates the command-line parsing can stop. + /// + bool StopParsing { get; } + + /// + /// Executes the command. + /// + /// Cancellation token. + /// Exit code for the command. + Task ExecuteAsync(CancellationToken cancellationToken); + + /// + /// Allows the command to parse command-line arguments. + /// + /// Parser to help parse the argument and additional arguments. + /// Argument to parse. + /// True if the argument is recognized; otherwise false to allow another extension to process it. + bool TryParseArgument(ICommandLineParser parser, string argument); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineContext.cs new file mode 100644 index 00000000..d8c9469e --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineContext.cs @@ -0,0 +1,17 @@ +// 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.Data +{ + using System; + using WixToolset.Extensibility.Services; + +#pragma warning disable 1591 // TODO: add documentation + public interface ICommandLineContext + { + IServiceProvider ServiceProvider { get; } + + IExtensionManager ExtensionManager { get; set; } + + ICommandLineArguments Arguments { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs new file mode 100644 index 00000000..2ee8f2a1 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ICompileContext.cs @@ -0,0 +1,52 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using System.Xml.Linq; + using WixToolset.Data; + + /// + /// Context provided to the compiler. + /// + public interface ICompileContext + { + /// + /// Service provider made available to the compiler and its extensions. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Unique identifier for the compilation. + /// + string CompilationId { get; set; } + + /// + /// Set of extensions provided to the compiler. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Gets or sets the platform which the compiler will use when defaulting 64-bit attributes and elements. + /// + /// The platform which the compiler will use when defaulting 64-bit attributes and elements. + Platform Platform { get; set; } + + /// + /// Calculates whether the target platform for the compilation is 64-bit or not. + /// + bool IsCurrentPlatform64Bit { get; } + + /// + /// Source document being compiled. + /// + XDocument Source { get; set; } + + /// + /// Cancellation token to abort cancellation. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs b/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs new file mode 100644 index 00000000..2de9c028 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IComponentKeyPath.cs @@ -0,0 +1,14 @@ +// 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.Data +{ +#pragma warning disable 1591 // TODO: add documentation + public interface IComponentKeyPath + { + bool Explicit { get; set; } + + string Id { get; set; } + + PossibleKeyPathType Type { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs new file mode 100644 index 00000000..fe7d0465 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IDecompileContext.cs @@ -0,0 +1,59 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Extensibility.Services; + +#pragma warning disable 1591 // TODO: add documentation + public interface IDecompileContext + { + IServiceProvider ServiceProvider { get; } + + string DecompilePath { get; set; } + + OutputType DecompileType { get; set; } + + IReadOnlyCollection Extensions { get; set; } + + string ExtractFolder { get; set; } + + string CabinetExtractFolder { get; set; } + + /// + /// Optional gets or sets the base path for the File/@Source. + /// + /// Default value is "SourceDir" to enable use of BindPaths. + string BaseSourcePath { get; set; } + + string IntermediateFolder { get; set; } + + bool IsAdminImage { get; set; } + + string OutputPath { get; set; } + + /// + /// Gets or sets the option to suppress custom tables. + /// + bool SuppressCustomTables { get; set; } + + /// + /// Gets or sets the option to suppress dropping empty tables. + /// + bool SuppressDroppingEmptyTables { get; set; } + + bool SuppressExtractCabinets { get; set; } + + /// + /// Gets or sets the option to suppress decompiling UI-related tables. + /// + bool SuppressUI { get; set; } + + /// + /// Gets or sets whether the decompiler should use module logic on a product output. + /// + bool TreatProductAsModule { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs new file mode 100644 index 00000000..cffd0976 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IDecompileResult.cs @@ -0,0 +1,18 @@ +// 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.Data +{ + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface IDecompileResult + { + XDocument Document { get; set; } + + IReadOnlyCollection ExtractedFilePaths { get; set; } + + Platform? Platform { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IDelayedField.cs b/src/api/wix/WixToolset.Extensibility/Data/IDelayedField.cs new file mode 100644 index 00000000..59a578a6 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IDelayedField.cs @@ -0,0 +1,14 @@ +// 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.Data +{ + using WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface IDelayedField + { + IntermediateField Field { get; } + + IntermediateSymbol Symbol { get; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IExpectedExtractFile.cs b/src/api/wix/WixToolset.Extensibility/Data/IExpectedExtractFile.cs new file mode 100644 index 00000000..4bc8cd96 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IExpectedExtractFile.cs @@ -0,0 +1,16 @@ +// 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.Data +{ + using System; + +#pragma warning disable 1591 // TODO: add documentation + public interface IExpectedExtractFile + { + Uri Uri { get; set; } + + string EmbeddedFileId { get; set; } + + string OutputPath { get; set; } + } +} \ No newline at end of file diff --git a/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs b/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs new file mode 100644 index 00000000..fea00d4e --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IFileFacade.cs @@ -0,0 +1,126 @@ +// 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.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. + /// + 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. + /// + string ComponentRef { get; } + + /// + /// Indicates whether the file is compressed. + /// + bool Compressed { get; } + + /// + /// Disk Id for the file. + /// + int DiskId { get; set; } + + /// + /// Name of the file. + /// + string FileName { get; } + + /// + /// Size of the file. + /// + 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. + /// + Identifier Identifier { get; } + + /// + /// Helper accessor for the Id of the Identifier. + /// + string Id { get; } + + /// + /// Language of the file. + /// + string Language { get; set; } + + /// + /// Optional patch group for the file. + /// + int? PatchGroup { get; } + + /// + /// Sequence of the file. + /// + int Sequence { get; set; } + + /// + /// Source line number that define the file. + /// + SourceLineNumber SourceLineNumber { get; } + + /// + /// Source to the file. + /// + string SourcePath { get; } + + /// + /// Indicates whether the file is to be uncompressed. + /// + bool Uncompressed { get; } + + /// + /// Version of the file. + /// + string Version { get; set; } + + /// + /// Gets the underlying FileRow if one is present. + /// + /// FileRow if one is present, otherwise throws. + FileRow GetFileRow(); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IFileSystemContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IFileSystemContext.cs new file mode 100644 index 00000000..2e58059a --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IFileSystemContext.cs @@ -0,0 +1,24 @@ +// 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.Data +{ + using System; + using WixToolset.Data; + using WixToolset.Extensibility.Services; + +#pragma warning disable 1591 // TODO: add documentation + public interface IFileSystemContext + { + IServiceProvider ServiceProvider { get; } + + string CabCachePath { get; set; } + + string IntermediateFolder { get; set; } + + Intermediate IntermediateRepresentation { get; set; } + + string OutputPath { get; set; } + + string OutputPdbPath { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IFileTransfer.cs b/src/api/wix/WixToolset.Extensibility/Data/IFileTransfer.cs new file mode 100644 index 00000000..6f521536 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IFileTransfer.cs @@ -0,0 +1,27 @@ +// 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.Data +{ + using WixToolset.Data; + + /// + /// Structure used for all file transfer information. + /// + public interface IFileTransfer + { + /// Destination path for file. + string Destination { get; set; } + + /// Flag if file should be moved (optimal). + bool Move { get; set; } + + /// Set during layout of media when the file transfer when the source and target resolve to the same path. + bool Redundant { get; set; } + + /// Source path to file. + string Source { get; set; } + + /// Optional source line numbers where this file transfer orginated. + SourceLineNumber SourceLineNumbers { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IIncludedFile.cs b/src/api/wix/WixToolset.Extensibility/Data/IIncludedFile.cs new file mode 100644 index 00000000..e25c9f7e --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IIncludedFile.cs @@ -0,0 +1,24 @@ +// 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.Data +{ + using WixToolset.Data; + + /// + /// Interface for an included file. + /// + public interface IIncludedFile + { + /// + /// Gets the full path of the included file. + /// + /// The full path of the included file. + string Path { get; set; } + + /// + /// Gets the source line numbers. + /// + /// The source line numbers. + SourceLineNumber SourceLineNumbers { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IInscribeContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IInscribeContext.cs new file mode 100644 index 00000000..31c66aad --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IInscribeContext.cs @@ -0,0 +1,21 @@ +// 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.Data +{ + using System; + using WixToolset.Extensibility.Services; + +#pragma warning disable 1591 // TODO: add documentation + public interface IInscribeContext + { + IServiceProvider ServiceProvider { get; } + + string InputFilePath { get; set; } + + string IntermediateFolder { get; set; } + + string OutputFile { get; set; } + + string SignedEngineFile { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ILayoutContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ILayoutContext.cs new file mode 100644 index 00000000..b11b4d13 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ILayoutContext.cs @@ -0,0 +1,64 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + + /// + /// Context for laying out files. + /// + public interface ILayoutContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Extensions for use during layout. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Set of tracked of files created during processing to be cleaned up. + /// + IReadOnlyCollection TrackedFiles { get; set; } + + /// + /// Set of files to transfer. + /// + IReadOnlyCollection FileTransfers { get; set; } + + /// + /// File to capture list of content files. + /// + string ContentsFile { get; set; } + + /// + /// File to capture list of output files. + /// + string OutputsFile { get; set; } + + /// + /// Intermediate folder. + /// + string IntermediateFolder { get; set; } + + /// + /// List of built output files. + /// + string BuiltOutputsFile { get; set; } + + /// + /// Reset ACLs on file transfers. + /// + bool ResetAcls { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ILibraryContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ILibraryContext.cs new file mode 100644 index 00000000..208b6f73 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ILibraryContext.cs @@ -0,0 +1,55 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using WixToolset.Data; + + /// + /// Context provided during library creation operations. + /// + public interface ILibraryContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Indicates whether files should be bound into the library. + /// + bool BindFiles { get; set; } + + /// + /// Collection of bindpaths used to bind files. + /// + IReadOnlyCollection BindPaths { get; set; } + + /// + /// Collection of extensions used during creation of library. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Identifier of the library. + /// + string LibraryId { get; set; } + + /// + /// Collection of localization files to use in the library. + /// + IReadOnlyCollection Localizations { get; set; } + + /// + /// Collection of intermediates to include in the library. + /// + IReadOnlyCollection Intermediates { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ILinkContext.cs b/src/api/wix/WixToolset.Extensibility/Data/ILinkContext.cs new file mode 100644 index 00000000..d56866f7 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ILinkContext.cs @@ -0,0 +1,50 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using WixToolset.Data; + + /// + /// Context provided during linking. + /// + public interface ILinkContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Collection of extensions to use during linking. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Collection of extension data to use during linking. + /// + IReadOnlyCollection ExtensionData { get; set; } + + /// + /// Expected output type. + /// + OutputType ExpectedOutputType { get; set; } + + /// + /// Collection of intermediates to link. + /// + IReadOnlyCollection Intermediates { get; set; } + + /// + /// Symbol definition creator used to load extension data. + /// + ISymbolDefinitionCreator SymbolDefinitionCreator { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IPreprocessContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IPreprocessContext.cs new file mode 100644 index 00000000..69057c33 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IPreprocessContext.cs @@ -0,0 +1,56 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using WixToolset.Data; + + /// + /// Preprocessor context. + /// + public interface IPreprocessContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Collection of extensions to use during preprocessing. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Collection of search paths to find include files. + /// + IReadOnlyCollection IncludeSearchPaths { get; set; } + + /// + /// Gets the platform which the compiler will use when defaulting 64-bit attributes and elements. + /// + /// The platform which the compiler will use when defaulting 64-bit attributes and elements. + Platform Platform { get; set; } + + /// + /// Path to the source file being preprocessed. + /// + string SourcePath { get; set; } + + /// + /// Collection of name/value pairs used as preprocessor variables. + /// + IDictionary Variables { get; set; } + + /// + /// Current source line number of the preprocessor. + /// + SourceLineNumber CurrentSourceLineNumber { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IPreprocessResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IPreprocessResult.cs new file mode 100644 index 00000000..af224c1e --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IPreprocessResult.cs @@ -0,0 +1,23 @@ +// 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.Data +{ + using System.Collections.Generic; + using System.Xml.Linq; + + /// + /// Result of preprocessing. + /// + public interface IPreprocessResult + { + /// + /// Document result of preprocessor. + /// + XDocument Document { get; set; } + + /// + /// Collection of files included during preprocessing. + /// + IReadOnlyCollection IncludedFiles { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IResolveContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IResolveContext.cs new file mode 100644 index 00000000..63159ccb --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IResolveContext.cs @@ -0,0 +1,65 @@ +// 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.Data +{ + using System; + using System.Collections.Generic; + using System.Threading; + using WixToolset.Data; + + /// + /// Context for resolve. + /// + public interface IResolveContext + { + /// + /// Service provider. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Bind paths used during resolution. + /// + IReadOnlyCollection BindPaths { get; set; } + + /// + /// Resolve extensions. + /// + IReadOnlyCollection Extensions { get; set; } + + /// + /// Extension data. + /// + IReadOnlyCollection ExtensionData { get; set; } + + /// + /// List of cultures to filter the localizations. + /// + IReadOnlyCollection FilterCultures { get; set; } + + /// + /// Intermediate folder. + /// + string IntermediateFolder { get; set; } + + /// + /// Intermediate to resolve. + /// + Intermediate IntermediateRepresentation { get; set; } + + /// + /// Localizations used to resolve. + /// + IReadOnlyCollection Localizations { get; set; } + + /// + /// Indicates whether to allow localization and bind variables to remain unresolved. + /// + bool AllowUnresolvedVariables { get; set; } + + /// + /// Cancellation token. + /// + CancellationToken CancellationToken { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IResolveFileResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IResolveFileResult.cs new file mode 100644 index 00000000..2f0df96c --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IResolveFileResult.cs @@ -0,0 +1,22 @@ +// 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.Data +{ + using System.Collections.Generic; + + /// + /// Result of resolving a file. + /// + public interface IResolveFileResult + { + /// + /// Collection of paths checked to find file. + /// + IReadOnlyCollection CheckedPaths { get; set; } + + /// + /// Path to found file, if found. + /// + string Path { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IResolveResult.cs b/src/api/wix/WixToolset.Extensibility/Data/IResolveResult.cs new file mode 100644 index 00000000..0c5e0ccf --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IResolveResult.cs @@ -0,0 +1,43 @@ +// 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.Data +{ + using System.Collections.Generic; + using WixToolset.Data; + + /// + /// Result of resolving localization and bind variables. + /// + public interface IResolveResult + { + /// + /// Resolved codepage, if provided. + /// + int? Codepage { get; set; } + + /// + /// Resolved summary information codepage, if provided. + /// + int? SummaryInformationCodepage { get; set; } + + /// + /// Resolved package language, if provided. + /// + int? PackageLcid { get; set; } + + /// + /// Fields still requiring resolution. + /// + IReadOnlyCollection DelayedFields { get; set; } + + /// + /// Files to extract from embedded .wixlibs. + /// + IReadOnlyCollection ExpectedEmbeddedFiles { get; set; } + + /// + /// Resolved intermediate. + /// + Intermediate IntermediateRepresentation { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IResolvedCabinet.cs b/src/api/wix/WixToolset.Extensibility/Data/IResolvedCabinet.cs new file mode 100644 index 00000000..0c07d387 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IResolvedCabinet.cs @@ -0,0 +1,12 @@ +// 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.Data +{ +#pragma warning disable 1591 // TODO: add documentation + public interface IResolvedCabinet + { + CabinetBuildOption BuildOption { get; set; } + + string Path { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IResolvedDirectory.cs b/src/api/wix/WixToolset.Extensibility/Data/IResolvedDirectory.cs new file mode 100644 index 00000000..59de6e78 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IResolvedDirectory.cs @@ -0,0 +1,19 @@ +// 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.Data +{ + /// + /// Used for resolved directory information. + /// + public interface IResolvedDirectory + { + /// The directory parent. + string DirectoryParent { get; set; } + + /// The name of this directory. + string Name { get; set; } + + /// The path of this directory. + string Path { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ITrackedFile.cs b/src/api/wix/WixToolset.Extensibility/Data/ITrackedFile.cs new file mode 100644 index 00000000..df36bd2b --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/ITrackedFile.cs @@ -0,0 +1,32 @@ +// 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.Data +{ + using WixToolset.Data; + + /// + /// Interface used to track all files processed. + /// + public interface ITrackedFile + { + /// + /// Indicates whether the tracked file should be cleaned by the project. + /// + bool Clean { get; set; } + + /// + /// Path to tracked file. + /// + string Path { get; set; } + + /// + /// Optional source line numbers where the tracked file was created. + /// + SourceLineNumber SourceLineNumbers { get; set; } + + /// + /// Type of tracked file. + /// + TrackedFileType Type { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs b/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs new file mode 100644 index 00000000..6427422f --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/IUnbindContext.cs @@ -0,0 +1,24 @@ +// 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.Data +{ + using System; + +#pragma warning disable 1591 // TODO: add documentation + public interface IUnbindContext + { + IServiceProvider ServiceProvider { get; } + + string ExportBasePath { get; set; } + + string InputFilePath { get; set; } + + string IntermediateFolder { get; set; } + + bool IsAdminImage { get; set; } + + bool SuppressDemodularization { get; set; } + + bool SuppressExtractCabinets { get; set; } + } +} \ No newline at end of file diff --git a/src/api/wix/WixToolset.Extensibility/Data/PossibleKeyPathType.cs b/src/api/wix/WixToolset.Extensibility/Data/PossibleKeyPathType.cs new file mode 100644 index 00000000..08e927e4 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/PossibleKeyPathType.cs @@ -0,0 +1,40 @@ +// 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.Data +{ + /// + /// Key path types. + /// + public enum PossibleKeyPathType + { + /// + /// Not a key path. + /// + None, + + /// + /// File resource as a key path. + /// + File, + + /// + /// Folder as a key path. + /// + Directory, + + /// + /// ODBC data source as a key path. + /// + OdbcDataSource, + + /// + /// A simple registry key acting as a key path. + /// + Registry, + + /// + /// A registry key that contains a formatted property acting as a key path. + /// + RegistryFormatted + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/TrackedFileType.cs b/src/api/wix/WixToolset.Extensibility/Data/TrackedFileType.cs new file mode 100644 index 00000000..e7f53842 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/TrackedFileType.cs @@ -0,0 +1,33 @@ +// 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.Data +{ + /// + /// Tracked file types. + /// + public enum TrackedFileType + { + /// + /// File tracked as input (like content included in an .msi). + /// + Input, + + /// + /// Temporary file (like an .idt or any other temporary file). + /// These are to be deleted before the build completes. + /// + Temporary, + + /// + /// Intermediate file (like a .cab in the cabcache). + /// These are left for subsequent builds. + /// + Intermediate, + + /// + /// Final output (like a .msi, .cab or .wixpdb). + /// These are the whole point of the build process. + /// + Final, + } +} diff --git a/src/api/wix/WixToolset.Extensibility/DecompilerConstants.cs b/src/api/wix/WixToolset.Extensibility/DecompilerConstants.cs new file mode 100644 index 00000000..22e8530d --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/DecompilerConstants.cs @@ -0,0 +1,20 @@ +// 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 +{ + /// + /// Constants used by decompiler. + /// + public static class DecompilerConstants + { + /// + /// + /// + public const char PrimaryKeyDelimiter = '/'; + + /// + /// + /// + public const string PrimaryKeyDelimiterString = "/"; + } +} diff --git a/src/api/wix/WixToolset.Extensibility/DecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/DecompilerExtension.cs new file mode 100644 index 00000000..b492cf3a --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/DecompilerExtension.cs @@ -0,0 +1,61 @@ +// 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 +{ + using WixToolset.Data; + +#if BRING_BACK_LATER + /// + /// Base class for creating a decompiler extension. + /// + public abstract class DecompilerExtension : IDecompilerExtension + { + /// + /// Gets or sets the decompiler core for the extension. + /// + /// The decompiler core for the extension. + public IDecompilerCore Core { get; set; } + + /// + /// Gets the table definitions this extension decompiles. + /// + /// Table definitions this extension decompiles. + public virtual TableDefinitionCollection TableDefinitions { get; protected set; } + + /// + /// Gets the library that this decompiler wants removed from the decomipiled output. + /// + /// The table definitions to use while loading the library. + /// The library for this extension or null if there is no library to be removed. + public virtual Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return null; + } + + /// + /// Called at the beginning of the decompilation of a database. + /// + /// The collection of all tables. + public virtual void Initialize(TableIndexedCollection tables) + { + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public virtual void DecompileTable(Table table) + { + this.Core.UnexpectedTable(table); + } + + /// + /// Finalize decompilation. + /// + /// The collection of all tables. + public virtual void Finish(TableIndexedCollection tables) + { + } + } +#endif +} diff --git a/src/api/wix/WixToolset.Extensibility/ExtensionHelper.cs b/src/api/wix/WixToolset.Extensibility/ExtensionHelper.cs new file mode 100644 index 00000000..6b938a65 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/ExtensionHelper.cs @@ -0,0 +1,55 @@ +// 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 +{ + using System; + using System.Collections.Specialized; + using System.IO; + using System.Reflection; + using System.Xml; + using WixToolset.Data; + using WixToolset.Extensibility; + +#if BRING_BACK_LATER + /// + /// The main class for a WiX extension. + /// + public static class ExtensionHelper + { + /// + /// Help for loading a library from an embedded resource. + /// + /// The assembly containing the embedded resource. + /// The name of the embedded resource being requested. + /// The table definitions to use while loading the library. + /// The loaded library. + public static Library LoadLibraryHelper(Assembly assembly, string resourceName, TableDefinitionCollection tableDefinitions) + { + using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) + { + UriBuilder uriBuilder = new UriBuilder(); + uriBuilder.Scheme = "embeddedresource"; + uriBuilder.Path = assembly.Location; + uriBuilder.Fragment = resourceName; + + return Library.Load(resourceStream, uriBuilder.Uri, tableDefinitions, false); + } + } + + /// + /// Helper for loading table definitions from an embedded resource. + /// + /// The assembly containing the embedded resource. + /// The name of the embedded resource being requested. + /// The loaded table definitions. + public static TableDefinitionCollection LoadTableDefinitionHelper(Assembly assembly, string resourceName) + { + using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName)) + using (XmlReader reader = XmlReader.Create(resourceStream)) + { + return TableDefinitionCollection.Load(reader); + } + } + } +#endif +} diff --git a/src/api/wix/WixToolset.Extensibility/IBackend.cs b/src/api/wix/WixToolset.Extensibility/IBackend.cs new file mode 100644 index 00000000..9579c3ca --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IBackend.cs @@ -0,0 +1,19 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface IBackend + { + IBindResult Bind(IBindContext context); + + IDecompileResult Decompile(IDecompileContext context); + + Intermediate Unbind(IUnbindContext context); + + bool Inscribe(IInscribeContext context); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs new file mode 100644 index 00000000..99a6704f --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IBackendFactory.cs @@ -0,0 +1,10 @@ +// 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 +{ +#pragma warning disable 1591 // TODO: add documentation + public interface IBackendFactory + { + bool TryCreateBackend(string outputType, string outputPath, out IBackend backend); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IBinderExtension.cs new file mode 100644 index 00000000..dba09845 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IBinderExtension.cs @@ -0,0 +1,22 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + + /// + /// Interface all binder extensions implement. + /// + public interface IBinderExtension + { + /// + /// Called before binding occurs. + /// + void PreBind(IBindContext context); + + /// + /// Called after all binding occurs. + /// + void PostBind(IBindResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IBurnBackendBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IBurnBackendBinderExtension.cs new file mode 100644 index 00000000..1dd4d9b1 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IBurnBackendBinderExtension.cs @@ -0,0 +1,64 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + /// + /// Interface all Burn backend extensions implement. + /// + public interface IBurnBackendBinderExtension + { + /// + /// Called before binding occurs. + /// + void PreBackendBind(IBindContext context); + + /// + /// Called to find a file related to another source in the authoring. For example, most often used + /// to find cabinets and uncompressed files for an MSI package. + /// + /// Path to the source package. + /// Expected path to the related file. + /// Type of related file, such as "File" or "Cabinet" + /// Source line number of source package. + /// IResolveFileResult if the related file was found, or null for default handling. + IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers); + + /// + /// Called right before the output is bound into its final format. + /// + /// The finalized intermediate section. + void SymbolsFinalized(IntermediateSection section); + + /// + /// Called to customize the DownloadUrl provided in source cde. + /// + /// The value from the source code. May not actually be a URL. + /// The default URL if the extension does not return a value. + /// Identifier of the package. + /// Identifier of the payload. + /// Filename of the payload. + /// Url to override, or null to use default value. + string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName); + + /// + /// Called for each extension symbol that hasn't been handled yet. + /// Use IBurnBackendHelper to add data. + /// + /// The linked section. + /// The current symbol. + /// + /// True if the extension handled the symbol, false otherwise. + /// The Burn backend will warn on all unhandled symbols. + /// + bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol); + + /// + /// Called after output is bound into its final format. + /// + /// + void PostBackendBind(IBindResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/ICompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/ICompilerExtension.cs new file mode 100644 index 00000000..55ef683a --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/ICompilerExtension.cs @@ -0,0 +1,61 @@ +// 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 +{ + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + /// + /// Interface all compiler extensions implement. + /// + public interface ICompilerExtension + { + /// + /// Gets the schema namespace for this extension. + /// + /// Schema namespace supported by this extension. + XNamespace Namespace { get; } + + /// + /// Called at the beginning of the compilation of a source file. + /// + void PreCompile(ICompileContext context); + + /// + /// Processes an attribute for the Compiler. + /// + /// Parent intermediate. + /// Parent section. + /// Parent element of attribute. + /// Attribute to process. + /// Extra information about the context in which this element is being parsed. + void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context); + + /// + /// Processes an element for the Compiler. + /// + /// Parent intermediate. + /// Parent section. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); + + /// + /// Processes an element for the Compiler, with the ability to supply a component keypath. + /// + /// Parent intermediate. + /// Parent section. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + IComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); + + /// + /// Called at the end of the compilation of a source file. + /// + void PostCompile(Intermediate intermediate); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs new file mode 100644 index 00000000..24ef3bff --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IDecompilerExtension.cs @@ -0,0 +1,22 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + + /// + /// Base class for creating a decompiler extension. + /// + public interface IDecompilerExtension + { + /// + /// Called before decompiling occurs. + /// + void PreDecompile(IDecompileContext context); + + /// + /// Called after all decompiling occurs. + /// + void PostDecompile(IDecompileResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs b/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs new file mode 100644 index 00000000..f7b19955 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs @@ -0,0 +1,48 @@ +// 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 +{ + using System.Collections.Generic; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Interface extensions implement to be able to parse the command-line. + /// + public interface IExtensionCommandLine + { + /// + /// Gets the supported command line types for this extension. + /// + /// The supported command line types for this extension. + IReadOnlyCollection CommandLineSwitches { get; } + + /// + /// Called before the command-line is parsed. + /// + /// Information about the command-line to be parsed. + void PreParse(ICommandLineContext context); + + /// + /// Gives the extension an opportunity pass a command-line argument for another command. + /// + /// Parser to help parse the argument and additional arguments. + /// Argument to parse. + /// True if the argument is recognized; otherwise false to allow another extension to process it. + bool TryParseArgument(ICommandLineParser parser, string argument); + + /// + /// Gives the extension an opportunity to provide a command. + /// + /// Parser to help parse the argument and additional arguments. + /// Argument to parse. + /// + /// True if the argument is recognized as a command; otherwise false to allow another extension to process it. + bool TryParseCommand(ICommandLineParser parser, string argument, out ICommandLineCommand command); + + /// + /// Called after the command-line is parsed. + /// + void PostParse(); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IExtensionData.cs b/src/api/wix/WixToolset.Extensibility/IExtensionData.cs new file mode 100644 index 00000000..823e2beb --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IExtensionData.cs @@ -0,0 +1,33 @@ +// 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 +{ + using WixToolset.Data; + + /// + /// Interface extensions implement to provide data. + /// + public interface IExtensionData + { + /// + /// Gets the optional default culture. + /// + /// The optional default culture. + string DefaultCulture { get; } + + /// + /// + /// + /// + /// + /// True + bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition); + + /// + /// Gets the library associated with this extension. + /// + /// The symbol definitions to use while loading the library. + /// The library for this extension or null if there is no library. + Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IExtensionFactory.cs b/src/api/wix/WixToolset.Extensibility/IExtensionFactory.cs new file mode 100644 index 00000000..f86fdde0 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IExtensionFactory.cs @@ -0,0 +1,20 @@ +// 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 +{ + using System; + + /// + /// Implementations may request an IWixToolsetCoreServiceProvider at instantiation by having a single parameter constructor for it. + /// + public interface IExtensionFactory + { + /// + /// Request to create an extension of the specified type. + /// + /// Extension type to create. + /// Extension created. + /// True if extension was created; otherwise false. + bool TryCreateExtension(Type extensionType, out object extension); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IFileSystemExtension.cs b/src/api/wix/WixToolset.Extensibility/IFileSystemExtension.cs new file mode 100644 index 00000000..9807e8b9 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IFileSystemExtension.cs @@ -0,0 +1,17 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + + /// + /// Interface all file system extensions implement. + /// + public interface IFileSystemExtension + { +#pragma warning disable 1591 // TODO: add documentation + void Initialize(IFileSystemContext context); + + bool? CompareFiles(string targetFile, string updatedFile); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IInspectorCore.cs b/src/api/wix/WixToolset.Extensibility/IInspectorCore.cs new file mode 100644 index 00000000..9420ea05 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IInspectorCore.cs @@ -0,0 +1,15 @@ +// 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 +{ + /// + /// Core facilities for inspector extensions. + /// + public interface IInspectorCore + { + /// + /// Gets whether an error occured. + /// + bool EncounteredError { get; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IInspectorExtension.cs b/src/api/wix/WixToolset.Extensibility/IInspectorExtension.cs new file mode 100644 index 00000000..7c488a89 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IInspectorExtension.cs @@ -0,0 +1,60 @@ +// 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 +{ + using System; + using System.IO; + using WixToolset.Data; + + /// + /// Interface for inspector extensions. + /// + /// + /// The inspector methods are stateless, but extensions are loaded once. If you want to maintain state, you should check + /// if your data is loaded for each method and, if not, load it. + /// + public interface IInspectorExtension + { + /// + /// Gets or sets the for inspector extensions to use. + /// + IInspectorCore Core { get; set; } + + /// + /// Inspect the source before preprocessing. + /// + /// The source to preprocess. + void InspectSource(Stream source); + + /// + /// Inspect the compiled output. + /// + /// The compiled output. + void InspectIntermediate(Intermediate intermediate); + +#if REWRITE + /// + /// Inspect the output. + /// + /// The output. May be called after linking or binding. + /// + /// To inspect a patch's filtered transforms, enumerate . + /// Transforms where the begins with "#" are + /// called patch transforms and instruct Windows Installer how to apply the + /// authored transforms - those that do not begin with "#". The authored + /// transforms are the primary transforms you'll typically want to inspect + /// and contain your changes to target products. + /// +#endif + /// + void InspectOutput(Intermediate output); + + /// + /// Inspect the final output after binding. + /// + /// The file path to the final bound output. + /// The that contains source line numbers + /// for the database and all rows. + void InspectDatabase(string filePath, Intermediate pdb); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/ILayoutExtension.cs b/src/api/wix/WixToolset.Extensibility/ILayoutExtension.cs new file mode 100644 index 00000000..ecd7d8f1 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/ILayoutExtension.cs @@ -0,0 +1,28 @@ +// 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 +{ + using WixToolset.Extensibility.Data; + + /// + /// Interface all layout extensions implement. + /// + public interface ILayoutExtension + { + /// + /// Called before layout occurs. + /// + void PreLayout(ILayoutContext context); + +#pragma warning disable 1591 // TODO: add documentation + bool CopyFile(string source, string destination); + + bool MoveFile(string source, string destination); +#pragma warning restore 1591 + + /// + /// Called after all layout occurs. + /// + void PostLayout(); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/ILibrarianExtension.cs b/src/api/wix/WixToolset.Extensibility/ILibrarianExtension.cs new file mode 100644 index 00000000..d9b04cd2 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/ILibrarianExtension.cs @@ -0,0 +1,17 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface ILibrarianExtension + { + void PreCombine(ILibraryContext context); + + IResolveFileResult ResolveFile(SourceLineNumber sourceLineNumber, IntermediateSymbolDefinition symbolDefinition, string path); + + void PostCombine(Intermediate library); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/ILinkerExtension.cs b/src/api/wix/WixToolset.Extensibility/ILinkerExtension.cs new file mode 100644 index 00000000..febca1df --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/ILinkerExtension.cs @@ -0,0 +1,23 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + /// + /// Interface all binder extensions implement. + /// + public interface ILinkerExtension + { + /// + /// Called before linking occurs. + /// + void PreLink(ILinkContext context); + + /// + /// Called after all linking occurs. + /// + void PostLink(Intermediate intermediate); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IMessageListener.cs b/src/api/wix/WixToolset.Extensibility/IMessageListener.cs new file mode 100644 index 00000000..a04e9c98 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IMessageListener.cs @@ -0,0 +1,34 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Services; + + /// + /// Message listener. + /// + public interface IMessageListener + { + /// + /// Calculate a new level for a message. + /// + /// Messaging object. + /// Message to evaluate. + /// Current message level. + /// + MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel); + + /// + /// Writes a message. + /// + /// Message to write. + void Write(Message message); + + /// + /// Writes a string message. + /// + /// String message to write. + void Write(string message); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IPreprocessorExtension.cs b/src/api/wix/WixToolset.Extensibility/IPreprocessorExtension.cs new file mode 100644 index 00000000..919ff1ae --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IPreprocessorExtension.cs @@ -0,0 +1,57 @@ +// 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 +{ + using System.Xml.Linq; + using WixToolset.Extensibility.Data; + + /// + /// Interface for extending the WiX toolset preprocessor. + /// + public interface IPreprocessorExtension + { + /// + /// Gets the variable prefixes for the extension. + /// + /// The variable prefixes for the extension. + string[] Prefixes { get; } + + /// + /// Called at the beginning of the preprocessing of a source file. + /// + void PrePreprocess(IPreprocessContext context); + + /// + /// Gets the value of a variable whose prefix matches the extension. + /// + /// The prefix of the variable to be processed by the extension. + /// The name of the variable. + /// The value of the variable or null if the variable is undefined. + string GetVariableValue(string prefix, string name); + + /// + /// Evaluates a function defined in the extension. + /// + /// The prefix of the function to be processed by the extension. + /// The name of the function. + /// The list of arguments. + /// The value of the function or null if the function is not defined. + string EvaluateFunction(string prefix, string function, string[] args); + + /// + /// Processes a pragma defined in the extension. + /// + /// The prefix of the pragma to be processed by the extension. + /// The name of the pragma. + /// The pragma's arguments. + /// The parent node of the pragma. + /// false if the pragma is not defined. + /// Don't return false for any condition except for unrecognized pragmas. Use Core.OnMessage for errors, warnings and messages. + bool ProcessPragma(string prefix, string pragma, string args, XContainer parent); + + /// + /// Called at the end of the preprocessing of a source file. + /// + void PostPreprocess(IPreprocessResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IResolverExtension.cs b/src/api/wix/WixToolset.Extensibility/IResolverExtension.cs new file mode 100644 index 00000000..f77581a0 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IResolverExtension.cs @@ -0,0 +1,28 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Extensibility.Data; + + /// + /// Interface all resolver extensions implement. + /// + public interface IResolverExtension + { + /// + /// Called before resolving occurs. + /// + void PreResolve(IResolveContext context); + + /// + /// Called to attempt to resolve source to a file. + /// + IResolveFileResult ResolveFile(string source, IntermediateSymbolDefinition symbolDefinition, SourceLineNumber sourceLineNumbers, BindStage bindStage); + + /// + /// Called after all resolving occurs. + /// + void PostResolve(IResolveResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs new file mode 100644 index 00000000..0e9a2504 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IUnbinderExtension.cs @@ -0,0 +1,18 @@ +// 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 +{ + using System; + using WixToolset.Data; + + /// + /// Base class for creating an unbinder extension. + /// + public interface IUnbinderExtension + { + /// + /// Called during the generation of sectionIds for an admin image. + /// + void GenerateSectionIds(Intermediate output); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendBinderExtension.cs b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..067745c2 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,65 @@ +// 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 +{ + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Data; + + /// + /// Interface all binder extensions implement. + /// + public interface IWindowsInstallerBackendBinderExtension + { + /// + /// Table definitions provided by the extension. + /// + IReadOnlyCollection TableDefinitions { get; } + + /// + /// Called before binding occurs. + /// + void PreBackendBind(IBindContext context); + + /// + /// Extension can process the intermediate before the Windows Installer data is created. + /// + /// The finalized intermediate section. + void SymbolsFinalized(IntermediateSection section); + + /// + /// Finds an existing cabinet that contains the provided files. + /// + /// Path to the cabinet. + /// Files contained in the cabinet. + /// Resolved cabinet options or null if the cabinet could not be found. + IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable files); + + /// + /// Override layout location for a media. + /// + /// Media symbol. + /// Default media specific layout directory. + /// Default overall layout directory. + /// Layout location or null to use the default processing. + string ResolveMedia(MediaSymbol mediaSymbol, string mediaLayoutDirectory, string layoutDirectory); + + /// + /// Called for each extension symbol that hasn't been handled yet. + /// + /// The linked section. + /// The current symbol. + /// Windows Installer data + /// Collection of table definitions available for the output. + /// True if the symbol was handled, or false if not. + bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions); + + /// + /// Called after all output changes occur and right before the output is bound into its final format. + /// + /// Bind result to process. + void PostBackendBind(IBindResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs new file mode 100644 index 00000000..a56b63c3 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/IWindowsInstallerBackendDecompilerExtension.cs @@ -0,0 +1,26 @@ +// 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 +{ + using WixToolset.Data; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Data; + + /// + /// Interface all binder extensions implement. + /// + public interface IWindowsInstallerBackendDecompilerExtension + { + /// + /// Called before decompiling occurs. + /// + void PreBackendDecompile(IDecompileContext context); + + // TODO: Redesign this interface to be useful. + + /// + /// Called after all output changes occur and right before the output is bound into its final format. + /// + void PostBackendDecompile(IDecompileResult result); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/InspectorExtension.cs b/src/api/wix/WixToolset.Extensibility/InspectorExtension.cs new file mode 100644 index 00000000..49c3f9de --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/InspectorExtension.cs @@ -0,0 +1,63 @@ +// 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 +{ + using System; + using System.IO; + using WixToolset.Data; + +#if BRING_THIS_BACK + /// + /// Opitonal base class for inspector extensions. + /// + public class InspectorExtension : IInspectorExtension + { + /// + /// Gets the for inspector extensions to use. + /// + public IInspectorCore Core { get; set; } + + /// + /// Inspect the source before preprocessing. + /// + /// The source to preprocess. + public virtual void InspectSource(Stream source) + { + } + + /// + /// Inspect the compiled output. + /// + /// The compiled output. + public virtual void InspectIntermediate(Intermediate intermediate) + { + } + + /// + /// Inspect the output. + /// + /// The output. May be called after linking or binding. + /// + /// To inspect a patch's filtered transforms, enumerate . + /// Transforms where the begins with "#" are + /// called patch transforms and instruct Windows Installer how to apply the + /// authored transforms - those that do not begin with "#". The authored + /// transforms are the primary transforms you'll typically want to inspect + /// and contain your changes to target products. + /// + public virtual void InspectOutput(Output output) + { + } + + /// + /// Inspect the final output after binding. + /// + /// The file path to the final bound output. + /// The that contains source line numbers + /// for the database and all rows. + public virtual void InspectDatabase(string filePath, Pdb pdb) + { + } + } +#endif +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs new file mode 100644 index 00000000..5c4d9a68 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IBackendHelper.cs @@ -0,0 +1,183 @@ +// 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; + using System.Collections.Generic; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller.Rows; + using WixToolset.Extensibility.Data; + + /// + /// Interface provided to help backend extensions. + /// + public interface IBackendHelper + { + /// + /// 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 file transfer and marks it redundant if the source and destination are identical. + /// + /// Source for the file transfer. + /// Destination for the file transfer. + /// Indicates whether to move or copy the source file. + /// Optional source line numbers that requested the file transfer. + IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null); + + /// + /// Creates a MSI compatible GUID. + /// + /// Creates an uppercase GUID with braces. + string CreateGuid(); + + /// + /// Creates a version 3 name-based UUID. + /// + /// The namespace UUID. + /// The value. + /// The generated GUID for the given namespace and value. + string CreateGuid(Guid namespaceGuid, string value); + + /// + /// Creates a resolved directory. + /// + /// Directory parent identifier. + /// Name of directory. + /// Resolved directory. + IResolvedDirectory CreateResolvedDirectory(string directoryParent, string name); + + /// + /// Extracts embedded files. + /// + /// Embedded files to extract. + /// ITrackedFile for each embedded file extracted. + IReadOnlyList ExtractEmbeddedFiles(IEnumerable embeddedFiles); + + /// + /// Generate an identifier by hashing data from the row. + /// + /// Three letter or less prefix for generated row identifier. + /// Information to hash. + /// The generated identifier. + string GenerateIdentifier(string prefix, params string[] args); + + /// + /// Validates path is relative and canonicalizes it. + /// For example, "a\..\c\.\d.exe" => "c\d.exe". + /// + /// + /// + /// + /// + /// The original value if not relative, otherwise the canonicalized relative path. + string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath); + + /// + /// Gets a valid code page from the given web name or integer value. + /// + /// A code page web name or integer value as a string. + /// Whether to allow -1 which does not change the database code pages. This may be the case with wxl files. + /// Whether to allow Unicode (UCS) or UTF code pages. + /// Source line information for the current authoring. + /// A valid code page number. + /// The value is an integer less than 0 or greater than 65535. + /// is null. + /// The value doesn't not represent a valid code page name or integer value. + /// The code page is invalid for summary information. + int GetValidCodePage(string value, bool allowNoChange = false, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null); + + /// + /// Get a source/target and short/long file name from an MSI Filename column. + /// + /// The Filename value. + /// true to get a source name; false to get a target name + /// true to get a long name; false to get a short name + /// The name. + string GetMsiFileName(string value, bool source, bool longName); + + /// + /// Verifies if an identifier is a valid binder variable name. + /// + /// Binder variable name to verify. + /// True if the identifier is a valid binder variable name. + bool IsValidBinderVariable(string variable); + + /// + /// Verifies the given string is a valid 4-part version module or bundle version. + /// + /// The version to verify. + /// True if version is a valid module or bundle version. + bool IsValidFourPartVersion(string version); + + /// + /// Determines if value is a valid identifier. + /// + /// Identifier to validate. + /// True if valid identifier, otherwise false. + bool IsValidIdentifier(string id); + + /// + /// Verifies the given string is a valid long filename. + /// + /// The filename to verify. + /// Allow wildcards in the filename. + /// Allow long file name to be a relative path. + /// True if filename is a valid long filename. + bool IsValidLongFilename(string filename, bool allowWildcards, bool allowRelative); + + /// + /// Verifies the given string is a valid short filename. + /// + /// The filename to verify. + /// Allow wildcards in the filename. + /// True if filename is a valid short filename. + bool IsValidShortFilename(string filename, bool allowWildcards); + + /// + /// Resolve delayed fields. + /// + /// The fields which had resolution delayed. + /// The cached variable values used when resolving delayed fields. + void ResolveDelayedFields(IEnumerable delayedFields, Dictionary variableCache); + + /// + /// Get the source/target and short/long file names from an MSI Filename column. + /// + /// The Filename value. + /// An array of strings of length 4. The contents are: short target, long target, short source, and long source. + /// + /// If any particular file name part is not parsed, its set to null in the appropriate location of the returned array of strings. + /// Thus the returned array will always be of length 4. + /// + string[] SplitMsiFileName(string value); + + /// + /// Creates a tracked file. + /// + /// Destination path for the build output. + /// Type of tracked file to create. + /// Optional source line numbers that requested the tracked file. + ITrackedFile TrackFile(string path, TrackedFileType type, SourceLineNumber sourceLineNumbers = null); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IBurnBackendHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IBurnBackendHelper.cs new file mode 100644 index 00000000..ef5fcc65 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IBurnBackendHelper.cs @@ -0,0 +1,50 @@ +// 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 WixToolset.Data; + + /// + /// Interface provided to help Burn backend extensions. + /// + public interface IBurnBackendHelper : IBackendHelper + { + /// + /// Adds the given XML to the BootstrapperApplicationData manifest. + /// + /// A valid XML fragment. + void AddBootstrapperApplicationData(string xml); + + /// + /// Adds an XML element for the given symbol to the BootstrapperApplicationData manifest. + /// The symbol's name is used for the element's name. + /// All of the symbol's fields are used for the element's attributes. + /// + /// The symbol to create the element from. + /// + /// If true and the symbol has an Id, + /// then an Id attribute is created with a value of the symbol's Id. + /// + void AddBootstrapperApplicationData(IntermediateSymbol symbol, bool symbolIdIsIdAttribute = false); + + /// + /// Adds the given XML to the BundleExtensionData manifest for the given bundle extension. + /// + /// The bundle extension's id. + /// A valid XML fragment. + void AddBundleExtensionData(string extensionId, string xml); + + /// + /// Adds an XML element for the given symbol to the BundleExtensionData manifest for the given bundle extension. + /// The symbol's name is used for the element's name. + /// All of the symbol's fields are used for the element's attributes. + /// + /// The bundle extension's id. + /// The symbol to create the element from. + /// + /// If true and the symbol has an Id, + /// then an Id attribute is created with a value of the symbol's Id. + /// + void AddBundleExtensionData(string extensionId, IntermediateSymbol symbol, bool symbolIdIsIdAttribute = false); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/ICommandLine.cs b/src/api/wix/WixToolset.Extensibility/Services/ICommandLine.cs new file mode 100644 index 00000000..2b841af0 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/ICommandLine.cs @@ -0,0 +1,33 @@ +// 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 WixToolset.Extensibility.Data; + + /// + /// Command-line parsing mechanism. + /// + public interface ICommandLine + { + /// + /// Simple way to parse arguments and create a command. + /// + /// Unparsed arguments. + /// Command if the command-line arguments can be parsed, otherwise null. + ICommandLineCommand CreateCommand(string[] args); + + /// + /// Simple way to parse arguments and create a command. + /// + /// Unparsed arguments. + /// Command if the command-line arguments can be parsed, otherwise null. + ICommandLineCommand CreateCommand(string commandLine); + + /// + /// Creates a command from populated arguments. + /// + /// Parsed arguments. + /// Command if the command-line arguments can be parsed, otherwise null. + ICommandLineCommand ParseStandardCommandLine(ICommandLineArguments arguments); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs b/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs new file mode 100644 index 00000000..cd17f100 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/ICommandLineParser.cs @@ -0,0 +1,40 @@ +// 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; + +#pragma warning disable 1591 // TODO: add documentation + public interface ICommandLineParser + { + string ErrorArgument { get; } + + /// + /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity + /// + /// The string check. + /// True if a valid switch, otherwise false. + bool IsSwitch(string arg); + + string GetArgumentAsFilePathOrError(string argument, string fileType); + + void GetArgumentAsFilePathOrError(string argument, string fileType, IList paths); + + string GetNextArgumentOrError(string commandLineSwitch); + + bool GetNextArgumentOrError(string commandLineSwitch, IList argument); + + string GetNextArgumentAsDirectoryOrError(string commandLineSwitch); + + bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList directories); + + string GetNextArgumentAsFilePathOrError(string commandLineSwitch); + + bool GetNextArgumentAsFilePathOrError(string commandLineSwitch, string fileType, IList paths); + + void ReportErrorArgument(string argument, Message message = null); + + bool TryGetNextSwitchOrArgument(out string arg); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IExtensionManager.cs b/src/api/wix/WixToolset.Extensibility/Services/IExtensionManager.cs new file mode 100644 index 00000000..8e49c38d --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IExtensionManager.cs @@ -0,0 +1,42 @@ +// 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 System.Reflection; + + /// + /// Loads extensions and uses the extensions' factories to provide services. + /// + public interface IExtensionManager + { + /// + /// Adds an extension assembly directly to the manager. + /// + /// Extension assembly. + void Add(Assembly extensionAssembly); + + /// + /// Loads an extension assembly from an extension reference string. + /// + /// Reference to the extension. + /// The loaded assembly. This assembly can be ignored since the extension manager maintains the list of loaded assemblies internally. + /// + /// can be in several different forms: + /// + /// Full path to an extension file (C:\MyExtensions\MyExtension.Example.wixext.dll) + /// Reference to latest version of an extension in the cache (MyExtension.Example.wixext) + /// Versioned reference to specific extension in the cache (MyExtension.Example.wixext/1.0.2) + /// Relative path to an extension file (..\..\MyExtensions\MyExtension.Example.wixext.dll) + /// + /// + void Load(string extensionReference); + + /// + /// Gets extensions of specified type from factories loaded into the extension manager. + /// + /// Type of extension to get. + /// Extensions of the specified type. + IReadOnlyCollection GetServices() where T : class; + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs b/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs new file mode 100644 index 00000000..fe77f2a4 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IMessaging.cs @@ -0,0 +1,73 @@ +// 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 WixToolset.Data; + + /// + /// Interface for handling messages (error/warning/verbose). + /// + public interface IMessaging + { + /// + /// Indicates whether an error has been found. + /// + /// A bool indicating whether an error has been found. + bool EncounteredError { get; } + + /// + /// Gets the last error code encountered during messaging. + /// + /// The exit code for the process. + int LastErrorNumber { get; } + + /// + /// Gets or sets the option to show verbose messages. + /// + /// The option to show verbose messages. + bool ShowVerboseMessages { get; set; } + + /// + /// Gets or sets the option to suppress all warning messages. + /// + /// The option to suppress all warning messages. + bool SuppressAllWarnings { get; set; } + + /// + /// Gets and sets the option to treat warnings as errors. + /// + /// The option to treat warnings as errors. + bool WarningsAsError { get; set; } + + /// + /// Sets the listener for messaging. + /// + /// + void SetListener(IMessageListener listener); + + /// + /// Adds a warning message id to be elevated to an error message. + /// + /// Id of the message to elevate. + void ElevateWarningMessage(int warningNumber); + + /// + /// Adds a warning message id to be suppressed in message output. + /// + /// Id of the message to suppress. + void SuppressWarningMessage(int warningNumber); + + /// + /// Sends a message with the given arguments. + /// + /// Message to write. + void Write(Message message); + + /// + /// Sends a message with the given arguments. + /// + /// Message to write. + /// Indicates where to write a verbose message. + void Write(string message, bool verbose = false); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs new file mode 100644 index 00000000..fbe5aae4 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs @@ -0,0 +1,466 @@ +// 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; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility.Data; + + /// + /// Interface provided to help compiler extensions parse. + /// + public interface IParseHelper + { + /// + /// Creates a version 3 name-based UUID. + /// + /// The namespace UUID. + /// The value. + /// The generated GUID for the given namespace and value. + string CreateGuid(Guid namespaceGuid, string value); + + /// + /// Create an identifier by hashing data from the row. + /// + /// Three letter or less prefix for generated row identifier. + /// Information to hash. + /// The new identifier. + Identifier CreateIdentifier(string prefix, params string[] args); + + /// + /// Create an identifier based on passed file name + /// + /// File name to generate identifier from + /// The new identifier. + Identifier CreateIdentifierFromFilename(string filename); + + /// + /// Append a suffix to the given name based on the current platform. + /// If the current platform is not in the supported platforms, then it returns null. + /// + /// The base name for the identifier. + /// The platform being compiled. + /// The platforms for which there are specialized implementations. + /// The generated identifier value, or null if the current platform isn't supported. + string CreateIdentifierValueFromPlatform(string name, Platform currentPlatform, BurnPlatforms supportedPlatforms); + + /// + /// Creates a symbol in the section. + /// + /// Section to add the new symbol to. + /// Source and line number of current symbol. + /// Name of symbol definition. + /// Optional identifier for the symbol. + /// New symbol. + IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, Identifier identifier = null); + + /// + /// Creates a symbol in the section. + /// + /// Section to add the new symbol to. + /// Source and line number of current symbol. + /// Symbol definition to create from. + /// Optional identifier for the symbol. + /// New symbol. + IntermediateSymbol CreateSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, Identifier identifier = null); + + /// + /// Creates a directory row from a name. + /// + /// Section to add the new symbol to. + /// Source line information. + /// Optional identifier for the new row. + /// Optional identifier for the parent row. + /// Long name of the directory. + /// Optional short name of the directory. + /// Optional source name for the directory. + /// Optional short source name for the directory. + /// Identifier for the newly created row. + Identifier CreateDirectorySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, string name, string shortName = null, string sourceName = null, string shortSourceName = null); + + /// + /// Creates directories using the inline directory syntax. + /// + /// Section to add the new symbol to. + /// Source line information. + /// Attribute containing the inline syntax. + /// Optional identifier of parent directory. + /// Optional inline syntax to override attribute's value. + /// Mapping of inline directory syntax to ids for the section. + /// Identifier of the leaf directory created. + string CreateDirectoryReferenceFromInlineSyntax(IntermediateSection section, SourceLineNumber sourceLineNumbers, XAttribute attribute, string parentId, string inlineSyntax, IDictionary sectionCachedInlinedDirectoryIds); + + /// + /// Creates a Registry symbol in the active section. + /// + /// Active section. + /// Source and line number of the current symbol. + /// The registry entry root. + /// The registry entry key. + /// The registry entry name. + /// The registry entry value. + /// The component which will control installation/uninstallation of the registry entry. + /// If true, "escape" leading '#' characters so the value is written as a REG_SZ. + Identifier CreateRegistrySymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, RegistryRootType root, string key, string name, string value, string componentId, bool escapeLeadingHash); + + /// + /// Create a WixSimpleReference symbol in the active section. + /// + /// Active section. + /// Source line information for the row. + /// The symbol name of the simple reference. + /// The primary key of the simple reference. + void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, string primaryKey); + + /// + /// Create a WixSimpleReference symbol in the active section. + /// + /// Active section. + /// Source line information for the row. + /// The symbol name of the simple reference. + /// The primary keys of the simple reference. + void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, string symbolName, params string[] primaryKeys); + + /// + /// Create a WixSimpleReference symbol in the active section. + /// + /// Active section. + /// Source line information for the row. + /// The symbol definition of the simple reference. + /// The primary key of the simple reference. + void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, string primaryKey); + + /// + /// Create a WixSimpleReference symbol in the active section. + /// + /// Active section. + /// Source line information for the row. + /// The symbol definition of the simple reference. + /// The primary keys of the simple reference. + void CreateSimpleReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, IntermediateSymbolDefinition symbolDefinition, params string[] primaryKeys); + + /// + /// Create a reference in the specified section for a custom action specialized for specific platforms, + /// given standard prefixes for naming and suffixes for platforms. + /// + /// Source line information. + /// Section to create the reference in. + /// The custom action base name. + /// The platform being compiled. + /// The platforms for which there are specialized custom actions. + void CreateCustomActionReference(SourceLineNumber sourceLineNumbers, IntermediateSection section, string customAction, Platform platform, CustomActionPlatforms supportedPlatforms); + + /// + /// Creates WixComplexReference and WixGroup symbols in the active section. + /// + /// Section to create the reference in. + /// Source line information. + /// The parent type. + /// The parent id. + /// The parent language. + /// The child type. + /// The child id. + /// Whether the child is primary. + void CreateComplexReference(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, string parentLanguage, ComplexReferenceChildType childType, string childId, bool isPrimary); + + /// + /// A symbol in the WixGroup table is added for this child node and its parent node. + /// + /// Section to create the reference in. + /// Source line information for the row. + /// Type of child's complex reference parent. + /// Id of the parenet node. + /// Complex reference type of child + /// Id of the Child Node. + void CreateWixGroupSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType childType, string childId); + + /// + /// Creates a symbol in the WixSearch table. + /// + /// Section to create the reference in. + /// Source line number for the search element. + /// Name of search element. + /// Identifier of the search. + /// The Burn variable to store the result into. + /// A condition to test before evaluating the search. + /// The search that this one will execute after. + /// The id of the bundle extension that handles this search. + void CreateWixSearchSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, string elementName, Identifier id, string variable, string condition, string after, string bundleExtensionId); + + /// + /// + /// + /// Section to create the reference in. + /// Source line number for the parent element. + /// Identifier of the search (key into the WixSearch table) + /// Identifier of the search that comes before (key into the WixSearch table) + /// Further details about the relation between id and parentId. + void CreateWixSearchRelationSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, Identifier id, string parentId, int attributes); + + /// + /// Checks if the string contains a property (i.e. "foo[Property]bar") + /// + /// String to evaluate for properties. + /// True if a property is found in the string. + bool ContainsProperty(string possibleProperty); + + /// + /// Add the appropriate symbols to make sure that the given table shows up in the resulting output. + /// + /// Active section. + /// Source line numbers. + /// Name of the table to ensure existance of. + void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, string tableName); + + /// + /// Add the appropriate symbols to make sure that the given table shows up in the resulting output. + /// + /// Active section. + /// Source line numbers. + /// Definition of the table to ensure existance of. + void EnsureTable(IntermediateSection section, SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition); + + /// + /// Get an attribute value and displays an error if the value is empty by default. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// A rule for the contents of the value. If the contents do not follow the rule, an error is thrown. + /// The attribute's value. + string GetAttributeValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, EmptyRule emptyRule = EmptyRule.CanBeWhitespaceOnly); + + /// + /// Get a guid attribute value and displays an error for an illegal guid value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// Determines whether the guid can be automatically generated. + /// If true, no error is raised on empty value. If false, an error is raised. + /// The attribute's guid value or a special value if an error occurred. + string GetAttributeGuidValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool generatable = false, bool canBeEmpty = false); + + /// + /// Get an identifier attribute value and displays an error for an illegal identifier value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's identifier value or a special value if an error occurred. + Identifier GetAttributeIdentifier(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Get an identifier attribute value and displays an error for an illegal identifier value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's identifier value or a special value if an error occurred. + string GetAttributeIdentifierValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Get an integer attribute value and displays an error for an illegal integer value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The minimum legal value. + /// The maximum legal value. + /// The attribute's integer value or a special value if an error occurred during conversion. + int GetAttributeIntegerValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, int minimum, int maximum); + + /// + /// Get a long integral attribute value and displays an error for an illegal long value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The minimum legal value. + /// The maximum legal value. + /// The attribute's long value or a special value if an error occurred during conversion. + long GetAttributeLongValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, long minimum, long maximum); + + /// + /// Gets a long filename value and displays an error for an illegal long filename value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// true if wildcards are allowed in the filename. + /// true if relative paths are allowed in the filename. + /// The attribute's long filename value. + string GetAttributeLongFilename(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowWildcards = false, bool allowRelative = false); + + /// + /// Gets a RegistryRootType value and displays an error for an illegal value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// Whether HKMU is returned as -1 (true), or treated as an error (false). + /// The attribute's RegisitryRootType value. + RegistryRootType? GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu); + + /// + /// Gets a version value or possibly a binder variable and displays an error for an illegal version value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's version value. + string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets a yes/no value and displays an error for an illegal yes/no value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's YesNoType value. + YesNoType GetAttributeYesNoValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Gets a yes/no/default value and displays an error for an illegal yes/no/default value. + /// + /// Source line information about the owner element. + /// The attribute containing the value to get. + /// The attribute's YesNoType value. + YesNoDefaultType GetAttributeYesNoDefaultValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); + + /// + /// Validates path is relative and canonicalizes it. + /// For example, "a\..\c\.\d.exe" => "c\d.exe". + /// + /// + /// + /// + /// + /// The original value if not relative, otherwise the canonicalized relative path. + string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath); + + /// + /// Gets a source line number for an element. + /// + /// Element to get source line number. + /// Source line number. + SourceLineNumber GetSourceLineNumbers(XElement element); + + /// + /// Gets node's inner text and ensure's it is safe for use in a condition by trimming any extra whitespace. + /// + /// The node to ensure inner text is a condition. + /// The value converted into a safe condition. + [Obsolete] + string GetConditionInnerText(XElement node); + + /// + /// Get an element's inner text and trims any extra whitespace. + /// + /// The element with inner text to be trimmed. + /// The node's inner text trimmed. + [Obsolete] + string GetTrimmedInnerText(XElement element); + + /// + /// Validates that the element does not contain inner text. + /// + /// Element to check for inner text. + void InnerTextDisallowed(XElement element); + + /// + /// Verifies that a value is a legal identifier. + /// + /// The value to verify. + /// true if the value is an identifier; false otherwise. + bool IsValidIdentifier(string value); + + /// + /// Verifies if an identifier is a valid loc identifier. + /// + /// Identifier to verify. + /// True if the identifier is a valid loc identifier. + bool IsValidLocIdentifier(string identifier); + + /// + /// Verifies if a filename is a valid long filename. + /// + /// Filename to verify. + /// true if wildcards are allowed in the filename. + /// true if relative paths are allowed in the filename. + /// True if the filename is a valid long filename + bool IsValidLongFilename(string filename, bool allowWildcards = false, bool allowRelative = false); + + /// + /// Verifies if a filename is a valid short filename. + /// + /// Filename to verify. + /// Indicates whether wildcards are allowed in the filename. + /// True if the filename is a valid short filename + bool IsValidShortFilename(string filename, bool allowWildcards); + + /// + /// Attempts to use an extension to parse the attribute. + /// + /// + /// Parent intermediate. + /// Parent section. + /// Element containing attribute to be parsed. + /// Attribute to be parsed. + /// Extra information about the context in which this element is being parsed. + void ParseExtensionAttribute(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement element, XAttribute attribute, IDictionary context = null); + + /// + /// Attempts to use an extension to parse the element. + /// + /// + /// Parent intermediate. + /// Parent section. + /// Element containing element to be parsed. + /// Element to be parsed. + /// Extra information about the context in which this element is being parsed. + void ParseExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context = null); + + /// + /// Attempts to use an extension to parse the element, with support for setting component keypath. + /// + /// + /// Parent intermediate. + /// Parent section. + /// Element containing element to be parsed. + /// Element to be parsed. + /// Extra information about the context in which this element is being parsed. + IComponentKeyPath ParsePossibleKeyPathExtensionElement(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context); + + /// + /// Process all children of the element looking for extensions and erroring on the unexpected. + /// + /// + /// Parent intermediate. + /// Parent section. + /// Element to parse children. + void ParseForExtensionElements(IEnumerable extensions, Intermediate intermediate, IntermediateSection section, XElement element); + + /// + /// Schedules an action symbol. + /// + /// Section to add the symbol to. + /// Source line information about the owner element. + /// Access modifier for the scheduled action. + /// Sequence to add the action to. + /// Name of action. + /// Optional condition of action. + /// Optional action to schedule before. + /// Option action to schedule after. + /// Optional overridable flag. + WixActionSymbol ScheduleActionSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string name, string condition, string beforeAction, string afterAction, bool overridable = false); + + /// + /// Called when the compiler encounters an unexpected attribute. + /// + /// Parent element that found unexpected attribute. + /// Unexpected attribute. + void UnexpectedAttribute(XElement element, XAttribute attribute); + + /// + /// Called when the compiler encounters an unexpected child element. + /// + /// Parent element that found unexpected child. + /// Unexpected child element. + void UnexpectedElement(XElement parentElement, XElement childElement); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IPathResolver.cs b/src/api/wix/WixToolset.Extensibility/Services/IPathResolver.cs new file mode 100644 index 00000000..64362174 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IPathResolver.cs @@ -0,0 +1,43 @@ +// 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; + + /// + /// Support for processing paths. + /// + public interface IPathResolver + { + /// + /// Get the canonical source path of a directory. + /// + /// All cached directories. + /// Hash table of Component GUID generation seeds indexed by directory id. + /// Directory identifier. + /// Current platform. + /// Source path of a directory. + string GetCanonicalDirectoryPath(Dictionary directories, Dictionary componentIdGenSeeds, string directory, Platform platform); + + /// + /// Get the source path of a directory. + /// + /// All cached directories. + /// Directory identifier. + /// Source path of a directory. + string GetDirectoryPath(Dictionary directories, string directory); + + /// + /// Gets the source path of a file. + /// + /// All cached directories in . + /// Parent directory identifier. + /// File name (in long|source format). + /// Specifies the package is compressed. + /// Specifies the package uses long file names. + /// Source path of file relative to package directory. + string GetFileSourcePath(Dictionary directories, string directoryId, string fileName, bool compressed, bool useLongName); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IPreprocessHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IPreprocessHelper.cs new file mode 100644 index 00000000..f7973ac2 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IPreprocessHelper.cs @@ -0,0 +1,90 @@ +// 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.Xml.Linq; + using WixToolset.Extensibility.Data; + + /// + /// Interface provided to help preprocessor extensions. + /// + public interface IPreprocessHelper + { + /// + /// Add a variable. + /// + /// The preprocess context. + /// The variable name. + /// The variable value. + void AddVariable(IPreprocessContext context, string name, string value); + + /// + /// Add a variable. + /// + /// The preprocess context. + /// The variable name. + /// The variable value. + /// Set to true to show variable overwrite warning. + void AddVariable(IPreprocessContext context, string name, string value, bool showWarning); + + /// + /// Evaluate a function. + /// + /// The preprocess context. + /// The function expression including the prefix and name. + /// The function value. + string EvaluateFunction(IPreprocessContext context, string function); + + /// + /// Evaluate a function. + /// + /// The preprocess context. + /// The function prefix. + /// The function name. + /// The arguments for the function. + /// The function value or null if the function is not defined. + string EvaluateFunction(IPreprocessContext context, string prefix, string function, string[] args); + + /// + /// Get the value of a variable expression like var.name. + /// + /// The preprocess context. + /// The variable expression including the optional prefix and name. + /// true to allow the variable prefix to be missing. + /// The variable value. + string GetVariableValue(IPreprocessContext context, string variable, bool allowMissingPrefix); + + /// + /// Get the value of a variable. + /// + /// The preprocess context. + /// The variable prefix. + /// The variable name. + /// The variable value or null if the variable is not set. + string GetVariableValue(IPreprocessContext context, string prefix, string name); + + /// + /// Evaluate a Pragma. + /// + /// The preprocess context. + /// The pragma's full name (<prefix>.<pragma>). + /// The arguments to the pragma. + /// The parent element of the pragma. + void PreprocessPragma(IPreprocessContext context, string pragmaName, string args, XContainer parent); + + /// + /// Replaces parameters in the source text. + /// + /// The preprocess context. + /// Text that may contain parameters to replace. + /// Text after parameters have been replaced. + string PreprocessString(IPreprocessContext context, string value); + + /// + /// Remove a variable. + /// + /// The preprocess context. + /// The variable name. + void RemoveVariable(IPreprocessContext context, string name); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IVariableResolution.cs b/src/api/wix/WixToolset.Extensibility/Services/IVariableResolution.cs new file mode 100644 index 00000000..adcec47f --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IVariableResolution.cs @@ -0,0 +1,30 @@ +// 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 +{ + /// + /// Result when resolving a variable. + /// + public interface IVariableResolution + { + /// + /// Indicates if the value contains variables that cannot be resolved yet. + /// + bool DelayedResolve { get; set; } + + /// + /// Indicates whether a bind variables default value was used in the resolution. + /// + bool IsDefault { get; set; } + + /// + /// Indicates whether the resolution updated the value. + /// + bool UpdatedValue { get; set; } + + /// + /// The resolved value. + /// + string Value { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IVariableResolver.cs b/src/api/wix/WixToolset.Extensibility/Services/IVariableResolver.cs new file mode 100644 index 00000000..285f1fd1 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IVariableResolver.cs @@ -0,0 +1,48 @@ +// 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 WixToolset.Data; + +#pragma warning disable 1591 // TODO: add documentation + public interface IVariableResolver + { + void AddLocalization(Localization localization); +#pragma warning restore 1591 + + /// + /// Add a variable. + /// + /// The source line information for the value. + /// The name of the variable. + /// The value of the variable. + /// Indicates whether the variable can be overridden by an existing variable. + void AddVariable(SourceLineNumber sourceLineNumber, string name, string value, bool overridable); + + /// + /// Resolve the wix variables in a value. + /// + /// The source line information for the value. + /// The value to resolve. + /// The resolved result. + IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value); + + /// + /// Resolve the wix variables in a value. + /// + /// The source line information for the value. + /// The value to resolve. + /// true if unknown variables should throw errors. + /// The resolved value. + IVariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool errorOnUnknown); + + /// + /// Try to find localization information for dialog and (optional) control. + /// + /// Dialog identifier. + /// Optional control identifier. + /// Found localization information. + /// True if localized control was found, otherwise false. + bool TryGetLocalizedControl(string dialog, string control, out LocalizedControl localizedControl); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs new file mode 100644 index 00000000..81325131 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IWindowsInstallerBackendHelper.cs @@ -0,0 +1,35 @@ +// 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 WixToolset.Data; + using WixToolset.Data.WindowsInstaller; + + /// + /// Interface provided to help Windows Installer backend extensions. + /// + public interface IWindowsInstallerBackendHelper : IBackendHelper + { + /// + /// Creates a in the specified table. + /// + /// Parent section. + /// Symbol with line information for the row. + /// Windows Installer data. + /// Table definition for the row. + /// Row created in the . + Row CreateRow(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinition tableDefinition); + + /// + /// Looks up the registered for the given and creates a in that table. + /// Goes sequentially through each field in the symbol and assigns the value to the column with the same index as the field. + /// If the symbol's Id is registered as the primary key then that is used for the first column and the column data is offset by 1. + /// + /// Parent section. + /// Symbol to create the row from. + /// Windows Installer data. + /// Table definitions that have been registered with the binder. + /// True if a row was created. + bool TryAddSymbolToMatchingTableDefinitions(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IWixBranding.cs b/src/api/wix/WixToolset.Extensibility/Services/IWixBranding.cs new file mode 100644 index 00000000..4bac9ccd --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IWixBranding.cs @@ -0,0 +1,26 @@ +// 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.Reflection; + + /// + /// WiX branding interface. + /// + public interface IWixBranding + { + /// + /// Gets the value for CreatingApplication field (MSI Summary Information Stream). + /// + /// String for creating application. + string GetCreatingApplication(); + + /// + /// Replaces branding placeholders in original string. + /// + /// Original string containing placeholders to replace. + /// Optional assembly with branding information, if not specified core branding is used. + /// + string ReplacePlaceholders(string original, Assembly assembly = null); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs b/src/api/wix/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs new file mode 100644 index 00000000..f5fb28fb --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/IWixtoolsetCoreServiceProvider.cs @@ -0,0 +1,34 @@ +// 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; + using System.Collections.Generic; + + /// + /// The core of the service provider used to add services to the service provider. + /// + public interface IWixToolsetCoreServiceProvider : IServiceProvider + { + /// + /// Adds a service to the service locator. + /// + /// Type of the service to add. + /// + /// A function that creates the service. The create function is provided the service provider + /// itself to resolve additional services and a type dictionary that stores singleton services + /// the creation function can add its service to. + /// + void AddService(Type serviceType, Func, object> creationFunction); + + /// + /// Adds a service to the service locator. + /// + /// + /// A function that creates the service. The create function is provided the service provider + /// itself to resolve additional services and a type dictionary that stores singleton services + /// the creation function can add its service to. + /// + void AddService(Func, T> creationFunction) where T : class; + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs b/src/api/wix/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs new file mode 100644 index 00000000..68484d09 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Services/ServiceProviderExtensions.cs @@ -0,0 +1,48 @@ +// 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; + + /// + /// Service provider extensions. + /// + public static class ServiceProviderExtensions + { + /// + /// Gets a service from the service provider. + /// + /// Type of service to get. + /// Service provider. + public static T GetService(this IServiceProvider provider) where T : class + { + return provider.GetService(typeof(T)) as T; + } + + /// + /// Gets a service from the service provider. + /// + /// Service provider. + /// Type of service to get. + /// Retrieved service. + /// True if the service was found, otherwise false + public static bool TryGetService(this IServiceProvider provider, Type serviceType, out object service) + { + service = provider.GetService(serviceType); + return service != null; + } + + /// + /// Gets a service from the service provider. + /// + /// Type of service to get. + /// Service provider. + /// Retrieved service. + /// True if the service was found, otherwise false + public static bool TryGetService(this IServiceProvider provider, out T service) where T : class + { + service = provider.GetService(typeof(T)) as T; + return service != null; + } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.csproj b/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.csproj new file mode 100644 index 00000000..8b18c0ed --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.csproj @@ -0,0 +1,23 @@ + + + + + + netstandard2.0 + $(TargetFrameworks);net461;net472 + WiX Toolset Extensibility + + embedded + true + true + + + + + + + + + + + diff --git a/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.v3.ncrunchproject b/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.v3.ncrunchproject new file mode 100644 index 00000000..c6001ebe --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/WixToolset.Extensibility.v3.ncrunchproject @@ -0,0 +1,7 @@ + + + + ..\..\version.json + + + \ No newline at end of file diff --git a/src/api/wix/appveyor-Extensibility.cmd b/src/api/wix/appveyor-Extensibility.cmd new file mode 100644 index 00000000..e0dfe33f --- /dev/null +++ b/src/api/wix/appveyor-Extensibility.cmd @@ -0,0 +1,7 @@ +@setlocal +@pushd %~dp0 + +dotnet pack -c Release + +@popd +@endlocal \ No newline at end of file diff --git a/src/api/wix/appveyor-Extensibility.yml b/src/api/wix/appveyor-Extensibility.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/api/wix/appveyor-Extensibility.yml @@ -0,0 +1,40 @@ +# 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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/api/wix/nuget-Extensibility.config b/src/api/wix/nuget-Extensibility.config new file mode 100644 index 00000000..6ab85be3 --- /dev/null +++ b/src/api/wix/nuget-Extensibility.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb