diff --git a/global.json b/global.json index 77a8132..8b25293 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0170" + "WixToolset.Sdk": "4.0.0-build-0191" } } diff --git a/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs b/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs index 0f72953..968b8de 100644 --- a/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs +++ b/src/test/WixToolsetTest.Dependency/DependencyExtensionFixture.cs @@ -15,9 +15,10 @@ public void CanBuildUsingProvides() var folder = TestData.Get(@"TestData\UsingProvides"); var build = new Builder(folder, typeof(DependencyExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(Build, "WixDependencyProvider"); + var results = build.BuildAndQuery(Build, "CustomAction", "WixDependencyProvider"); Assert.Equal(new[] { + "CustomAction:Wix4DependencyCheck_X86\t1\tDependencyCA_X86\tWixDependencyCheck\t", "WixDependencyProvider:dep74OfIcniaqxA7EprRGBw4Oyy3r8\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tUsingProvides\t\t\t", }, results); } diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs index 44820bd..b15ae8d 100644 --- a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs +++ b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/Package.wxs @@ -1,21 +1,16 @@ - + - - - + + - + + + + - - - - - - - - - + diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs deleted file mode 100644 index e241fb1..0000000 --- a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/PackageComponents.wxs +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt b/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt deleted file mode 100644 index 1b4ffe8..0000000 --- a/src/test/WixToolsetTest.Dependency/TestData/UsingProvides/example.txt +++ /dev/null @@ -1 +0,0 @@ -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 index 7bedc47..2d3e40c 100644 --- a/src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj +++ b/src/test/WixToolsetTest.Dependency/WixToolsetTest.Dependency.csproj @@ -12,10 +12,7 @@ - - - - + diff --git a/src/wixext/DependencyCommon.cs b/src/wixext/DependencyCommon.cs deleted file mode 100644 index cb36be3..0000000 --- a/src/wixext/DependencyCommon.cs +++ /dev/null @@ -1,26 +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.Dependency -{ - using System; - using WixToolset; - - internal static class DependencyCommon - { - // Bundle attributes are in the upper 32-bits. - internal const int ProvidesAttributesBundle = 0x10000; - - // Same values as for the Upgrade table in Windows Installer. - internal const int RequiresAttributesMinVersionInclusive = 256; - internal const int RequiresAttributesMaxVersionInclusive = 512; - - // The root registry key for the dependency extension. We write to Software\Classes explicitly - // based on the current security context instead of HKCR. See - // http://msdn.microsoft.com/en-us/library/ms724475(VS.85).aspx for more information. - internal static readonly string RegistryRoot = @"Software\Classes\Installer\Dependencies\"; - internal static readonly string RegistryDependents = "Dependents"; - - // The following characters cannot be used in a provider key. - internal static readonly char[] InvalidCharacters = new char[] { ' ', '\"', ';', '\\' }; - } -} diff --git a/src/wixext/DependencyCompiler.cs b/src/wixext/DependencyCompiler.cs index 18bb89d..0405c32 100644 --- a/src/wixext/DependencyCompiler.cs +++ b/src/wixext/DependencyCompiler.cs @@ -2,13 +2,9 @@ namespace WixToolset.Dependency { - using System; using System.Collections.Generic; - using System.Text; using System.Xml.Linq; using WixToolset.Data; - using WixToolset.Data.Symbols; - using WixToolset.Dependency.Symbols; using WixToolset.Extensibility; using WixToolset.Extensibility.Data; @@ -17,18 +13,6 @@ namespace WixToolset.Dependency /// public sealed class DependencyCompiler : BaseCompilerExtension { - /// - /// Package type when parsing the Provides element. - /// - private enum PackageType - { - None, - ExePackage, - MsiPackage, - MspPackage, - MsuPackage - } - public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/dependency"; /// @@ -40,534 +24,38 @@ private enum PackageType public override void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); - switch (parentElement.Name.LocalName) - { - case "Bundle": - switch (attribute.Name.LocalName) - { - case "ProviderKey": - this.ParseProviderKeyAttribute(section, sourceLineNumbers, parentElement, attribute); - break; - default: - this.ParseHelper.UnexpectedAttribute(parentElement, attribute); - break; - } - break; - default: - this.ParseHelper.UnexpectedAttribute(parentElement, attribute); - break; - } - } - - /// - /// Processes an element for the Compiler. - /// - /// Source line number for the parent element. - /// 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(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - var packageType = PackageType.None; + var addCheck = YesNoType.NotSet; + var addRequire = YesNoType.NotSet; switch (parentElement.Name.LocalName) { - case "Bundle": - case "Fragment": - case "Module": - case "Package": - switch (element.Name.LocalName) + case "Provides": + if (attribute.Name.LocalName == "Check" && parentElement.Parent.Name.LocalName == "Component") { - case "Requires": - this.ParseRequiresElement(intermediate, section, element, null, false); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; + addCheck = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute); } break; - case "ExePackage": - packageType = PackageType.ExePackage; - break; - case "MsiPackage": - packageType = PackageType.MsiPackage; - break; - case "MspPackage": - packageType = PackageType.MspPackage; - break; - case "MsuPackage": - packageType = PackageType.MsuPackage; - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - - if (PackageType.None != packageType) - { - var packageId = context["PackageId"]; - - switch (element.Name.LocalName) - { - case "Provides": - this.ParseProvidesElement(intermediate, section, element, packageType, packageId); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - } - } - - /// - /// Processes a child element of a Component for the Compiler. - /// - /// Parent element of element to process. - /// Element to process. - /// Extra information about the context in which this element is being parsed. - /// The component key path type if set. - public override IComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); - IComponentKeyPath keyPath = null; - - switch (parentElement.Name.LocalName) - { - case "Component": - var componentId = context["ComponentId"]; - - // 64-bit components may cause issues downlevel. - Boolean.TryParse(context["Win64"], out var win64); - - switch (element.Name.LocalName) + case "Requires": + case "RequiresRef": + if (attribute.Name.LocalName == "Enforce" && parentElement.Parent.Name.LocalName == "Component") { - case "Provides": - if (win64) - { - this.Messaging.Write(DependencyWarnings.Win64Component(sourceLineNumbers, componentId)); - } - - keyPath = this.ParseProvidesElement(intermediate, section, element, PackageType.None, componentId); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; + addRequire = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attribute); } break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - - return keyPath; - } - - /// - /// Processes the ProviderKey bundle attribute. - /// - /// Source line number for the parent element. - /// Parent element of attribute. - /// The XML attribute for the ProviderKey attribute. - private void ParseProviderKeyAttribute(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement parentElement, XAttribute attribute) - { - Identifier id = null; - string providerKey = null; - int illegalChar = -1; - - switch (attribute.Name.LocalName) - { - case "ProviderKey": - providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); - break; - default: - this.ParseHelper.UnexpectedAttribute(parentElement, attribute); - break; - } - - // Make sure the key does not contain any illegal characters or values. - if (String.IsNullOrEmpty(providerKey)) - { - this.Messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, parentElement.Name.LocalName, attribute.Name.LocalName)); } - else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) - { - var sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); - Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); - } - else if ("ALL" == providerKey) + if (addCheck == YesNoType.NotSet && addRequire == YesNoType.NotSet) { - this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, parentElement.Name.LocalName, "ProviderKey", providerKey)); + this.ParseHelper.UnexpectedAttribute(parentElement, attribute); } - - // Generate the primary key for the row. - id = this.ParseHelper.CreateIdentifier("dep", attribute.Name.LocalName, providerKey); - - if (!this.Messaging.EncounteredError) + else if (addCheck == YesNoType.Yes) { - // Create the provider symbol for the bundle. The Component_ field is required - // in the table definition but unused for bundles, so just set it to the valid ID. - section.AddSymbol(new WixDependencyProviderSymbol(sourceLineNumbers, id) - { - ComponentRef = id.Id, - ProviderKey = providerKey, - Attributes = WixDependencyProviderAttributes.ProvidesAttributesBundle, - }); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4DependencyCheck", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } - } - - /// - /// Processes the Provides element. - /// - /// The XML node for the Provides element. - /// The type of the package being chained into a bundle, or "None" if building an MSI package. - /// Explicit key path. - /// The identifier of the parent component or package. - /// The type of key path if set. - private IComponentKeyPath ParseProvidesElement(Intermediate intermediate, IntermediateSection section, XElement node, PackageType packageType, string parentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - IComponentKeyPath keyPath = null; - Identifier id = null; - string key = null; - string version = null; - string displayName = null; - int illegalChar = -1; - - foreach (var attrib in node.Attributes()) + else if (addRequire == YesNoType.Yes) { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Key": - key = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Version": - version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4DependencyRequire", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } - - // Make sure the key is valid. The key will default to the ProductCode for MSI packages - // and the package code for MSP packages in the binder if not specified. - if (!String.IsNullOrEmpty(key)) - { - // Make sure the key does not contain any illegal characters or values. - if (0 <= (illegalChar = key.IndexOfAny(DependencyCommon.InvalidCharacters))) - { - var sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); - Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - - this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); - } - else if ("ALL" == 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.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.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Property, "ProductCode"); - key = "!(bind.property.ProductCode)"; - } - - // The Version attribute should not be authored in or for an MSI package. - if (!String.IsNullOrEmpty(version)) - { - switch (packageType) - { - case PackageType.None: - this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); - break; - case PackageType.MsiPackage: - 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.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.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, parentId, key); - } - - foreach (var child in node.Elements()) - { - if (this.Namespace == child.Name.Namespace) - { - switch (child.Name.LocalName) - { - case "Requires": - this.ParseRequiresElement(intermediate, section, child, id.Id, PackageType.None == packageType); - break; - case "RequiresRef": - this.ParseRequiresRefElement(intermediate, section, child, id.Id, PackageType.None == packageType); - break; - default: - this.ParseHelper.UnexpectedElement(node, child); - break; - } - } - else - { - this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); - } - } - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new WixDependencyProviderSymbol(sourceLineNumbers, id) - { - ComponentRef = parentId, - ProviderKey = key, - }); - - if (!String.IsNullOrEmpty(version)) - { - symbol.Version = version; - } - - if (!String.IsNullOrEmpty(displayName)) - { - symbol.DisplayName = displayName; - } - - if (PackageType.None == packageType) - { - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "DependencyCheck", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - - // Generate registry rows for the provider using binder properties. - var keyProvides = String.Concat(DependencyCommon.RegistryRoot, key); - var root = RegistryRootType.MachineUser; - - var value = "[ProductCode]"; - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, null, value, parentId, false); - - value = !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"; - var versionRegistrySymbol = - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, "Version", value, parentId, false); - - value = !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"; - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, root, keyProvides, "DisplayName", value, parentId, false); - - // Use the Version registry value and use that as a potential key path. - keyPath = this.CreateComponentKeyPath(); - keyPath.Id = versionRegistrySymbol.Id; - keyPath.Explicit = false; - keyPath.Type = PossibleKeyPathType.Registry; - } - } - - return keyPath; - } - - /// - /// Processes the Requires element. - /// - /// The XML node for the Requires element. - /// The parent provider identifier. - /// Whether the Requires custom action should be referenced. - private void ParseRequiresElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - Identifier id = null; - string providerKey = null; - string minVersion = null; - string maxVersion = null; - int attributes = 0; - int illegalChar = -1; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ProviderKey": - providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Minimum": - minVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "Maximum": - maxVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "IncludeMinimum": - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DependencyCommon.RequiresAttributesMinVersionInclusive; - } - break; - case "IncludeMaximum": - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DependencyCommon.RequiresAttributesMaxVersionInclusive; - } - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - - if (null == id) - { - // Generate an ID only if this element is authored under a Provides element; otherwise, a RequiresRef - // element will be necessary and the Id attribute will be required. - if (!String.IsNullOrEmpty(providerId)) - { - id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, providerKey); - } - else - { - this.Messaging.Write(ErrorMessages.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); - id = Identifier.Invalid; - } - } - - if (String.IsNullOrEmpty(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))) - { - var sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); - Array.ForEach(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); - - this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); - } - - if (!this.Messaging.EncounteredError) - { - // Reference the Require custom action if required. - if (requiresAction) - { - this.AddReferenceToWixDependencyRequire(section, sourceLineNumbers); - } - - var symbol = section.AddSymbol(new WixDependencySymbol(sourceLineNumbers, id) - { - ProviderKey = providerKey, - MinVersion = minVersion, - MaxVersion = maxVersion, - }); - - if (0 != attributes) - { - symbol.Attributes = attributes; - } - - // Create the relationship between this WixDependency symbol and the WixDependencyProvider symbol. - if (!String.IsNullOrEmpty(providerId)) - { - section.AddSymbol(new WixDependencyRefSymbol(sourceLineNumbers) - { - WixDependencyProviderRef = providerId, - WixDependencyRef = id.Id, - }); - } - } - } - - /// - /// Processes the RequiresRef element. - /// - /// The XML node for the RequiresRef element. - /// The parent provider identifier. - /// Whether the Requires custom action should be referenced. - private void ParseRequiresRefElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - string id = null; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - - if (String.IsNullOrEmpty(id)) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); - } - - if (!this.Messaging.EncounteredError) - { - // Reference the Require custom action if required. - if (requiresAction) - { - this.AddReferenceToWixDependencyRequire(section, sourceLineNumbers); - } - - // Create a link dependency on the row that contains information we'll need during bind. - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, DependencySymbolDefinitions.WixDependency, id); - - // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. - section.AddSymbol(new WixDependencyRefSymbol(sourceLineNumbers) - { - WixDependencyProviderRef = providerId, - WixDependencyRef = id, - }); - } - } - - private void AddReferenceToWixDependencyRequire(IntermediateSection section, SourceLineNumber sourceLineNumbers) - { - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "DependencyRequire", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } } } diff --git a/src/wixext/DependencyErrors.cs b/src/wixext/DependencyErrors.cs deleted file mode 100644 index 83c0986..0000000 --- a/src/wixext/DependencyErrors.cs +++ /dev/null @@ -1,37 +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.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/DependencyExtensionData.cs b/src/wixext/DependencyExtensionData.cs index e7d8746..2f30c2b 100644 --- a/src/wixext/DependencyExtensionData.cs +++ b/src/wixext/DependencyExtensionData.cs @@ -16,12 +16,11 @@ public sealed class DependencyExtensionData : BaseExtensionData /// The default culture. public override string DefaultCulture => "en-US"; - public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = DependencySymbolDefinitions.ByName(name); - return symbolDefinition != null; - } - + /// + /// Gets the contained .wixlib content. + /// + /// Strong typed symbold definitions. + /// The .wixlib. public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) { return Intermediate.Load(typeof(DependencyExtensionData).Assembly, "WixToolset.Dependency.dependency.wixlib", symbolDefinitions); diff --git a/src/wixext/DependencyExtensionFactory.cs b/src/wixext/DependencyExtensionFactory.cs index c5b8965..354f923 100644 --- a/src/wixext/DependencyExtensionFactory.cs +++ b/src/wixext/DependencyExtensionFactory.cs @@ -12,7 +12,6 @@ public class DependencyExtensionFactory : BaseExtensionFactory { typeof(DependencyCompiler), typeof(DependencyExtensionData), - typeof(DependencyWindowsInstallerBackendBinderExtension), }; } } diff --git a/src/wixext/DependencyTableDefinitions.cs b/src/wixext/DependencyTableDefinitions.cs deleted file mode 100644 index d3f643e..0000000 --- a/src/wixext/DependencyTableDefinitions.cs +++ /dev/null @@ -1,57 +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.Dependency -{ - using WixToolset.Data; - using WixToolset.Data.WindowsInstaller; - - public static class DependencyTableDefinitions - { - public static readonly TableDefinition WixDependencyProvider = new TableDefinition( - "WixDependencyProvider", - SymbolDefinitions.WixDependencyProvider, - new[] - { - new ColumnDefinition("WixDependencyProvider", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "The foreign key into the Component table used to determine install state.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("ProviderKey", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The name of the registry key that holds the provider identity."), - new ColumnDefinition("Version", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The version of the package."), - new ColumnDefinition("DisplayName", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Text, description: "The display name of the package."), - new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 2147483647, description: "A 32-bit word that specifies the attribute flags to be applied."), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition WixDependency = new TableDefinition( - "WixDependency", - DependencySymbolDefinitions.WixDependency, - new[] - { - new ColumnDefinition("WixDependency", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "The non-localized primary key for the table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("ProviderKey", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The name of the registry key that holds the provider identity."), - new ColumnDefinition("MinVersion", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The minimum version of the provider supported."), - new ColumnDefinition("MaxVersion", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Version, description: "The maximum version of the provider supported."), - new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 2147483647, description: "A 32-bit word that specifies the attribute flags to be applied."), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition WixDependencyRef = new TableDefinition( - "WixDependencyRef", - DependencySymbolDefinitions.WixDependencyRef, - new[] - { - new ColumnDefinition("WixDependencyProvider_", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "WixDependencyProvider", keyColumn: 1, description: "Foreign key into the Component table.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("WixDependency_", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, keyTable: "WixDependency", keyColumn: 1, description: "Foreign key into the WixDependency table.", modularizeType: ColumnModularizeType.Column), - }, - symbolIdIsPrimaryKey: false - ); - - public static readonly TableDefinition[] All = new[] - { - WixDependencyProvider, - WixDependency, - WixDependencyRef, - }; - } -} diff --git a/src/wixext/DependencyWarnings.cs b/src/wixext/DependencyWarnings.cs deleted file mode 100644 index 802edc2..0000000 --- a/src/wixext/DependencyWarnings.cs +++ /dev/null @@ -1,60 +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.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 deleted file mode 100644 index f52f97f..0000000 --- a/src/wixext/DependencyWindowsInstallerBackendBinderExtension.cs +++ /dev/null @@ -1,168 +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.Dependency -{ - using System.Collections.Generic; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility; - - public class DependencyWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension - { - public override IEnumerable TableDefinitions => DependencyTableDefinitions.All; - -#if TODO_DEPENDENCY_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/Symbols/DependencySymbolDefinitions.cs b/src/wixext/Symbols/DependencySymbolDefinitions.cs deleted file mode 100644 index 5a18ae4..0000000 --- a/src/wixext/Symbols/DependencySymbolDefinitions.cs +++ /dev/null @@ -1,43 +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.Dependency -{ - using System; - using WixToolset.Data; - - public enum DependencySymbolDefinitionType - { - WixDependency, - WixDependencyRef, - } - - public static partial class DependencySymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out DependencySymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(DependencySymbolDefinitionType type) - { - switch (type) - { - case DependencySymbolDefinitionType.WixDependency: - return DependencySymbolDefinitions.WixDependency; - - case DependencySymbolDefinitionType.WixDependencyRef: - return DependencySymbolDefinitions.WixDependencyRef; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/wixext/Symbols/WixDependencyRefSymbol.cs b/src/wixext/Symbols/WixDependencyRefSymbol.cs deleted file mode 100644 index 6f2aaad..0000000 --- a/src/wixext/Symbols/WixDependencyRefSymbol.cs +++ /dev/null @@ -1,55 +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.Dependency -{ - using WixToolset.Data; - using WixToolset.Dependency.Symbols; - - public static partial class DependencySymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixDependencyRef = new IntermediateSymbolDefinition( - DependencySymbolDefinitionType.WixDependencyRef.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixDependencyRefSymbolFields.WixDependencyProviderRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixDependencyRefSymbolFields.WixDependencyRef), IntermediateFieldType.String), - }, - typeof(WixDependencyRefSymbol)); - } -} - -namespace WixToolset.Dependency.Symbols -{ - using WixToolset.Data; - - public enum WixDependencyRefSymbolFields - { - WixDependencyProviderRef, - WixDependencyRef, - } - - public class WixDependencyRefSymbol : IntermediateSymbol - { - public WixDependencyRefSymbol() : base(DependencySymbolDefinitions.WixDependencyRef, null, null) - { - } - - public WixDependencyRefSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DependencySymbolDefinitions.WixDependencyRef, sourceLineNumber, id) - { - } - - public IntermediateField this[WixDependencyRefSymbolFields index] => this.Fields[(int)index]; - - public string WixDependencyProviderRef - { - get => this.Fields[(int)WixDependencyRefSymbolFields.WixDependencyProviderRef].AsString(); - set => this.Set((int)WixDependencyRefSymbolFields.WixDependencyProviderRef, value); - } - - public string WixDependencyRef - { - get => this.Fields[(int)WixDependencyRefSymbolFields.WixDependencyRef].AsString(); - set => this.Set((int)WixDependencyRefSymbolFields.WixDependencyRef, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/WixDependencySymbol.cs b/src/wixext/Symbols/WixDependencySymbol.cs deleted file mode 100644 index 17c631c..0000000 --- a/src/wixext/Symbols/WixDependencySymbol.cs +++ /dev/null @@ -1,71 +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.Dependency -{ - using WixToolset.Data; - using WixToolset.Dependency.Symbols; - - public static partial class DependencySymbolDefinitions - { - public static readonly IntermediateSymbolDefinition WixDependency = new IntermediateSymbolDefinition( - DependencySymbolDefinitionType.WixDependency.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(WixDependencySymbolFields.ProviderKey), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixDependencySymbolFields.MinVersion), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixDependencySymbolFields.MaxVersion), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(WixDependencySymbolFields.Attributes), IntermediateFieldType.Number), - }, - typeof(WixDependencySymbol)); - } -} - -namespace WixToolset.Dependency.Symbols -{ - using WixToolset.Data; - - public enum WixDependencySymbolFields - { - ProviderKey, - MinVersion, - MaxVersion, - Attributes, - } - - public class WixDependencySymbol : IntermediateSymbol - { - public WixDependencySymbol() : base(DependencySymbolDefinitions.WixDependency, null, null) - { - } - - public WixDependencySymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(DependencySymbolDefinitions.WixDependency, sourceLineNumber, id) - { - } - - public IntermediateField this[WixDependencySymbolFields index] => this.Fields[(int)index]; - - public string ProviderKey - { - get => this.Fields[(int)WixDependencySymbolFields.ProviderKey].AsString(); - set => this.Set((int)WixDependencySymbolFields.ProviderKey, value); - } - - public string MinVersion - { - get => this.Fields[(int)WixDependencySymbolFields.MinVersion].AsString(); - set => this.Set((int)WixDependencySymbolFields.MinVersion, value); - } - - public string MaxVersion - { - get => this.Fields[(int)WixDependencySymbolFields.MaxVersion].AsString(); - set => this.Set((int)WixDependencySymbolFields.MaxVersion, value); - } - - public int Attributes - { - get => this.Fields[(int)WixDependencySymbolFields.Attributes].AsNumber(); - set => this.Set((int)WixDependencySymbolFields.Attributes, value); - } - } -} \ No newline at end of file