From 6f29d2fc2b3514cc85a7975e974e8e31f39288e2 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 3 Feb 2019 14:43:56 -0600 Subject: Integrate into latest v4. --- src/Cpp.Build.props | 104 ++++++++ src/Directory.Build.props | 28 +++ src/Directory.Build.targets | 48 ++++ src/FindLocalWix.props | 8 + src/ca/custommsierrors.h | 5 + src/ca/dependencyca.vcxproj | 61 +++++ src/ca/dependencyca.vcxproj.filters | 35 +++ src/ca/packages.config | 5 + src/ca/wixdepca.def | 2 +- src/ca/wixdepca.vcxproj | 57 ----- src/ca/wixdepca.vcxproj.filters | 40 ---- .../DependencyExtensionFixture.cs | 32 +++ .../TestData/UsingProvides/Package.en-us.wxl | 11 + .../TestData/UsingProvides/Package.wxs | 22 ++ .../TestData/UsingProvides/PackageComponents.wxs | 12 + .../TestData/UsingProvides/example.txt | 1 + .../WixToolsetTest.Dependency.csproj | 38 +++ src/wixext/DependencyBinder.cs | 169 ------------- src/wixext/DependencyCommon.cs | 2 +- src/wixext/DependencyCompiler.cs | 263 ++++++++++----------- src/wixext/DependencyDecompiler.cs | 4 +- src/wixext/DependencyErrors.cs | 37 +++ src/wixext/DependencyExtension.csproj | 50 ---- src/wixext/DependencyExtensionData.cs | 52 +--- src/wixext/DependencyExtensionFactory.cs | 18 ++ src/wixext/DependencyWarnings.cs | 60 +++++ ...ndencyWindowsInstallerBackendBinderExtension.cs | 181 ++++++++++++++ src/wixext/Tuples/DependencyTupleDefinitions.cs | 47 ++++ src/wixext/Tuples/WixDependencyProviderTuple.cs | 87 +++++++ src/wixext/Tuples/WixDependencyRefTuple.cs | 55 +++++ src/wixext/Tuples/WixDependencyTuple.cs | 79 +++++++ src/wixext/WixToolset.Dependency.wixext.csproj | 33 +++ src/wixext/WixToolset.Dependency.wixext.targets | 11 + src/wixext/messages.xml | 60 ----- src/wixlib/DependencyExtension.wixproj | 27 --- src/wixlib/DependencyExtension_Platform.wxi | 6 +- src/wixlib/caSuffix.wxi | 28 +++ src/wixlib/caerr.wxi | 96 ++++++++ src/wixlib/dependency.wixproj | 43 ++++ src/wixlib/packages.config | 5 + 40 files changed, 1337 insertions(+), 585 deletions(-) create mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Build.targets create mode 100644 src/FindLocalWix.props create mode 100644 src/ca/custommsierrors.h create mode 100644 src/ca/dependencyca.vcxproj create mode 100644 src/ca/dependencyca.vcxproj.filters create mode 100644 src/ca/packages.config delete mode 100644 src/ca/wixdepca.vcxproj delete mode 100644 src/ca/wixdepca.vcxproj.filters create mode 100644 src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs create mode 100644 src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs create mode 100644 src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt create mode 100644 src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj delete mode 100644 src/wixext/DependencyBinder.cs create mode 100644 src/wixext/DependencyErrors.cs delete mode 100644 src/wixext/DependencyExtension.csproj create mode 100644 src/wixext/DependencyExtensionFactory.cs create mode 100644 src/wixext/DependencyWarnings.cs create mode 100644 src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs create mode 100644 src/wixext/Tuples/DependencyTupleDefinitions.cs create mode 100644 src/wixext/Tuples/WixDependencyProviderTuple.cs create mode 100644 src/wixext/Tuples/WixDependencyRefTuple.cs create mode 100644 src/wixext/Tuples/WixDependencyTuple.cs create mode 100644 src/wixext/WixToolset.Dependency.wixext.csproj create mode 100644 src/wixext/WixToolset.Dependency.wixext.targets delete mode 100644 src/wixext/messages.xml delete mode 100644 src/wixlib/DependencyExtension.wixproj create mode 100644 src/wixlib/caSuffix.wxi create mode 100644 src/wixlib/caerr.wxi create mode 100644 src/wixlib/dependency.wixproj create mode 100644 src/wixlib/packages.config (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props new file mode 100644 index 00000000..0e00132b --- /dev/null +++ b/src/Cpp.Build.props @@ -0,0 +1,104 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..a22f4470 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,28 @@ + + + + + + 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/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + 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/FindLocalWix.props b/src/FindLocalWix.props new file mode 100644 index 00000000..a784e352 --- /dev/null +++ b/src/FindLocalWix.props @@ -0,0 +1,8 @@ + + + + + + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + + diff --git a/src/ca/custommsierrors.h b/src/ca/custommsierrors.h new file mode 100644 index 00000000..26450452 --- /dev/null +++ b/src/ca/custommsierrors.h @@ -0,0 +1,5 @@ +#pragma once +// 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. + +#define msierrDependencyMissingDependencies 26451 +#define msierrDependencyHasDependents 26452 diff --git a/src/ca/dependencyca.vcxproj b/src/ca/dependencyca.vcxproj new file mode 100644 index 00000000..480a1861 --- /dev/null +++ b/src/ca/dependencyca.vcxproj @@ -0,0 +1,61 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + {B86AF46C-0F90-49CC-923F-A800B088D015} + DynamicLibrary + v141 + Unicode + dependencyca + wixdepca.def + WiX Toolset Dependency CustomAction + + + + + + + msi.lib + + + + + Create + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + diff --git a/src/ca/dependencyca.vcxproj.filters b/src/ca/dependencyca.vcxproj.filters new file mode 100644 index 00000000..d4931f32 --- /dev/null +++ b/src/ca/dependencyca.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/src/ca/packages.config b/src/ca/packages.config new file mode 100644 index 00000000..ab964d2c --- /dev/null +++ b/src/ca/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/ca/wixdepca.def b/src/ca/wixdepca.def index df50e992..651c6373 100644 --- a/src/ca/wixdepca.def +++ b/src/ca/wixdepca.def @@ -1,7 +1,7 @@ ; 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. -LIBRARY "wixdepca" +LIBRARY "dependencyca" EXPORTS WixDependencyRequire diff --git a/src/ca/wixdepca.vcxproj b/src/ca/wixdepca.vcxproj deleted file mode 100644 index b757a35f..00000000 --- a/src/ca/wixdepca.vcxproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - Debug - Win32 - - - Release - Win32 - - - - - Debug - ARM - - - Release - ARM - - - - - {B86AF46C-0F90-49CC-923F-A800B088D015} - DynamicLibrary - Unicode - WixDepCA - wixdepca.def - - - - - - $(WixRoot)src\libs\dutil\inc;$(WixRoot)src\libs\wcautil;$(WixRoot)src\libs\deputil\inc - msi.lib;dutil.lib;deputil.lib;wcautil.lib - - - - - - - - - - - - - - - - - - diff --git a/src/ca/wixdepca.vcxproj.filters b/src/ca/wixdepca.vcxproj.filters deleted file mode 100644 index 1fdb0236..00000000 --- a/src/ca/wixdepca.vcxproj.filters +++ /dev/null @@ -1,40 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - - - Header Files - - - - - Resource Files - - - - - Source Files - - - \ No newline at end of file diff --git a/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs b/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs new file mode 100644 index 00000000..07d6228e --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.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 WixToolsetTest.Dependency +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Dependency; + using Xunit; + + public class DependencyExtensionFixture + { + [Fact] + public void CanBuildUsingProvides() + { + var folder = TestData.Get(@"TestData\UsingProvides"); + var build = new Builder(folder, typeof(DependencyExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "WixDependencyProvider"); + Assert.Equal(new[] + { + "WixDependencyProvider:depJQsOasf1FRUsKxq8THB9sXk8yws\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tUsingProvides\t\t\t0", + }, results.OrderBy(s => s).ToArray()); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.en-us.wxl b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs new file mode 100644 index 00000000..68ff98fd --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs new file mode 100644 index 00000000..e241fb17 --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj b/src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj new file mode 100644 index 00000000..342325df --- /dev/null +++ b/src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj @@ -0,0 +1,38 @@ + + + + + + netcoreapp2.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/DependencyBinder.cs b/src/wixext/DependencyBinder.cs deleted file mode 100644 index 13fea203..00000000 --- a/src/wixext/DependencyBinder.cs +++ /dev/null @@ -1,169 +0,0 @@ -// 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.Extensions -{ - using System; - using System.Collections.ObjectModel; - using System.Globalization; - using WixToolset.Data; - using WixToolset.Extensibility; - - /// - /// The compiler for the WiX toolset dependency extension. - /// - public sealed class DependencyBinder : BinderExtension - { - private Output output; - - /// - /// Called after all output changes occur and right before the output is bound into its final format. - /// - public override void Finish(Output output) - { - // Only process MSI packages. - if (OutputType.Product != output.Type) - { - return; - } - - this.output = output; - - Table wixDependencyTable = output.Tables["WixDependency"]; - Table wixDependencyProviderTable = output.Tables["WixDependencyProvider"]; - Table wixDependencyRefTable = output.Tables["WixDependencyRef"]; - - // Make sure there's something to do. - if (null != wixDependencyRefTable) - { - KeyedRowCollection wixDependencyRows = new KeyedRowCollection(wixDependencyTable); - KeyedRowCollection wixDependencyProviderRows = new KeyedRowCollection(wixDependencyProviderTable); - - // For each relationship, get the provides and requires rows to generate registry values. - foreach (Row wixDependencyRefRow in wixDependencyRefTable.Rows) - { - string providesId = (string)wixDependencyRefRow[0]; - string requiresId = (string)wixDependencyRefRow[1]; - - Row wixDependencyRow = null; - if (wixDependencyRows.Contains(requiresId)) - { - wixDependencyRow = wixDependencyRows[requiresId]; - } - - Row wixDependencyProviderRow = null; - if (wixDependencyProviderRows.Contains(providesId)) - { - wixDependencyProviderRow = wixDependencyProviderRows[providesId]; - } - - // If we found both rows, generate the registry values. - if (null != wixDependencyRow && null != wixDependencyProviderRow) - { - // Format the root registry key using the required provider key and the current provider key. - string requiresKey = (string)wixDependencyRow[1]; - string providesKey = (string)wixDependencyProviderRow[2]; - string keyRequires = String.Format(@"{0}{1}\{2}\{3}", DependencyCommon.RegistryRoot, requiresKey, DependencyCommon.RegistryDependents, providesKey); - - // Get the component ID from the provider. - string componentId = (string)wixDependencyProviderRow[1]; - - Row row = this.CreateRegistryRow(wixDependencyRow); - row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "(Default)"); - row[1] = -1; - row[2] = keyRequires; - row[3] = "*"; - row[4] = null; - row[5] = componentId; - - string minVersion = (string)wixDependencyRow[2]; - if (!String.IsNullOrEmpty(minVersion)) - { - row = this.CreateRegistryRow(wixDependencyRow); - row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MinVersion"); - row[1] = -1; - row[2] = keyRequires; - row[3] = "MinVersion"; - row[4] = minVersion; - row[5] = componentId; - } - - string maxVersion = (string)wixDependencyRow[3]; - if (!String.IsNullOrEmpty(minVersion)) - { - row = this.CreateRegistryRow(wixDependencyRow); - row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MaxVersion"); - row[1] = -1; - row[2] = keyRequires; - row[3] = "MaxVersion"; - row[4] = maxVersion; - row[5] = componentId; - } - - if (null != wixDependencyRow[4]) - { - int attributes = (int)wixDependencyRow[4]; - - row = this.CreateRegistryRow(wixDependencyRow); - row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "Attributes"); - row[1] = -1; - row[2] = keyRequires; - row[3] = "Attributes"; - row[4] = String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat)); - row[5] = componentId; - } - } - } - } - } - - /// - /// Creates a registry row using source information from the given . - /// - /// The from which the section and source line information are retrieved. - /// A new Registry row. - private Row CreateRegistryRow(Row referenceRow) - { - TableDefinition tableDefinition = this.Core.TableDefinitions["Registry"]; - - // Create the row from the main tables, which were populated during link anyway. - // We still associate the table with the dependency row's section to maintain servicing. - Table table = this.output.EnsureTable(tableDefinition, referenceRow.Table.Section); - Row row = table.CreateRow(referenceRow.SourceLineNumbers); - - // Set the section ID for patching and return the new row. - row.SectionId = referenceRow.SectionId; - return row; - } - - /// - /// A keyed collection of instances for O(1) lookup. - /// - private sealed class KeyedRowCollection : KeyedCollection - { - /// - /// Initializes the class with all rows from the specified . - /// - /// The containing rows to index. - internal KeyedRowCollection(Table table) - { - if (null != table) - { - foreach (Row row in table.Rows) - { - this.Add(row); - } - } - } - - /// - /// Gets the primary key for the . - /// - /// The to index. - /// The primary key for the . - protected override string GetKeyForItem(Row row) - { - return row.GetPrimaryKey('/'); - } - } - } -} diff --git a/src/wixext/DependencyCommon.cs b/src/wixext/DependencyCommon.cs index 4826d8b0..cb36be36 100644 --- a/src/wixext/DependencyCommon.cs +++ b/src/wixext/DependencyCommon.cs @@ -1,6 +1,6 @@ // 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.Extensions +namespace WixToolset.Dependency { using System; using WixToolset; diff --git a/src/wixext/DependencyCompiler.cs b/src/wixext/DependencyCompiler.cs index a138c047..f866b589 100644 --- a/src/wixext/DependencyCompiler.cs +++ b/src/wixext/DependencyCompiler.cs @@ -1,6 +1,6 @@ // 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.Extensions +namespace WixToolset.Dependency { using System; using System.Collections.Generic; @@ -9,11 +9,12 @@ namespace WixToolset.Extensions using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; /// - /// The compiler for the WiX toolset dependency extension. + /// The compiler for the WiX Toolset Dependency Extension. /// - public sealed class DependencyCompiler : CompilerExtension + public sealed class DependencyCompiler : BaseCompilerExtension { /// /// Package type when parsing the Provides element. @@ -27,10 +28,7 @@ namespace WixToolset.Extensions MsuPackage } - public DependencyCompiler() - { - this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/dependency"; - } + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/dependency"; /// /// Processes an attribute for the Compiler. @@ -38,24 +36,24 @@ namespace WixToolset.Extensions /// Source line number for the parent element. /// Parent element of attribute. /// Attribute to process. - public override void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context) + public override void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); switch (parentElement.Name.LocalName) { case "Bundle": switch (attribute.Name.LocalName) { case "ProviderKey": - this.ParseProviderKeyAttribute(sourceLineNumbers, parentElement, attribute); + this.ParseProviderKeyAttribute(section, sourceLineNumbers, parentElement, attribute); break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } } @@ -67,7 +65,7 @@ namespace WixToolset.Extensions /// Parent element of element to process. /// Element to process. /// Extra information about the context in which this element is being parsed. - public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { PackageType packageType = PackageType.None; @@ -80,10 +78,10 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "Requires": - this.ParseRequiresElement(element, null, false); + this.ParseRequiresElement(intermediate, section, element, null, false); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; @@ -100,7 +98,7 @@ namespace WixToolset.Extensions packageType = PackageType.MsuPackage; break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } @@ -111,10 +109,10 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "Provides": - this.ParseProvidesElement(element, packageType, packageId); + this.ParseProvidesElement(intermediate, section, element, packageType, packageId); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } } @@ -127,9 +125,9 @@ namespace WixToolset.Extensions /// Element to process. /// Extra information about the context in which this element is being parsed. /// The component key path type if set. - public override ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary context) + public override ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); ComponentKeyPath keyPath = null; switch (parentElement.Name.LocalName) @@ -146,18 +144,18 @@ namespace WixToolset.Extensions case "Provides": if (win64) { - this.Core.OnMessage(DependencyWarnings.Win64Component(sourceLineNumbers, componentId)); + this.Messaging.Write(DependencyWarnings.Win64Component(sourceLineNumbers, componentId)); } - keyPath = this.ParseProvidesElement(element, PackageType.None, componentId); + keyPath = this.ParseProvidesElement(intermediate, section, element, PackageType.None, componentId); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } @@ -170,7 +168,7 @@ namespace WixToolset.Extensions /// Source line number for the parent element. /// Parent element of attribute. /// The XML attribute for the ProviderKey attribute. - private void ParseProviderKeyAttribute(SourceLineNumber sourceLineNumbers, XElement parentElement, XAttribute attribute) + private void ParseProviderKeyAttribute(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement parentElement, XAttribute attribute) { Identifier id = null; string providerKey = null; @@ -179,41 +177,41 @@ namespace WixToolset.Extensions switch (attribute.Name.LocalName) { case "ProviderKey": - providerKey = this.Core.GetAttributeValue(sourceLineNumbers, attribute); + providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); break; default: - this.Core.UnexpectedAttribute(parentElement, attribute); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); break; } // Make sure the key does not contain any illegal characters or values. if (String.IsNullOrEmpty(providerKey)) { - this.Core.OnMessage(WixErrors.IllegalEmptyAttributeValue(sourceLineNumbers, parentElement.Name.LocalName, attribute.Name.LocalName)); + this.Messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, parentElement.Name.LocalName, attribute.Name.LocalName)); } else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) { StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); + this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); } else if ("ALL" == providerKey) { - this.Core.OnMessage(DependencyErrors.ReservedValue(sourceLineNumbers, parentElement.Name.LocalName, "ProviderKey", providerKey)); + this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, parentElement.Name.LocalName, "ProviderKey", providerKey)); } // Generate the primary key for the row. - id = this.Core.CreateIdentifier("dep", attribute.Name.LocalName, providerKey); + id = this.ParseHelper.CreateIdentifier("dep", attribute.Name.LocalName, providerKey); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { // Create the provider row for the bundle. The Component_ field is required // in the table definition but unused for bundles, so just set it to the valid ID. - Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyProvider", id); - row[1] = id.Id; - row[2] = providerKey; - row[5] = DependencyCommon.ProvidesAttributesBundle; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyProvider", id); + row.Set(1, id.Id); + row.Set(2, providerKey); + row.Set(5, DependencyCommon.ProvidesAttributesBundle); } } @@ -225,9 +223,9 @@ namespace WixToolset.Extensions /// Explicit key path. /// The identifier of the parent component or package. /// The type of key path if set. - private ComponentKeyPath ParseProvidesElement(XElement node, PackageType packageType, string parentId) + private ComponentKeyPath ParseProvidesElement(Intermediate intermediate, IntermediateSection section, XElement node, PackageType packageType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); ComponentKeyPath keyPath = null; Identifier id = null; string key = null; @@ -243,25 +241,25 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + key = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Version": - version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + displayName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } @@ -275,22 +273,22 @@ namespace WixToolset.Extensions StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); + this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); } else if ("ALL" == key) { - this.Core.OnMessage(DependencyErrors.ReservedValue(sourceLineNumbers, node.Name.LocalName, "Key", key)); + this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, node.Name.LocalName, "Key", key)); } } else if (PackageType.ExePackage == packageType || PackageType.MsuPackage == packageType) { // Must specify the provider key when authored for a package. - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); } else if (PackageType.None == packageType) { // Make sure the ProductCode is authored and set the key. - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "ProductCode"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Property", "ProductCode"); key = "!(bind.property.ProductCode)"; } @@ -300,23 +298,23 @@ namespace WixToolset.Extensions switch (packageType) { case PackageType.None: - this.Core.OnMessage(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); + this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); break; case PackageType.MsiPackage: - this.Core.OnMessage(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers, parentId)); + this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers, parentId)); break; } } else if (PackageType.MspPackage == packageType || PackageType.MsuPackage == packageType) { // Must specify the Version when authored for packages that do not contain a version. - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Version")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Version")); } // Need the element ID for child element processing, so generate now if not authored. if (null == id) { - id = this.Core.CreateIdentifier("dep", node.Name.LocalName, parentId, key); + id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, parentId, key); } foreach (XElement child in node.Elements()) @@ -326,94 +324,93 @@ namespace WixToolset.Extensions switch (child.Name.LocalName) { case "Requires": - this.ParseRequiresElement(child, id.Id, PackageType.None == packageType); + this.ParseRequiresElement(intermediate, section, child, id.Id, PackageType.None == packageType); break; case "RequiresRef": - this.ParseRequiresRefElement(child, id.Id, PackageType.None == packageType); + this.ParseRequiresRefElement(intermediate, section, child, id.Id, PackageType.None == packageType); break; default: - this.Core.UnexpectedElement(node, child); + this.ParseHelper.UnexpectedElement(node, child); break; } } else { - this.Core.ParseExtensionElement(node, child); + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); } } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { // Create the row in the provider table. - Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyProvider", id); - row[1] = parentId; - row[2] = key; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyProvider", id); + row.Set(1, parentId); + row.Set(2, key); if (!String.IsNullOrEmpty(version)) { - row[3] = version; + row.Set(3, version); } if (!String.IsNullOrEmpty(displayName)) { - row[4] = displayName; + row.Set(4, displayName); } if (0 != attributes) { - row[5] = attributes; + row.Set(5, attributes); } if (PackageType.None == packageType) { // Reference the Check custom action to check for dependencies on the current provider. - if (Platform.ARM == this.Core.CurrentPlatform) + if (Platform.ARM == this.Context.Platform) { // Ensure the ARM version of the CA is referenced. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyCheck_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck_ARM"); } else { // All other supported platforms use x86. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyCheck"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck"); } // Generate registry rows for the provider using binder properties. string keyProvides = String.Concat(DependencyCommon.RegistryRoot, key); - row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "(Default)")); - row[1] = -1; - row[2] = keyProvides; - row[3] = null; - row[4] = "[ProductCode]"; - row[5] = parentId; + row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "(Default)")); + row.Set(1, -1); + row.Set(2, keyProvides); + row.Set(4, "[ProductCode]"); + row.Set(5, parentId); // Use the Version registry value and use that as a potential key path. - Identifier idVersion = this.Core.CreateIdentifier("reg", id.Id, "Version"); + Identifier idVersion = this.ParseHelper.CreateIdentifier("reg", id.Id, "Version"); keyPath = new ComponentKeyPath() { Id = idVersion.Id, Explicit = false, Type = ComponentKeyPathType.Registry }; - row = this.Core.CreateRow(sourceLineNumbers, "Registry", idVersion); - row[1] = -1; - row[2] = keyProvides; - row[3] = "Version"; - row[4] = !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"; - row[5] = parentId; + row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", idVersion); + row.Set(1, -1); + row.Set(2, keyProvides); + row.Set(3, "Version"); + row.Set(4, !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"); + row.Set(5, parentId); - row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "DisplayName")); - row[1] = -1; - row[2] = keyProvides; - row[3] = "DisplayName"; - row[4] = !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"; - row[5] = parentId; + row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "DisplayName")); + row.Set(1, -1); + row.Set(2, keyProvides); + row.Set(3, "DisplayName"); + row.Set(4, !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"); + row.Set(5, parentId); if (0 != attributes) { - row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "Attributes")); - row[1] = -1; - row[2] = keyProvides; - row[3] = "Attributes"; - row[4] = String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat)); - row[5] = parentId; + row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "Attributes")); + row.Set(1, -1); + row.Set(2, keyProvides); + row.Set(3, "Attributes"); + row.Set(4, String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat))); + row.Set(5, parentId); } } } @@ -427,9 +424,9 @@ namespace WixToolset.Extensions /// The XML node for the Requires element. /// The parent provider identifier. /// Whether the Requires custom action should be referenced. - private void ParseRequiresElement(XElement node, string providerId, bool requiresAction) + private void ParseRequiresElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); Identifier id = null; string providerKey = null; string minVersion = null; @@ -444,41 +441,41 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ProviderKey": - providerKey = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Minimum": - minVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + minVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "Maximum": - maxVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + maxVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); break; case "IncludeMinimum": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DependencyCommon.RequiresAttributesMinVersionInclusive; } break; case "IncludeMaximum": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DependencyCommon.RequiresAttributesMaxVersionInclusive; } break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (null == id) { @@ -486,18 +483,18 @@ namespace WixToolset.Extensions // element will be necessary and the Id attribute will be required. if (!String.IsNullOrEmpty(providerId)) { - id = this.Core.CreateIdentifier("dep", node.Name.LocalName, providerKey); + id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, providerKey); } else { - this.Core.OnMessage(WixErrors.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); + this.Messaging.Write(ErrorMessages.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); id = Identifier.Invalid; } } if (String.IsNullOrEmpty(providerKey)) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "ProviderKey")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "ProviderKey")); } // Make sure the key does not contain any illegal characters. else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) @@ -505,44 +502,44 @@ namespace WixToolset.Extensions StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); + this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { // Reference the Require custom action if required. if (requiresAction) { - if (Platform.ARM == this.Core.CurrentPlatform) + if (Platform.ARM == this.Context.Platform) { // Ensure the ARM version of the CA is referenced. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); } else { // All other supported platforms use x86. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire"); } } - Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependency", id); - row[1] = providerKey; - row[2] = minVersion; - row[3] = maxVersion; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependency", id); + row.Set(1, providerKey); + row.Set(2, minVersion); + row.Set(3, maxVersion); if (0 != attributes) { - row[4] = attributes; + row.Set(4, attributes); } // Create the relationship between this WixDependency row and the WixDependencyProvider row. if (!String.IsNullOrEmpty(providerId)) { // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. - row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyRef"); - row[0] = providerId; - row[1] = id.Id; + row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyRef"); + row.Set(0, providerId); + row.Set(1, id.Id); } } } @@ -553,9 +550,9 @@ namespace WixToolset.Extensions /// The XML node for the RequiresRef element. /// The parent provider identifier. /// Whether the Requires custom action should be referenced. - private void ParseRequiresRefElement(XElement node, string providerId, bool requiresAction) + private void ParseRequiresRefElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string id = null; foreach (XAttribute attrib in node.Attributes()) @@ -565,50 +562,50 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(node, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); } } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); if (String.IsNullOrEmpty(id)) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { // Reference the Require custom action if required. if (requiresAction) { - if (Platform.ARM == this.Core.CurrentPlatform) + if (Platform.ARM == this.Context.Platform) { // Ensure the ARM version of the CA is referenced. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); } else { // All other supported platforms use x86. - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire"); } } // Create a link dependency on the row that contains information we'll need during bind. - this.Core.CreateSimpleReference(sourceLineNumbers, "WixDependency", id); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixDependency", id); // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. - Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyRef"); - row[0] = providerId; - row[1] = id; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyRef"); + row.Set(0, providerId); + row.Set(1, id); } } } diff --git a/src/wixext/DependencyDecompiler.cs b/src/wixext/DependencyDecompiler.cs index 3013cf7c..31de3097 100644 --- a/src/wixext/DependencyDecompiler.cs +++ b/src/wixext/DependencyDecompiler.cs @@ -1,7 +1,8 @@ // 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.Extensions +namespace WixToolset.Dependency { +#if TODO_CONSIDER_DECOMPILER using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -342,4 +343,5 @@ namespace WixToolset.Extensions } } } +#endif } diff --git a/src/wixext/DependencyErrors.cs b/src/wixext/DependencyErrors.cs new file mode 100644 index 00000000..83c0986a --- /dev/null +++ b/src/wixext/DependencyErrors.cs @@ -0,0 +1,37 @@ +// 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.Dependency +{ + using System; + using System.Resources; + using WixToolset.Data; + + public static class DependencyErrors + { + public static Message IllegalCharactersInProvider(SourceLineNumber sourceLineNumbers, string attributeName, Char illegalChar, string illegalChars) + { + return Message(sourceLineNumbers, Ids.IllegalCharactersInProvider, "The provider key authored into the {0} attribute contains an illegal character, '{1}'. Please author the provider key without any of the following characters: {2}", attributeName, illegalChar, illegalChars); + } + + public static Message ReservedValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string attributeValue) + { + return Message(sourceLineNumbers, Ids.ReservedValue, "The {0}/@{1} attribute value '{2}' is reserved and cannot be used here. Please choose a different value.", elementName, attributeName, attributeValue); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + IllegalCharactersInProvider = 5400, + ReservedValue = 5401, + } + } +} diff --git a/src/wixext/DependencyExtension.csproj b/src/wixext/DependencyExtension.csproj deleted file mode 100644 index 050e8662..00000000 --- a/src/wixext/DependencyExtension.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - {A0B6D3F1-AE5E-423B-BA92-60C9926CA498} - WixDependencyExtension - Library - WixToolset.Extensions - - - - - - - - - - $(RootNamespace).Data.tables.xml - PreserveNewest - - - $(RootNamespace).Data.Messages.resources - - - $(RootNamespace).Xsd.Dependency.xsd - PreserveNewest - - - WixToolset.Data.Serialize - WixToolset.Extensions.Serialize.Dependency - - - Data\Dependency.wixlib - - - - - - - - - - - false - - - - diff --git a/src/wixext/DependencyExtensionData.cs b/src/wixext/DependencyExtensionData.cs index da2215ce..e92aeff1 100644 --- a/src/wixext/DependencyExtensionData.cs +++ b/src/wixext/DependencyExtensionData.cs @@ -1,64 +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.Extensions +namespace WixToolset.Dependency { - using System; - using System.Reflection; using WixToolset.Data; using WixToolset.Extensibility; /// - /// The WiX toolset dependency extension. + /// The WiX Toolset Dependency Extension. /// - public sealed class DependencyExtensionData : ExtensionData + public sealed class DependencyExtensionData : BaseExtensionData { /// /// Gets the default culture. /// /// The default culture. - public override string DefaultCulture - { - get { return "en-us"; } - } - - /// - /// Gets the optional table definitions for this extension. - /// - /// The optional table definitions for this extension. - public override TableDefinitionCollection TableDefinitions - { - get - { - return DependencyExtensionData.GetExtensionTableDefinitions(); - } - } - - /// - /// Gets the library associated with this extension. - /// - /// The table definitions to use while loading the library. - /// The loaded library. - public override Library GetLibrary(TableDefinitionCollection tableDefinitions) - { - return DependencyExtensionData.GetExtensionLibrary(tableDefinitions); - } + public override string DefaultCulture => "en-US"; - /// - /// Internal mechanism to access the extension's table definitions. - /// - /// Extension's table definitions. - internal static TableDefinitionCollection GetExtensionTableDefinitions() + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); + tupleDefinition = DependencyTupleDefinitions.ByName(name); + return tupleDefinition != null; } - /// - /// Internal mechanism to access the extension's library. - /// - /// Extension's library. - internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) { - return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.Dependency.wixlib", tableDefinitions); + return Intermediate.Load(typeof(DependencyExtensionData).Assembly, "WixToolset.Dependency.dependency.wixlib", tupleDefinitions); } } } diff --git a/src/wixext/DependencyExtensionFactory.cs b/src/wixext/DependencyExtensionFactory.cs new file mode 100644 index 00000000..c5b89658 --- /dev/null +++ b/src/wixext/DependencyExtensionFactory.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.Dependency +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class DependencyExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(DependencyCompiler), + typeof(DependencyExtensionData), + typeof(DependencyWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/wixext/DependencyWarnings.cs b/src/wixext/DependencyWarnings.cs new file mode 100644 index 00000000..802edc22 --- /dev/null +++ b/src/wixext/DependencyWarnings.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.Dependency +{ + using System; + using System.Resources; + using WixToolset.Data; + + public static class DependencyWarnings + { + public static Message DiscouragedVersionAttribute(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.DiscouragedVersionAttribute, "The Provides/@Version attribute should not be specified in an MSI package. The ProductVersion will be used by default."); + } + + public static Message DiscouragedVersionAttribute(SourceLineNumber sourceLineNumbers, string id) + { + return Message(sourceLineNumbers, Ids.DiscouragedVersionAttribute, "The Provides/@Version attribute should not be specified for MSI package {0}. The ProductVersion will be used by default.", id); + } + + public static Message PropertyRemoved(string name) + { + return Message(null, Ids.PropertyRemoved, "The property {0} was authored in the package with a value and will be removed. The property should not be authored.", name); + } + + public static Message ProvidesKeyNotFound(SourceLineNumber sourceLineNumbers, string id) + { + return Message(sourceLineNumbers, Ids.ProvidesKeyNotFound, "The provider key with identifier {0} was not found in the WixDependencyProvider table. Related registry rows will not be removed from authoring.", id); + } + + public static Message RequiresKeyNotFound(SourceLineNumber sourceLineNumbers, string id) + { + return Message(sourceLineNumbers, Ids.RequiresKeyNotFound, "The dependency key with identifier {0} was not found in the WixDependency table. Related registry rows will not be removed from authoring.", id); + } + + public static Message Win64Component(SourceLineNumber sourceLineNumbers, string componentId) + { + return Message(sourceLineNumbers, Ids.Win64Component, "The Provides element should not be authored in the 64-bit component with identifier {0}. The dependency feature may not work if installing this package on 64-bit Windows operating systems prior to Windows 7 and Windows Server 2008 R2. Set the Component/@Win64 attribute to \"no\" to make sure the dependency feature works correctly on all supported operating systems.", componentId); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + ProvidesKeyNotFound = 5431, + RequiresKeyNotFound = 5432, + PropertyRemoved = 5433, + DiscouragedVersionAttribute = 5434, + Win64Component = 5435, + } + } +} diff --git a/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs b/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs new file mode 100644 index 00000000..485453a1 --- /dev/null +++ b/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs @@ -0,0 +1,181 @@ +// 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.Dependency +{ + using System.Linq; + using System.Xml; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class DependencyWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + private static readonly TableDefinition[] Tables = LoadTables(); + + protected override TableDefinition[] TableDefinitionsForTuples => Tables; + + private static TableDefinition[] LoadTables() + { + using (var resourceStream = typeof(DependencyWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Dependency.tables.xml")) + using (var reader = XmlReader.Create(resourceStream)) + { + var tables = TableDefinitionCollection.Load(reader); + return tables.ToArray(); + } + } + +#if TODO_TAG_BINDER_EXTENSION + private Output output; + + /// + /// Called after all output changes occur and right before the output is bound into its final format. + /// + public void Finish(Output output) + { + // Only process MSI packages. + if (OutputType.Product != output.Type) + { + return; + } + + this.output = output; + + Table wixDependencyTable = output.Tables["WixDependency"]; + Table wixDependencyProviderTable = output.Tables["WixDependencyProvider"]; + Table wixDependencyRefTable = output.Tables["WixDependencyRef"]; + + // Make sure there's something to do. + if (null != wixDependencyRefTable) + { + KeyedRowCollection wixDependencyRows = new KeyedRowCollection(wixDependencyTable); + KeyedRowCollection wixDependencyProviderRows = new KeyedRowCollection(wixDependencyProviderTable); + + // For each relationship, get the provides and requires rows to generate registry values. + foreach (Row wixDependencyRefRow in wixDependencyRefTable.Rows) + { + string providesId = (string)wixDependencyRefRow[0]; + string requiresId = (string)wixDependencyRefRow[1]; + + Row wixDependencyRow = null; + if (wixDependencyRows.Contains(requiresId)) + { + wixDependencyRow = wixDependencyRows[requiresId]; + } + + Row wixDependencyProviderRow = null; + if (wixDependencyProviderRows.Contains(providesId)) + { + wixDependencyProviderRow = wixDependencyProviderRows[providesId]; + } + + // If we found both rows, generate the registry values. + if (null != wixDependencyRow && null != wixDependencyProviderRow) + { + // Format the root registry key using the required provider key and the current provider key. + string requiresKey = (string)wixDependencyRow[1]; + string providesKey = (string)wixDependencyProviderRow[2]; + string keyRequires = String.Format(@"{0}{1}\{2}\{3}", DependencyCommon.RegistryRoot, requiresKey, DependencyCommon.RegistryDependents, providesKey); + + // Get the component ID from the provider. + string componentId = (string)wixDependencyProviderRow[1]; + + Row row = this.CreateRegistryRow(wixDependencyRow); + row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "(Default)"); + row[1] = -1; + row[2] = keyRequires; + row[3] = "*"; + row[4] = null; + row[5] = componentId; + + string minVersion = (string)wixDependencyRow[2]; + if (!String.IsNullOrEmpty(minVersion)) + { + row = this.CreateRegistryRow(wixDependencyRow); + row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MinVersion"); + row[1] = -1; + row[2] = keyRequires; + row[3] = "MinVersion"; + row[4] = minVersion; + row[5] = componentId; + } + + string maxVersion = (string)wixDependencyRow[3]; + if (!String.IsNullOrEmpty(minVersion)) + { + row = this.CreateRegistryRow(wixDependencyRow); + row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "MaxVersion"); + row[1] = -1; + row[2] = keyRequires; + row[3] = "MaxVersion"; + row[4] = maxVersion; + row[5] = componentId; + } + + if (null != wixDependencyRow[4]) + { + int attributes = (int)wixDependencyRow[4]; + + row = this.CreateRegistryRow(wixDependencyRow); + row[0] = this.Core.CreateIdentifier("reg", providesId, requiresId, "Attributes"); + row[1] = -1; + row[2] = keyRequires; + row[3] = "Attributes"; + row[4] = String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat)); + row[5] = componentId; + } + } + } + } + } + + /// + /// Creates a registry row using source information from the given . + /// + /// The from which the section and source line information are retrieved. + /// A new Registry row. + private Row CreateRegistryRow(Row referenceRow) + { + TableDefinition tableDefinition = this.Core.TableDefinitions["Registry"]; + + // Create the row from the main tables, which were populated during link anyway. + // We still associate the table with the dependency row's section to maintain servicing. + Table table = this.output.EnsureTable(tableDefinition, referenceRow.Table.Section); + Row row = table.CreateRow(referenceRow.SourceLineNumbers); + + // Set the section ID for patching and return the new row. + row.SectionId = referenceRow.SectionId; + return row; + } + + /// + /// A keyed collection of instances for O(1) lookup. + /// + private sealed class KeyedRowCollection : KeyedCollection + { + /// + /// Initializes the class with all rows from the specified . + /// + /// The containing rows to index. + internal KeyedRowCollection(Table table) + { + if (null != table) + { + foreach (Row row in table.Rows) + { + this.Add(row); + } + } + } + + /// + /// Gets the primary key for the . + /// + /// The to index. + /// The primary key for the . + protected override string GetKeyForItem(Row row) + { + return row.GetPrimaryKey('/'); + } + } +#endif + } +} diff --git a/src/wixext/Tuples/DependencyTupleDefinitions.cs b/src/wixext/Tuples/DependencyTupleDefinitions.cs new file mode 100644 index 00000000..fdd3f0b5 --- /dev/null +++ b/src/wixext/Tuples/DependencyTupleDefinitions.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.Dependency +{ + using System; + using WixToolset.Data; + + public enum DependencyTupleDefinitionType + { + WixDependency, + WixDependencyProvider, + WixDependencyRef, + } + + public static partial class DependencyTupleDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateTupleDefinition ByName(string name) + { + if (!Enum.TryParse(name, out DependencyTupleDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateTupleDefinition ByType(DependencyTupleDefinitionType type) + { + switch (type) + { + case DependencyTupleDefinitionType.WixDependency: + return DependencyTupleDefinitions.WixDependency; + + case DependencyTupleDefinitionType.WixDependencyProvider: + return DependencyTupleDefinitions.WixDependencyProvider; + + case DependencyTupleDefinitionType.WixDependencyRef: + return DependencyTupleDefinitions.WixDependencyRef; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/wixext/Tuples/WixDependencyProviderTuple.cs b/src/wixext/Tuples/WixDependencyProviderTuple.cs new file mode 100644 index 00000000..2fd6a805 --- /dev/null +++ b/src/wixext/Tuples/WixDependencyProviderTuple.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.Dependency +{ + using WixToolset.Data; + using WixToolset.Dependency.Tuples; + + public static partial class DependencyTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixDependencyProvider = new IntermediateTupleDefinition( + DependencyTupleDefinitionType.WixDependencyProvider.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.WixDependencyProvider), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.ProviderKey), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.Version), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.DisplayName), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyProviderTupleFields.Attributes), IntermediateFieldType.Number), + }, + typeof(WixDependencyProviderTuple)); + } +} + +namespace WixToolset.Dependency.Tuples +{ + using WixToolset.Data; + + public enum WixDependencyProviderTupleFields + { + WixDependencyProvider, + Component_, + ProviderKey, + Version, + DisplayName, + Attributes, + } + + public class WixDependencyProviderTuple : IntermediateTuple + { + public WixDependencyProviderTuple() : base(DependencyTupleDefinitions.WixDependencyProvider, null, null) + { + } + + public WixDependencyProviderTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DependencyTupleDefinitions.WixDependencyProvider, sourceLineNumber, id) + { + } + + public IntermediateField this[WixDependencyProviderTupleFields index] => this.Fields[(int)index]; + + public string WixDependencyProvider + { + get => this.Fields[(int)WixDependencyProviderTupleFields.WixDependencyProvider].AsString(); + set => this.Set((int)WixDependencyProviderTupleFields.WixDependencyProvider, value); + } + + public string Component_ + { + get => this.Fields[(int)WixDependencyProviderTupleFields.Component_].AsString(); + set => this.Set((int)WixDependencyProviderTupleFields.Component_, value); + } + + public string ProviderKey + { + get => this.Fields[(int)WixDependencyProviderTupleFields.ProviderKey].AsString(); + set => this.Set((int)WixDependencyProviderTupleFields.ProviderKey, value); + } + + public string Version + { + get => this.Fields[(int)WixDependencyProviderTupleFields.Version].AsString(); + set => this.Set((int)WixDependencyProviderTupleFields.Version, value); + } + + public string DisplayName + { + get => this.Fields[(int)WixDependencyProviderTupleFields.DisplayName].AsString(); + set => this.Set((int)WixDependencyProviderTupleFields.DisplayName, value); + } + + public int Attributes + { + get => this.Fields[(int)WixDependencyProviderTupleFields.Attributes].AsNumber(); + set => this.Set((int)WixDependencyProviderTupleFields.Attributes, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixDependencyRefTuple.cs b/src/wixext/Tuples/WixDependencyRefTuple.cs new file mode 100644 index 00000000..3e996f5f --- /dev/null +++ b/src/wixext/Tuples/WixDependencyRefTuple.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.Dependency +{ + using WixToolset.Data; + using WixToolset.Dependency.Tuples; + + public static partial class DependencyTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixDependencyRef = new IntermediateTupleDefinition( + DependencyTupleDefinitionType.WixDependencyRef.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependencyProvider_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyRefTupleFields.WixDependency_), IntermediateFieldType.String), + }, + typeof(WixDependencyRefTuple)); + } +} + +namespace WixToolset.Dependency.Tuples +{ + using WixToolset.Data; + + public enum WixDependencyRefTupleFields + { + WixDependencyProvider_, + WixDependency_, + } + + public class WixDependencyRefTuple : IntermediateTuple + { + public WixDependencyRefTuple() : base(DependencyTupleDefinitions.WixDependencyRef, null, null) + { + } + + public WixDependencyRefTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DependencyTupleDefinitions.WixDependencyRef, sourceLineNumber, id) + { + } + + public IntermediateField this[WixDependencyRefTupleFields index] => this.Fields[(int)index]; + + public string WixDependencyProvider_ + { + get => this.Fields[(int)WixDependencyRefTupleFields.WixDependencyProvider_].AsString(); + set => this.Set((int)WixDependencyRefTupleFields.WixDependencyProvider_, value); + } + + public string WixDependency_ + { + get => this.Fields[(int)WixDependencyRefTupleFields.WixDependency_].AsString(); + set => this.Set((int)WixDependencyRefTupleFields.WixDependency_, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/WixDependencyTuple.cs b/src/wixext/Tuples/WixDependencyTuple.cs new file mode 100644 index 00000000..81e05ad1 --- /dev/null +++ b/src/wixext/Tuples/WixDependencyTuple.cs @@ -0,0 +1,79 @@ +// 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.Dependency +{ + using WixToolset.Data; + using WixToolset.Dependency.Tuples; + + public static partial class DependencyTupleDefinitions + { + public static readonly IntermediateTupleDefinition WixDependency = new IntermediateTupleDefinition( + DependencyTupleDefinitionType.WixDependency.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.WixDependency), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.ProviderKey), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.MinVersion), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.MaxVersion), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(WixDependencyTupleFields.Attributes), IntermediateFieldType.Number), + }, + typeof(WixDependencyTuple)); + } +} + +namespace WixToolset.Dependency.Tuples +{ + using WixToolset.Data; + + public enum WixDependencyTupleFields + { + WixDependency, + ProviderKey, + MinVersion, + MaxVersion, + Attributes, + } + + public class WixDependencyTuple : IntermediateTuple + { + public WixDependencyTuple() : base(DependencyTupleDefinitions.WixDependency, null, null) + { + } + + public WixDependencyTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DependencyTupleDefinitions.WixDependency, sourceLineNumber, id) + { + } + + public IntermediateField this[WixDependencyTupleFields index] => this.Fields[(int)index]; + + public string WixDependency + { + get => this.Fields[(int)WixDependencyTupleFields.WixDependency].AsString(); + set => this.Set((int)WixDependencyTupleFields.WixDependency, value); + } + + public string ProviderKey + { + get => this.Fields[(int)WixDependencyTupleFields.ProviderKey].AsString(); + set => this.Set((int)WixDependencyTupleFields.ProviderKey, value); + } + + public string MinVersion + { + get => this.Fields[(int)WixDependencyTupleFields.MinVersion].AsString(); + set => this.Set((int)WixDependencyTupleFields.MinVersion, value); + } + + public string MaxVersion + { + get => this.Fields[(int)WixDependencyTupleFields.MaxVersion].AsString(); + set => this.Set((int)WixDependencyTupleFields.MaxVersion, value); + } + + public int Attributes + { + get => this.Fields[(int)WixDependencyTupleFields.Attributes].AsNumber(); + set => this.Set((int)WixDependencyTupleFields.Attributes, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/WixToolset.Dependency.wixext.csproj b/src/wixext/WixToolset.Dependency.wixext.csproj new file mode 100644 index 00000000..7e9f1e3a --- /dev/null +++ b/src/wixext/WixToolset.Dependency.wixext.csproj @@ -0,0 +1,33 @@ + + + + + + netstandard2.0 + WixToolset.Dependency + WiX Toolset Dependency Extension + WiX Toolset Dependency Extension + true + build + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.Dependency.wixext.targets b/src/wixext/WixToolset.Dependency.wixext.targets new file mode 100644 index 00000000..494c0184 --- /dev/null +++ b/src/wixext/WixToolset.Dependency.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Depedency.wixext.dll + + + + + diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml deleted file mode 100644 index bd6eb602..00000000 --- a/src/wixext/messages.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - The provider key authored into the {0} attribute contains an illegal character, '{1}'. Please author the provider key without any of the following characters: {2} - - - - - - - - The {0}/@{1} attribute value '{2}' is reserved and cannot be used here. Please choose a different value. - - - - - - - - - - The provider key with identifier {0} was not found in the WixDependencyProvider table. Related registry rows will not be removed from authoring. - - - - - - The dependency key with identifier {0} was not found in the WixDependency table. Related registry rows will not be removed from authoring. - - - - - - The property {0} was authored in the package with a value and will be removed. The property should not be authored. - - - - - - The Provides/@Version attribute should not be specified in an MSI package. The ProductVersion will be used by default. - - - The Provides/@Version attribute should not be specified for MSI package {0}. The ProductVersion will be used by default. - - - - - - The Provides element should not be authored in the 64-bit component with identifier {0}. The dependency feature may not work if installing this package on 64-bit Windows operating systems prior to Windows 7 and Windows Server 2008 R2. Set the Component/@Win64 attribute to "no" to make sure the dependency feature works correctly on all supported operating systems. - - - - - - diff --git a/src/wixlib/DependencyExtension.wixproj b/src/wixlib/DependencyExtension.wixproj deleted file mode 100644 index e52218ed..00000000 --- a/src/wixlib/DependencyExtension.wixproj +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - {58ED0EC8-73F8-4EE1-8664-A53486D38EC8} - dependency - Library - true - true - 1086 - en-us - - - - - - - - - - - - - - diff --git a/src/wixlib/DependencyExtension_Platform.wxi b/src/wixlib/DependencyExtension_Platform.wxi index d06b0055..7cd7ad96 100644 --- a/src/wixlib/DependencyExtension_Platform.wxi +++ b/src/wixlib/DependencyExtension_Platform.wxi @@ -5,7 +5,7 @@ - + @@ -13,7 +13,7 @@ - + @@ -21,6 +21,6 @@ - + diff --git a/src/wixlib/caSuffix.wxi b/src/wixlib/caSuffix.wxi new file mode 100644 index 00000000..a56a2393 --- /dev/null +++ b/src/wixlib/caSuffix.wxi @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi new file mode 100644 index 00000000..141942f2 --- /dev/null +++ b/src/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/wixlib/dependency.wixproj b/src/wixlib/dependency.wixproj new file mode 100644 index 00000000..6fa70e3d --- /dev/null +++ b/src/wixlib/dependency.wixproj @@ -0,0 +1,43 @@ + + + + + + + {58ED0EC8-73F8-4EE1-8664-A53486D38EC8} + dependency + Library + true + true + 1086 + en-us + + + + + + + + + + + + + dependencyca + {B86AF46C-0F90-49CC-923F-A800B088D015} + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config new file mode 100644 index 00000000..f3d424e1 --- /dev/null +++ b/src/wixlib/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file -- cgit v1.2.3-55-g6feb