From dcfc3e2e369958d58dc070e3dbb8992e147b7a05 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 19 Jan 2019 12:11:35 -0600 Subject: Import code from old v4 repo --- src/wixext/PSCompiler.cs | 290 +++++++++++++++++++++++++++++++++++++++ src/wixext/PSExtensionData.cs | 34 +++++ src/wixext/WixPSExtension.csproj | 43 ++++++ src/wixext/messages.xml | 20 +++ src/wixext/ps.xsd | 191 ++++++++++++++++++++++++++ src/wixlib/PSExtension.wixproj | 19 +++ src/wixlib/PSExtension.wxs | 12 ++ 7 files changed, 609 insertions(+) create mode 100644 src/wixext/PSCompiler.cs create mode 100644 src/wixext/PSExtensionData.cs create mode 100644 src/wixext/WixPSExtension.csproj create mode 100644 src/wixext/messages.xml create mode 100644 src/wixext/ps.xsd create mode 100644 src/wixlib/PSExtension.wixproj create mode 100644 src/wixlib/PSExtension.wxs (limited to 'src') diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs new file mode 100644 index 00000000..61eb287c --- /dev/null +++ b/src/wixext/PSCompiler.cs @@ -0,0 +1,290 @@ +// 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.Generic; + using System.Globalization; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Data.Rows; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset Internet Information Services Extension. + /// + public sealed class PSCompiler : CompilerExtension + { + private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; + private const string VarPrefix = "PSVersionMajor"; + + /// + /// Instantiate a new PSCompiler. + /// + public PSCompiler() + { + this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/powershell"; + } + + /// + /// 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(XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "File": + string fileId = context["FileId"]; + string componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FormatsFile": + this.ParseExtensionsFile(element, "Formats", fileId, componentId); + break; + + case "SnapIn": + this.ParseSnapInElement(element, fileId, componentId); + break; + + case "TypesFile": + this.ParseExtensionsFile(element, "Types", fileId, componentId); + break; + + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a SnapIn element. + /// + /// Element to parse. + /// Identifier for parent file. + /// Identifier for parent component. + private void ParseSnapInElement(XElement node, string fileId, string componentId) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string id = null; + string assemblyName = null; + string customSnapInType = null; + string description = null; + string descriptionIndirect = null; + Version requiredPowerShellVersion = CompilerConstants.IllegalVersion; + string vendor = null; + string vendorIndirect = null; + string version = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + + case "CustomSnapInType": + customSnapInType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "DescriptionIndirect": + descriptionIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "RequiredPowerShellVersion": + string ver = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + requiredPowerShellVersion = new Version(ver); + break; + + case "Vendor": + vendor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "VendorIndirect": + vendorIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "Version": + version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == id) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + // Default to require PowerShell 1.0. + if (CompilerConstants.IllegalVersion == requiredPowerShellVersion) + { + requiredPowerShellVersion = new Version(1, 0); + } + + // If the snap-in version isn't explicitly specified, get it + // from the assembly version at bind time. + if (null == version) + { + version = String.Format("!(bind.assemblyVersion.{0})", fileId); + } + + foreach (XElement child in node.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + switch (child.Name.LocalName) + { + case "FormatsFile": + this.ParseExtensionsFile(child, "Formats", id, componentId); + break; + case "TypesFile": + this.ParseExtensionsFile(child, "Types", id, componentId); + break; + default: + this.Core.UnexpectedElement(node, child); + break; + } + } + else + { + this.Core.ParseExtensionElement(node, child); + } + } + + // Get the major part of the required PowerShell version which is + // needed for the registry key, and put that into a WiX variable + // for use in Formats and Types files. PowerShell v2 still uses 1. + int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; + + WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); + wixVariableRow.Id = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id); + wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); + wixVariableRow.Overridable = false; + + int registryRoot = 2; // HKLM + string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); + + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); + + // set the assembly name automatically when binding. + // processorArchitecture is not handled correctly by PowerShell v1.0 + // so format the assembly name explicitly. + assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); + + if (null != customSnapInType) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); + } + + if (null != description) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); + } + + if (null != descriptionIndirect) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); + } + + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); + + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); + + if (null != vendor) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); + } + + if (null != vendorIndirect) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); + } + + if (null != version) + { + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); + } + } + + /// + /// Parses a FormatsFile and TypesFile element. + /// + /// Element to parse. + /// Registry value name. + /// Idendifier for parent file or snap-in. + /// Identifier for parent component. + private void ParseExtensionsFile(XElement node, string valueName, string id, string componentId) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string fileId = null; + string snapIn = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "FileId": + fileId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + snapIn = id; + break; + + case "SnapIn": + fileId = id; + snapIn = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == fileId && null == snapIn) + { + this.Core.OnMessage(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); + } + + this.Core.ParseForExtensionElements(node); + + int registryRoot = 2; // HKLM + string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); + + this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); + this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); + } + } +} diff --git a/src/wixext/PSExtensionData.cs b/src/wixext/PSExtensionData.cs new file mode 100644 index 00000000..578bda91 --- /dev/null +++ b/src/wixext/PSExtensionData.cs @@ -0,0 +1,34 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensions +{ + using System; + using System.Reflection; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset PowerShell Extension. + /// + public sealed class PSExtensionData : ExtensionData + { + /// + /// 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 PSExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Internal mechanism to access the extension's library. + /// + /// Extension's library. + internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + { + return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.ps.wixlib", tableDefinitions); + } + } +} diff --git a/src/wixext/WixPSExtension.csproj b/src/wixext/WixPSExtension.csproj new file mode 100644 index 00000000..f9349ef1 --- /dev/null +++ b/src/wixext/WixPSExtension.csproj @@ -0,0 +1,43 @@ + + + + + + + {6F1482DF-1598-4D88-BDAA-B9D0E0242139} + WixPSExtension + Library + WixToolset.Extensions + + + + + + + $(RootNamespace).Data.Messages.resources + + + $(RootNamespace).Xsd.ps.xsd + PreserveNewest + + + WixToolset.Data.Serialize + WixToolset.Extensions.Serialize.PS + + + Data\ps.wixlib + + + + + + + + + + false + + + + + diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml new file mode 100644 index 00000000..ef715640 --- /dev/null +++ b/src/wixext/messages.xml @@ -0,0 +1,20 @@ + + + + + + + + Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element. + + + + + + + The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically. + + + + + diff --git a/src/wixext/ps.xsd b/src/wixext/ps.xsd new file mode 100644 index 00000000..0c4c2bef --- /dev/null +++ b/src/wixext/ps.xsd @@ -0,0 +1,191 @@ + + + + + + + + The source code schema for the WiX Toolset PowerShell Extension. + + + + + + + Identifies the parent File as a formats XML file for the referenced PowerShell snap-in. + + + + + A formats XML file that defines output formats for objects on the pipeline. + + + + + + + + Reference to the formats File ID. This is required when nested under the SnapIn element. + + + + + + + Reference to the PowerShell snap-in ID for which this formats file is associated. This is required when nested under the File element. + + + + + + + + + Identifies the parent File as a types XML file for the referenced PowerShell snap-in. + + + + + A types XML file used by the extensible type system. + + + + + + + + Reference to the types File ID. This is required when nested under the SnapIn element. + + + + + + + Reference to the PowerShell snap-in ID for which this types file is associated. This is required when nested under the File element. + + + + + + + + + Identifies the parent File as a PowerShell snap-in to be registered on the system. + + + + + PowerShell snap-ins + allow developers to extend the functionality of of the PowerShell engine. + Add this element to identify the parent File as a PowerShell snap-in that will + get registered on the system. + + + + + + + + + + + + The identifier for this PowerShell snap-in. + + + + + + + The fully-qualified name of the assembly. + + + + + + + + + + The full type name of a class that is used to register a list of cmdlets and providers. + + + + + + + A brief description of the snap-in. + + + + + + + An embedded resource that contains a brief description of the snap-in. + This resource must be embedded in the current snap-in assembly. + + + + + + + The required version of PowerShell that must be installed and is associated with the + snap-in registration. The default value is "1.0". + + + + + + + The name of the snap-in vendor. + + + + + + + An embedded resource that contains the name of the snap-in vendor. + This resource must be embedded in the current snap-in assembly. + + + + + + + The version of the snapin. If not specified, this is taken from the assembly name. + + + + + + + + + + Values should be in the format ResourceName,StringName, where ResourceName + is the name of the embedded resource in your assembly sans the ".resources" extension, and StringName + is the name of the string resource in the embedded resource. + + + Example: UtilityMshSnapInResources,Description + + + + + + + + + Values of this type will look like: "x", "x.x", "x.x.x", or "x.x.x.x" where x is an integer from 0 to 65534. + + + + + + + diff --git a/src/wixlib/PSExtension.wixproj b/src/wixlib/PSExtension.wixproj new file mode 100644 index 00000000..da2b6463 --- /dev/null +++ b/src/wixlib/PSExtension.wixproj @@ -0,0 +1,19 @@ + + + + + + + {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} + ps + Library + true + true + + + + + + + + diff --git a/src/wixlib/PSExtension.wxs b/src/wixlib/PSExtension.wxs new file mode 100644 index 00000000..a1f16ee6 --- /dev/null +++ b/src/wixlib/PSExtension.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb From 985ba427f8cd12b7b74d62f83a8b304764e6077b Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 19 Jan 2019 13:03:02 -0600 Subject: Integrate into latest v4 --- .editorconfig | 37 +++++++ PowerShell.wixext.sln | 63 ++++++++++++ appveyor.cmd | 13 +++ appveyor.yml | 40 ++++++++ nuget.config | 14 +++ src/Directory.Build.props | 26 +++++ src/Directory.Build.targets | 48 ++++++++++ src/FindLocalWix.props | 8 ++ .../PowerShellExtensionFixture.cs | 26 +++++ .../TestData/TypesFile/Package.en-us.wxl | 11 +++ .../TestData/TypesFile/Package.wxs | 21 ++++ .../TestData/TypesFile/PackageComponents.wxs | 13 +++ .../TestData/TypesFile/example.txt | 1 + .../WixToolsetTest.Powershell.csproj | 38 ++++++++ src/wixext/PSCompiler.cs | 106 ++++++++++----------- src/wixext/PSErrors.cs | 30 ++++++ src/wixext/PSExtensionData.cs | 26 +++-- src/wixext/PSWarnings.cs | 30 ++++++ src/wixext/PowerShellExtensionFactory.cs | 17 ++++ src/wixext/WixPSExtension.csproj | 43 --------- src/wixext/WixToolset.PowerShell.wixext.csproj | 29 ++++++ src/wixext/WixToolset.PowerShell.wixext.targets | 11 +++ src/wixext/messages.xml | 20 ---- src/wixlib/PSExtension.wixproj | 19 ---- src/wixlib/packages.config | 5 + src/wixlib/powershell.wixproj | 35 +++++++ version.json | 11 +++ 27 files changed, 588 insertions(+), 153 deletions(-) create mode 100644 .editorconfig create mode 100644 PowerShell.wixext.sln create mode 100644 appveyor.cmd create mode 100644 appveyor.yml create mode 100644 nuget.config create mode 100644 src/Directory.Build.props create mode 100644 src/Directory.Build.targets create mode 100644 src/FindLocalWix.props create mode 100644 src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs create mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs create mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt create mode 100644 src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj create mode 100644 src/wixext/PSErrors.cs create mode 100644 src/wixext/PSWarnings.cs create mode 100644 src/wixext/PowerShellExtensionFactory.cs delete mode 100644 src/wixext/WixPSExtension.csproj create mode 100644 src/wixext/WixToolset.PowerShell.wixext.csproj create mode 100644 src/wixext/WixToolset.PowerShell.wixext.targets delete mode 100644 src/wixext/messages.xml delete mode 100644 src/wixlib/PSExtension.wixproj create mode 100644 src/wixlib/packages.config create mode 100644 src/wixlib/powershell.wixproj create mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/.editorconfig @@ -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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/PowerShell.wixext.sln b/PowerShell.wixext.sln new file mode 100644 index 00000000..24be219a --- /dev/null +++ b/PowerShell.wixext.sln @@ -0,0 +1,63 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2003 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "powershell", "src\wixlib\powershell.wixproj", "{9D4CCDFC-840C-4D4E-A9B0-3D6015480645}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.PowerShell.wixext", "src\wixext\WixToolset.PowerShell.wixext.csproj", "{6F1482DF-1598-4D88-BDAA-B9D0E0242139}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.PowerShell", "src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj", "{BFD10109-F4F3-4530-BE3B-802342D411F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.Build.0 = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x64.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.Build.0 = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.Build.0 = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x64.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.Build.0 = Release|x86 + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.Build.0 = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.Build.0 = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60A3EA0F-9313-47F8-BF6B-74478A57B577} + EndGlobalSection +EndGlobal diff --git a/appveyor.cmd b/appveyor.cmd new file mode 100644 index 00000000..27d33a5d --- /dev/null +++ b/appveyor.cmd @@ -0,0 +1,13 @@ +@setlocal +@pushd %~dp0 + +nuget restore + +msbuild -p:Configuration=Release -t:Restore + +msbuild -p:Configuration=Release src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.PowerShell.wixext.csproj + +@popd +@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..c1df03cc --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,40 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2017 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/nuget.config b/nuget.config new file mode 100644 index 00000000..f4f0704e --- /dev/null +++ b/nuget.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..e853e22d --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,26 @@ + + + + + + Debug + false + + $(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/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs b/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs new file mode 100644 index 00000000..b2f27ecf --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.PowerShell +{ + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.PowerShell; + using Xunit; + + public class PowerShellExtensionFixture + { + [Fact] + public void CantBuildUsingTypesFileWithoutSnapIn() + { + var folder = TestData.Get(@"TestData\TypesFile"); + var build = new Builder(folder, typeof(PowerShellExtensionFactory), new[] { folder }); + + WixRunnerResult wixRunnerResult = null; + var results = build.BuildAndQuery(args => { + wixRunnerResult = WixRunner.Execute(args); + }); + Assert.NotNull(wixRunnerResult); + Assert.Equal((int)PSErrors.Ids.NeitherIdSpecified, wixRunnerResult.ExitCode); + } + } +} diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs new file mode 100644 index 00000000..cdc323ec --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs new file mode 100644 index 00000000..049f9a51 --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj new file mode 100644 index 00000000..0b5dfac4 --- /dev/null +++ b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj @@ -0,0 +1,38 @@ + + + + + + netcoreapp2.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 61eb287c..200d3fb4 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs @@ -1,30 +1,24 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.PowerShell { using System; using System.Collections.Generic; using System.Globalization; using System.Xml.Linq; using WixToolset.Data; - using WixToolset.Data.Rows; + using WixToolset.Data.Tuples; using WixToolset.Extensibility; /// - /// The compiler for the WiX Toolset Internet Information Services Extension. + /// The compiler for the WiX Toolset PowerShell Extension. /// - public sealed class PSCompiler : CompilerExtension + public sealed class PSCompiler : BaseCompilerExtension { private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; private const string VarPrefix = "PSVersionMajor"; - /// - /// Instantiate a new PSCompiler. - /// - public PSCompiler() - { - this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/powershell"; - } + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/powershell"; /// /// Processes an element for the Compiler. @@ -33,7 +27,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) { switch (parentElement.Name.LocalName) { @@ -44,25 +38,25 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "FormatsFile": - this.ParseExtensionsFile(element, "Formats", fileId, componentId); + this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId); break; case "SnapIn": - this.ParseSnapInElement(element, fileId, componentId); + this.ParseSnapInElement(intermediate, section, element, fileId, componentId); break; case "TypesFile": - this.ParseExtensionsFile(element, "Types", fileId, componentId); + this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, 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; } } @@ -73,9 +67,9 @@ namespace WixToolset.Extensions /// Element to parse. /// Identifier for parent file. /// Identifier for parent component. - private void ParseSnapInElement(XElement node, string fileId, string componentId) + private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string id = null; string assemblyName = null; string customSnapInType = null; @@ -93,52 +87,52 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; case "CustomSnapInType": - customSnapInType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "DescriptionIndirect": - descriptionIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "RequiredPowerShellVersion": - string ver = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + string ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); requiredPowerShellVersion = new Version(ver); break; case "Vendor": - vendor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "VendorIndirect": - vendorIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Version": - version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + version = this.ParseHelper.GetAttributeVersionValue(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); } } if (null == id) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } // Default to require PowerShell 1.0. @@ -161,19 +155,19 @@ namespace WixToolset.Extensions switch (child.Name.LocalName) { case "FormatsFile": - this.ParseExtensionsFile(child, "Formats", id, componentId); + this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId); break; case "TypesFile": - this.ParseExtensionsFile(child, "Types", id, componentId); + this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId); 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); } } @@ -182,54 +176,54 @@ namespace WixToolset.Extensions // for use in Formats and Types files. PowerShell v2 still uses 1. int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; - WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); - wixVariableRow.Id = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id); + var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); + var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable", variableId); wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); wixVariableRow.Overridable = false; int registryRoot = 2; // HKLM string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); // set the assembly name automatically when binding. // processorArchitecture is not handled correctly by PowerShell v1.0 // so format the assembly name explicitly. assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); if (null != customSnapInType) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); } if (null != description) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); } if (null != descriptionIndirect) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); } - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); if (null != vendor) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); } if (null != vendorIndirect) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); } if (null != version) { - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); } } @@ -240,9 +234,9 @@ namespace WixToolset.Extensions /// Registry value name. /// Idendifier for parent file or snap-in. /// Identifier for parent component. - private void ParseExtensionsFile(XElement node, string valueName, string id, string componentId) + private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string fileId = null; string snapIn = null; @@ -253,38 +247,38 @@ namespace WixToolset.Extensions switch (attrib.Name.LocalName) { case "FileId": - fileId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); snapIn = id; break; case "SnapIn": fileId = id; - snapIn = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + snapIn = 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); } } if (null == fileId && null == snapIn) { - this.Core.OnMessage(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); + this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); int registryRoot = 2; // HKLM string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); - this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); + this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); } } } diff --git a/src/wixext/PSErrors.cs b/src/wixext/PSErrors.cs new file mode 100644 index 00000000..704cf5cd --- /dev/null +++ b/src/wixext/PSErrors.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System.Resources; + using WixToolset.Data; + + public static class PSErrors + { + public static Message NeitherIdSpecified(SourceLineNumber sourceLineNumbers, string element) + { + return Message(sourceLineNumbers, Ids.NeitherIdSpecified, "Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element.", element); + } + + 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 + { + NeitherIdSpecified = 5301, + } + } +} diff --git a/src/wixext/PSExtensionData.cs b/src/wixext/PSExtensionData.cs index 578bda91..d9a2d2e7 100644 --- a/src/wixext/PSExtensionData.cs +++ b/src/wixext/PSExtensionData.cs @@ -1,34 +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.PowerShell { - using System; - using System.Reflection; using WixToolset.Data; using WixToolset.Extensibility; /// /// The WiX Toolset PowerShell Extension. /// - public sealed class PSExtensionData : ExtensionData + public sealed class PSExtensionData : BaseExtensionData { /// - /// Gets the library associated with this extension. + /// Gets the default culture. /// - /// The table definitions to use while loading the library. - /// The loaded library. - public override Library GetLibrary(TableDefinitionCollection tableDefinitions) + /// The default culture. + public override string DefaultCulture => "en-US"; + + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - return PSExtensionData.GetExtensionLibrary(tableDefinitions); + tupleDefinition = null; + 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.ps.wixlib", tableDefinitions); + return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", tupleDefinitions); } } } diff --git a/src/wixext/PSWarnings.cs b/src/wixext/PSWarnings.cs new file mode 100644 index 00000000..9be14948 --- /dev/null +++ b/src/wixext/PSWarnings.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System.Resources; + using WixToolset.Data; + + public static class PSWarnings + { + public static Message DeprecatedAssemblyNameAttribute(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.DeprecatedAssemblyNameAttribute, "The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically."); + } + + 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 + { + DeprecatedAssemblyNameAttribute = 5350, + } + } +} diff --git a/src/wixext/PowerShellExtensionFactory.cs b/src/wixext/PowerShellExtensionFactory.cs new file mode 100644 index 00000000..22a4ad88 --- /dev/null +++ b/src/wixext/PowerShellExtensionFactory.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class PowerShellExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(PSCompiler), + typeof(PSExtensionData), + }; + } +} diff --git a/src/wixext/WixPSExtension.csproj b/src/wixext/WixPSExtension.csproj deleted file mode 100644 index f9349ef1..00000000 --- a/src/wixext/WixPSExtension.csproj +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - {6F1482DF-1598-4D88-BDAA-B9D0E0242139} - WixPSExtension - Library - WixToolset.Extensions - - - - - - - $(RootNamespace).Data.Messages.resources - - - $(RootNamespace).Xsd.ps.xsd - PreserveNewest - - - WixToolset.Data.Serialize - WixToolset.Extensions.Serialize.PS - - - Data\ps.wixlib - - - - - - - - - - false - - - - - diff --git a/src/wixext/WixToolset.PowerShell.wixext.csproj b/src/wixext/WixToolset.PowerShell.wixext.csproj new file mode 100644 index 00000000..666e8aba --- /dev/null +++ b/src/wixext/WixToolset.PowerShell.wixext.csproj @@ -0,0 +1,29 @@ + + + + + + netstandard2.0 + WixToolset.PowerShell + WiX Toolset PowerShell Extension + WiX Toolset PowerShell Extension + true + build + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.PowerShell.wixext.targets b/src/wixext/WixToolset.PowerShell.wixext.targets new file mode 100644 index 00000000..bf06e1e4 --- /dev/null +++ b/src/wixext/WixToolset.PowerShell.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.PowerShell.wixext.dll + + + + + diff --git a/src/wixext/messages.xml b/src/wixext/messages.xml deleted file mode 100644 index ef715640..00000000 --- a/src/wixext/messages.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element. - - - - - - - The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically. - - - - - diff --git a/src/wixlib/PSExtension.wixproj b/src/wixlib/PSExtension.wixproj deleted file mode 100644 index da2b6463..00000000 --- a/src/wixlib/PSExtension.wixproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} - ps - Library - true - true - - - - - - - - diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config new file mode 100644 index 00000000..7964daed --- /dev/null +++ b/src/wixlib/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj new file mode 100644 index 00000000..eba605dc --- /dev/null +++ b/src/wixlib/powershell.wixproj @@ -0,0 +1,35 @@ + + + + + + + {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} + powershell + Library + true + true + + + + + + + + + + + + + + + + + + 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/version.json b/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} -- cgit v1.2.3-55-g6feb From dd8b4e6e1faf570c1233a7feb77f24751dcfc605 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 10 Apr 2020 09:24:44 +1000 Subject: Update dependencies. --- appveyor.yml | 2 +- src/Directory.Build.props | 4 +++- src/FindLocalWix.props | 2 +- .../WixToolsetTest.Powershell.csproj | 13 ++++++++----- src/wixext/PSCompiler.cs | 4 ++-- src/wixlib/packages.config | 2 +- src/wixlib/powershell.wixproj | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/appveyor.yml b/appveyor.yml index c1df03cc..7c686b04 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ branches: - master - develop -image: Visual Studio 2017 +image: Visual Studio 2019 version: 0.0.0.{build} configuration: Release diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e853e22d..a22f4470 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,6 +8,7 @@ Debug false + MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -21,6 +22,7 @@ WiX Toolset - + + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props index a784e352..1666e4fe 100644 --- a/src/FindLocalWix.props +++ b/src/FindLocalWix.props @@ -3,6 +3,6 @@ - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets diff --git a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj index 0b5dfac4..69645fb7 100644 --- a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj +++ b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj @@ -3,7 +3,7 @@ - netcoreapp2.1 + netcoreapp3.1 false @@ -23,7 +23,10 @@ - + + + + @@ -31,8 +34,8 @@ - - - + + + diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 200d3fb4..74e18bd7 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs @@ -181,7 +181,7 @@ namespace WixToolset.PowerShell wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); wixVariableRow.Overridable = false; - int registryRoot = 2; // HKLM + RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); @@ -274,7 +274,7 @@ namespace WixToolset.PowerShell this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - int registryRoot = 2; // HKLM + RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index 7964daed..e1b601f6 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj index eba605dc..c9135cae 100644 --- a/src/wixlib/powershell.wixproj +++ b/src/wixlib/powershell.wixproj @@ -1,7 +1,7 @@ - + {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} @@ -29,7 +29,7 @@ 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}. - + -- cgit v1.2.3-55-g6feb From f662e0ed63b1a22b7a9aed9093076a7b3bf808c6 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 10 Apr 2020 09:33:11 +1000 Subject: Modernize PSCompiler. --- src/wixext/PSCompiler.cs | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 74e18bd7..2a384231 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs @@ -32,8 +32,8 @@ namespace WixToolset.PowerShell switch (parentElement.Name.LocalName) { case "File": - string fileId = context["FileId"]; - string componentId = context["ComponentId"]; + var fileId = context["FileId"]; + var componentId = context["ComponentId"]; switch (element.Name.LocalName) { @@ -69,18 +69,17 @@ namespace WixToolset.PowerShell /// Identifier for parent component. private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string id = null; - string assemblyName = null; string customSnapInType = null; string description = null; string descriptionIndirect = null; - Version requiredPowerShellVersion = CompilerConstants.IllegalVersion; + var requiredPowerShellVersion = CompilerConstants.IllegalVersion; string vendor = null; string vendorIndirect = null; string version = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -103,7 +102,7 @@ namespace WixToolset.PowerShell break; case "RequiredPowerShellVersion": - string ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); + var ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); requiredPowerShellVersion = new Version(ver); break; @@ -148,7 +147,7 @@ namespace WixToolset.PowerShell version = String.Format("!(bind.assemblyVersion.{0})", fileId); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (this.Namespace == child.Name.Namespace) { @@ -174,56 +173,58 @@ namespace WixToolset.PowerShell // Get the major part of the required PowerShell version which is // needed for the registry key, and put that into a WiX variable // for use in Formats and Types files. PowerShell v2 still uses 1. - int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; + var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); - var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable", variableId); - wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); - wixVariableRow.Overridable = false; + section.AddTuple(new WixVariableTuple(sourceLineNumbers, variableId) + { + Value = major.ToString(CultureInfo.InvariantCulture), + Overridable = false, + }); - RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM - string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); + var registryRoot = RegistryRootType.LocalMachine; // HKLM + var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); // set the assembly name automatically when binding. // processorArchitecture is not handled correctly by PowerShell v1.0 // so format the assembly name explicitly. - assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); + var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); if (null != customSnapInType) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); } if (null != description) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); } if (null != descriptionIndirect) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); } - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); if (null != vendor) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); } if (null != vendorIndirect) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); } if (null != version) { - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); } } @@ -236,11 +237,11 @@ namespace WixToolset.PowerShell /// Identifier for parent component. private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); string fileId = null; string snapIn = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -274,11 +275,11 @@ namespace WixToolset.PowerShell this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM - string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); + var registryRoot = RegistryRootType.LocalMachine; // HKLM + var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); - this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); + this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); } } } -- cgit v1.2.3-55-g6feb From 7f4b7ee0038faf7099450d89a0ab7b1ef29e3f15 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 13 Apr 2020 19:05:06 +1000 Subject: Update dependencies. --- src/wixlib/packages.config | 2 +- src/wixlib/powershell.wixproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index e1b601f6..1e5a9850 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj index c9135cae..9506edf7 100644 --- a/src/wixlib/powershell.wixproj +++ b/src/wixlib/powershell.wixproj @@ -1,7 +1,7 @@ - + {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} @@ -29,7 +29,7 @@ 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}. - + -- cgit v1.2.3-55-g6feb From 0bee971ca12ea73d0c4e69da4f0836ab62c43e17 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 27 Oct 2020 18:08:31 -0400 Subject: Update project for Package/SummaryInformation change (and many others). --- PowerShell.wixext.sln | 4 ++-- global.json | 5 ++++ .../TestData/TypesFile/Package.wxs | 10 +++----- src/wixext/PSCompiler.cs | 28 +++++++++++----------- src/wixext/PSExtensionData.cs | 10 ++++---- src/wixlib/packages.config | 5 ---- src/wixlib/powershell.wixproj | 28 ++-------------------- 7 files changed, 31 insertions(+), 59 deletions(-) create mode 100644 global.json delete mode 100644 src/wixlib/packages.config (limited to 'src') diff --git a/PowerShell.wixext.sln b/PowerShell.wixext.sln index 24be219a..a036d47e 100644 --- a/PowerShell.wixext.sln +++ b/PowerShell.wixext.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2003 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 15.0.26124.0 Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "powershell", "src\wixlib\powershell.wixproj", "{9D4CCDFC-840C-4D4E-A9B0-3D6015480645}" EndProject diff --git a/global.json b/global.json new file mode 100644 index 00000000..f94ab6df --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0162" + } +} diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs index cdc323ec..082ac4cc 100644 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs @@ -1,15 +1,11 @@ - - - - - + + - - + diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 2a384231..3b09897a 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs @@ -7,7 +7,7 @@ namespace WixToolset.PowerShell using System.Globalization; using System.Xml.Linq; using WixToolset.Data; - using WixToolset.Data.Tuples; + using WixToolset.Data.Symbols; using WixToolset.Extensibility; /// @@ -176,7 +176,7 @@ namespace WixToolset.PowerShell var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); - section.AddTuple(new WixVariableTuple(sourceLineNumbers, variableId) + section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, variableId) { Value = major.ToString(CultureInfo.InvariantCulture), Overridable = false, @@ -185,46 +185,46 @@ namespace WixToolset.PowerShell var registryRoot = RegistryRootType.LocalMachine; // HKLM var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); // set the assembly name automatically when binding. // processorArchitecture is not handled correctly by PowerShell v1.0 // so format the assembly name explicitly. var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); if (null != customSnapInType) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); } if (null != description) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); } if (null != descriptionIndirect) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); } - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); if (null != vendor) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); } if (null != vendorIndirect) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); } if (null != version) { - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); } } @@ -278,8 +278,8 @@ namespace WixToolset.PowerShell var registryRoot = RegistryRootType.LocalMachine; // HKLM var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); - this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); } } } diff --git a/src/wixext/PSExtensionData.cs b/src/wixext/PSExtensionData.cs index d9a2d2e7..66627942 100644 --- a/src/wixext/PSExtensionData.cs +++ b/src/wixext/PSExtensionData.cs @@ -16,15 +16,15 @@ namespace WixToolset.PowerShell /// The default culture. public override string DefaultCulture => "en-US"; - public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) { - tupleDefinition = null; - return tupleDefinition != null; + return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", symbolDefinitions); } - public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) { - return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", tupleDefinitions); + symbolDefinition = null; + return symbolDefinition != null; } } } diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config deleted file mode 100644 index 1e5a9850..00000000 --- a/src/wixlib/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj index 9506edf7..d841de4f 100644 --- a/src/wixlib/powershell.wixproj +++ b/src/wixlib/powershell.wixproj @@ -1,35 +1,11 @@ - - - - + - {9d4ccdfc-840c-4d4e-a9b0-3d6015480645} - powershell Library true - true - + - - - - - - - - - - - - - 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}. - - - - - -- cgit v1.2.3-55-g6feb From a5a6c2fc839ee3223aeb4d7549db35cdaf8e4dca Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 31 Oct 2020 22:13:53 -0400 Subject: Strong-name sign WiX assemblies. --- global.json | 2 +- src/CSharp.Build.props | 11 +++++++++++ src/Directory.Build.props | 1 + src/wix.snk | Bin 0 -> 596 bytes 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/CSharp.Build.props create mode 100644 src/wix.snk (limited to 'src') diff --git a/global.json b/global.json index f94ab6df..10345833 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0162" + "WixToolset.Sdk": "4.0.0-build-0163" } } diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a22f4470..f83cc154 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,6 +22,7 @@ WiX Toolset + diff --git a/src/wix.snk b/src/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/wix.snk differ -- cgit v1.2.3-55-g6feb From 8203897431e76a2a9162bd2e5e019cc8628fc200 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 4 Dec 2020 17:39:31 -0600 Subject: xsd got moved to doc repo. Update dependencies. --- global.json | 2 +- src/wixext/WixToolset.PowerShell.wixext.csproj | 3 +- src/wixext/ps.xsd | 191 ------------------------- src/wixlib/powershell.wixproj | 2 +- 4 files changed, 3 insertions(+), 195 deletions(-) delete mode 100644 src/wixext/ps.xsd (limited to 'src') diff --git a/global.json b/global.json index 10345833..77a81322 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0163" + "WixToolset.Sdk": "4.0.0-build-0170" } } diff --git a/src/wixext/WixToolset.PowerShell.wixext.csproj b/src/wixext/WixToolset.PowerShell.wixext.csproj index 666e8aba..32bd9bac 100644 --- a/src/wixext/WixToolset.PowerShell.wixext.csproj +++ b/src/wixext/WixToolset.PowerShell.wixext.csproj @@ -12,7 +12,6 @@ - @@ -24,6 +23,6 @@ - + diff --git a/src/wixext/ps.xsd b/src/wixext/ps.xsd deleted file mode 100644 index 0c4c2bef..00000000 --- a/src/wixext/ps.xsd +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - The source code schema for the WiX Toolset PowerShell Extension. - - - - - - - Identifies the parent File as a formats XML file for the referenced PowerShell snap-in. - - - - - A formats XML file that defines output formats for objects on the pipeline. - - - - - - - - Reference to the formats File ID. This is required when nested under the SnapIn element. - - - - - - - Reference to the PowerShell snap-in ID for which this formats file is associated. This is required when nested under the File element. - - - - - - - - - Identifies the parent File as a types XML file for the referenced PowerShell snap-in. - - - - - A types XML file used by the extensible type system. - - - - - - - - Reference to the types File ID. This is required when nested under the SnapIn element. - - - - - - - Reference to the PowerShell snap-in ID for which this types file is associated. This is required when nested under the File element. - - - - - - - - - Identifies the parent File as a PowerShell snap-in to be registered on the system. - - - - - PowerShell snap-ins - allow developers to extend the functionality of of the PowerShell engine. - Add this element to identify the parent File as a PowerShell snap-in that will - get registered on the system. - - - - - - - - - - - - The identifier for this PowerShell snap-in. - - - - - - - The fully-qualified name of the assembly. - - - - - - - - - - The full type name of a class that is used to register a list of cmdlets and providers. - - - - - - - A brief description of the snap-in. - - - - - - - An embedded resource that contains a brief description of the snap-in. - This resource must be embedded in the current snap-in assembly. - - - - - - - The required version of PowerShell that must be installed and is associated with the - snap-in registration. The default value is "1.0". - - - - - - - The name of the snap-in vendor. - - - - - - - An embedded resource that contains the name of the snap-in vendor. - This resource must be embedded in the current snap-in assembly. - - - - - - - The version of the snapin. If not specified, this is taken from the assembly name. - - - - - - - - - - Values should be in the format ResourceName,StringName, where ResourceName - is the name of the embedded resource in your assembly sans the ".resources" extension, and StringName - is the name of the string resource in the embedded resource. - - - Example: UtilityMshSnapInResources,Description - - - - - - - - - Values of this type will look like: "x", "x.x", "x.x.x", or "x.x.x.x" where x is an integer from 0 to 65534. - - - - - - - diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj index d841de4f..6d6b413b 100644 --- a/src/wixlib/powershell.wixproj +++ b/src/wixlib/powershell.wixproj @@ -6,6 +6,6 @@ - + -- cgit v1.2.3-55-g6feb From 79cc786be11fb288374222287c549b910e4ce65d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 7 Apr 2021 23:05:49 -0700 Subject: Update dependencies --- global.json | 2 +- src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs | 8 +++----- src/wixext/PSCompiler.cs | 2 +- src/wixext/WixToolset.PowerShell.wixext.csproj | 2 ++ 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index 77a81322..fc26eb6e 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-0206" } } diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs index 082ac4cc..411893bc 100644 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs +++ b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs @@ -8,10 +8,8 @@ - - - - - + + + diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 3b09897a..37591282 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs @@ -175,7 +175,7 @@ namespace WixToolset.PowerShell // for use in Formats and Types files. PowerShell v2 still uses 1. var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; - var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); + var variableId = new Identifier(AccessModifier.Global, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, variableId) { Value = major.ToString(CultureInfo.InvariantCulture), diff --git a/src/wixext/WixToolset.PowerShell.wixext.csproj b/src/wixext/WixToolset.PowerShell.wixext.csproj index 32bd9bac..a89a574c 100644 --- a/src/wixext/WixToolset.PowerShell.wixext.csproj +++ b/src/wixext/WixToolset.PowerShell.wixext.csproj @@ -10,10 +10,12 @@ true build + + -- cgit v1.2.3-55-g6feb From 0a7de80d773dba9d93b64015934a92fd908824d7 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 20 Apr 2021 13:06:43 -0700 Subject: Integrate latest tooling --- global.json | 2 +- src/wixext/PowerShellExtensionFactory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index fc26eb6e..23dd3fa6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0206" + "WixToolset.Sdk": "4.0.0-build-0211" } } diff --git a/src/wixext/PowerShellExtensionFactory.cs b/src/wixext/PowerShellExtensionFactory.cs index 22a4ad88..44f836e0 100644 --- a/src/wixext/PowerShellExtensionFactory.cs +++ b/src/wixext/PowerShellExtensionFactory.cs @@ -8,7 +8,7 @@ namespace WixToolset.PowerShell public class PowerShellExtensionFactory : BaseExtensionFactory { - protected override IEnumerable ExtensionTypes => new[] + protected override IReadOnlyCollection ExtensionTypes => new[] { typeof(PSCompiler), typeof(PSExtensionData), -- cgit v1.2.3-55-g6feb From 59765d27eb205b7b62a5057cfb631caee97f0af6 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:49:35 -0700 Subject: Move PowerShell.wixext into ext --- .editorconfig | 37 --- PowerShell.wixext.sln | 63 ----- README.md | 2 - appveyor.cmd | 13 - appveyor.yml | 40 --- global.json | 5 - nuget.config | 14 - src/.editorconfig | 37 +++ src/CSharp.Build.props | 11 - src/Directory.Build.props | 29 --- src/Directory.Build.targets | 48 ---- src/FindLocalWix.props | 8 - src/ext/PowerShell/CSharp.Build.props | 11 + src/ext/PowerShell/Directory.Build.props | 29 +++ src/ext/PowerShell/Directory.Build.targets | 48 ++++ src/ext/PowerShell/FindLocalWix.props | 8 + src/ext/PowerShell/PowerShell.wixext.sln | 63 +++++ src/ext/PowerShell/README.md | 2 + src/ext/PowerShell/appveyor.cmd | 13 + src/ext/PowerShell/appveyor.yml | 40 +++ src/ext/PowerShell/nuget.config | 14 + .../PowerShellExtensionFixture.cs | 26 ++ .../TestData/TypesFile/Package.en-us.wxl | 11 + .../TestData/TypesFile/Package.wxs | 15 ++ .../TestData/TypesFile/PackageComponents.wxs | 13 + .../TestData/TypesFile/example.txt | 1 + .../WixToolsetTest.Powershell.csproj | 41 +++ src/ext/PowerShell/wix.snk | Bin 0 -> 596 bytes src/ext/PowerShell/wixext/PSCompiler.cs | 285 +++++++++++++++++++++ src/ext/PowerShell/wixext/PSErrors.cs | 30 +++ src/ext/PowerShell/wixext/PSExtensionData.cs | 30 +++ src/ext/PowerShell/wixext/PSWarnings.cs | 30 +++ .../wixext/PowerShellExtensionFactory.cs | 17 ++ .../wixext/WixToolset.PowerShell.wixext.csproj | 30 +++ .../wixext/WixToolset.PowerShell.wixext.targets | 11 + src/ext/PowerShell/wixlib/PSExtension.wxs | 12 + src/ext/PowerShell/wixlib/powershell.wixproj | 11 + src/ext/global.json | 5 + .../PowerShellExtensionFixture.cs | 26 -- .../TestData/TypesFile/Package.en-us.wxl | 11 - .../TestData/TypesFile/Package.wxs | 15 -- .../TestData/TypesFile/PackageComponents.wxs | 13 - .../TestData/TypesFile/example.txt | 1 - .../WixToolsetTest.Powershell.csproj | 41 --- src/version.json | 11 + src/wix.snk | Bin 596 -> 0 bytes src/wixext/PSCompiler.cs | 285 --------------------- src/wixext/PSErrors.cs | 30 --- src/wixext/PSExtensionData.cs | 30 --- src/wixext/PSWarnings.cs | 30 --- src/wixext/PowerShellExtensionFactory.cs | 17 -- src/wixext/WixToolset.PowerShell.wixext.csproj | 30 --- src/wixext/WixToolset.PowerShell.wixext.targets | 11 - src/wixlib/PSExtension.wxs | 12 - src/wixlib/powershell.wixproj | 11 - version.json | 11 - 56 files changed, 844 insertions(+), 844 deletions(-) delete mode 100644 .editorconfig delete mode 100644 PowerShell.wixext.sln delete mode 100644 README.md delete mode 100644 appveyor.cmd delete mode 100644 appveyor.yml delete mode 100644 global.json delete mode 100644 nuget.config create mode 100644 src/.editorconfig delete mode 100644 src/CSharp.Build.props delete mode 100644 src/Directory.Build.props delete mode 100644 src/Directory.Build.targets delete mode 100644 src/FindLocalWix.props create mode 100644 src/ext/PowerShell/CSharp.Build.props create mode 100644 src/ext/PowerShell/Directory.Build.props create mode 100644 src/ext/PowerShell/Directory.Build.targets create mode 100644 src/ext/PowerShell/FindLocalWix.props create mode 100644 src/ext/PowerShell/PowerShell.wixext.sln create mode 100644 src/ext/PowerShell/README.md create mode 100644 src/ext/PowerShell/appveyor.cmd create mode 100644 src/ext/PowerShell/appveyor.yml create mode 100644 src/ext/PowerShell/nuget.config create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt create mode 100644 src/ext/PowerShell/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj create mode 100644 src/ext/PowerShell/wix.snk create mode 100644 src/ext/PowerShell/wixext/PSCompiler.cs create mode 100644 src/ext/PowerShell/wixext/PSErrors.cs create mode 100644 src/ext/PowerShell/wixext/PSExtensionData.cs create mode 100644 src/ext/PowerShell/wixext/PSWarnings.cs create mode 100644 src/ext/PowerShell/wixext/PowerShellExtensionFactory.cs create mode 100644 src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.csproj create mode 100644 src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.targets create mode 100644 src/ext/PowerShell/wixlib/PSExtension.wxs create mode 100644 src/ext/PowerShell/wixlib/powershell.wixproj create mode 100644 src/ext/global.json delete mode 100644 src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs delete mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs delete mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt delete mode 100644 src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj create mode 100644 src/version.json delete mode 100644 src/wix.snk delete mode 100644 src/wixext/PSCompiler.cs delete mode 100644 src/wixext/PSErrors.cs delete mode 100644 src/wixext/PSExtensionData.cs delete mode 100644 src/wixext/PSWarnings.cs delete mode 100644 src/wixext/PowerShellExtensionFactory.cs delete mode 100644 src/wixext/WixToolset.PowerShell.wixext.csproj delete mode 100644 src/wixext/WixToolset.PowerShell.wixext.targets delete mode 100644 src/wixlib/PSExtension.wxs delete mode 100644 src/wixlib/powershell.wixproj delete mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1d72e683..00000000 --- a/.editorconfig +++ /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. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig -# then update all of the repos. - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.{cs,vb}] -dotnet_sort_system_directives_first = true - -[*.cs] -csharp_indent_case_contents = true : error -csharp_indent_switch_labels = true : error -csharp_new_line_before_open_brace = all -csharp_prefer_braces = true : error -csharp_style_expression_bodied_methods = when_on_single_line : suggestion -csharp_style_expression_bodied_constructors = when_on_single_line : suggestion -csharp_style_expression_bodied_operators = when_on_single_line : suggestion -csharp_style_expression_bodied_properties = when_on_single_line : suggestion -csharp_style_expression_bodied_indexers = when_on_single_line : suggestion -csharp_style_expression_bodied_accessors = when_on_single_line : suggestion -csharp_style_var_elsewhere = true : suggestion -csharp_style_var_for_built_in_types = true : suggestion -csharp_style_var_when_type_is_apparent = true : suggestion -dotnet_style_qualification_for_event = true : error -dotnet_style_qualification_for_field = true : error -dotnet_style_qualification_for_method = true : error -dotnet_style_qualification_for_property = true : error - -[*.targets] -indent_size = 2 diff --git a/PowerShell.wixext.sln b/PowerShell.wixext.sln deleted file mode 100644 index a036d47e..00000000 --- a/PowerShell.wixext.sln +++ /dev/null @@ -1,63 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 15.0.26124.0 -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "powershell", "src\wixlib\powershell.wixproj", "{9D4CCDFC-840C-4D4E-A9B0-3D6015480645}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.PowerShell.wixext", "src\wixext\WixToolset.PowerShell.wixext.csproj", "{6F1482DF-1598-4D88-BDAA-B9D0E0242139}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.PowerShell", "src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj", "{BFD10109-F4F3-4530-BE3B-802342D411F7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.ActiveCfg = Debug|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.Build.0 = Debug|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x64.ActiveCfg = Debug|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.ActiveCfg = Debug|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.Build.0 = Debug|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.ActiveCfg = Release|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.Build.0 = Release|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x64.ActiveCfg = Release|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.ActiveCfg = Release|x86 - {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.Build.0 = Release|x86 - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.ActiveCfg = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.Build.0 = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.ActiveCfg = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.Build.0 = Debug|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.Build.0 = Release|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.ActiveCfg = Release|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.Build.0 = Release|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.ActiveCfg = Release|Any CPU - {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.Build.0 = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.ActiveCfg = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.Build.0 = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.ActiveCfg = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.Build.0 = Debug|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.Build.0 = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.ActiveCfg = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.Build.0 = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.ActiveCfg = Release|Any CPU - {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {60A3EA0F-9313-47F8-BF6B-74478A57B577} - EndGlobalSection -EndGlobal diff --git a/README.md b/README.md deleted file mode 100644 index 6de236f7..00000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# PowerShell.wixext -WixToolset.PowerShell.wixext - PowerShell WiX Toolset Extension diff --git a/appveyor.cmd b/appveyor.cmd deleted file mode 100644 index 27d33a5d..00000000 --- a/appveyor.cmd +++ /dev/null @@ -1,13 +0,0 @@ -@setlocal -@pushd %~dp0 - -nuget restore - -msbuild -p:Configuration=Release -t:Restore - -msbuild -p:Configuration=Release src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj - -msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.PowerShell.wixext.csproj - -@popd -@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7c686b04..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,40 +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. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml -# then update all of the repos. - -branches: - only: - - master - - develop - -image: Visual Studio 2019 - -version: 0.0.0.{build} -configuration: Release - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - NUGET_XMLDOC_MODE: skip - -build_script: - - appveyor.cmd - -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -skip_branch_with_pr: true -skip_tags: true - -artifacts: -- path: build\Release\**\*.nupkg - name: nuget - -notifications: -- provider: Slack - incoming_webhook: - secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/global.json b/global.json deleted file mode 100644 index 23dd3fa6..00000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0211" - } -} diff --git a/nuget.config b/nuget.config deleted file mode 100644 index f4f0704e..00000000 --- a/nuget.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/src/.editorconfig @@ -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. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props deleted file mode 100644 index b12f4c6e..00000000 --- a/src/CSharp.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index f83cc154..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - 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 deleted file mode 100644 index dac7452a..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - 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 deleted file mode 100644 index 1666e4fe..00000000 --- a/src/FindLocalWix.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets - - diff --git a/src/ext/PowerShell/CSharp.Build.props b/src/ext/PowerShell/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/ext/PowerShell/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/ext/PowerShell/Directory.Build.props b/src/ext/PowerShell/Directory.Build.props new file mode 100644 index 00000000..f83cc154 --- /dev/null +++ b/src/ext/PowerShell/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + + + diff --git a/src/ext/PowerShell/Directory.Build.targets b/src/ext/PowerShell/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/ext/PowerShell/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/ext/PowerShell/FindLocalWix.props b/src/ext/PowerShell/FindLocalWix.props new file mode 100644 index 00000000..1666e4fe --- /dev/null +++ b/src/ext/PowerShell/FindLocalWix.props @@ -0,0 +1,8 @@ + + + + + + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + + diff --git a/src/ext/PowerShell/PowerShell.wixext.sln b/src/ext/PowerShell/PowerShell.wixext.sln new file mode 100644 index 00000000..a036d47e --- /dev/null +++ b/src/ext/PowerShell/PowerShell.wixext.sln @@ -0,0 +1,63 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30611.23 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "powershell", "src\wixlib\powershell.wixproj", "{9D4CCDFC-840C-4D4E-A9B0-3D6015480645}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.PowerShell.wixext", "src\wixext\WixToolset.PowerShell.wixext.csproj", "{6F1482DF-1598-4D88-BDAA-B9D0E0242139}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.PowerShell", "src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj", "{BFD10109-F4F3-4530-BE3B-802342D411F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|Any CPU.Build.0 = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x64.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.ActiveCfg = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Debug|x86.Build.0 = Debug|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|Any CPU.Build.0 = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x64.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.ActiveCfg = Release|x86 + {9D4CCDFC-840C-4D4E-A9B0-3D6015480645}.Release|x86.Build.0 = Release|x86 + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x64.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.ActiveCfg = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Debug|x86.Build.0 = Debug|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|Any CPU.Build.0 = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x64.Build.0 = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.ActiveCfg = Release|Any CPU + {6F1482DF-1598-4D88-BDAA-B9D0E0242139}.Release|x86.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x64.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.ActiveCfg = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Debug|x86.Build.0 = Debug|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|Any CPU.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x64.Build.0 = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.ActiveCfg = Release|Any CPU + {BFD10109-F4F3-4530-BE3B-802342D411F7}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {60A3EA0F-9313-47F8-BF6B-74478A57B577} + EndGlobalSection +EndGlobal diff --git a/src/ext/PowerShell/README.md b/src/ext/PowerShell/README.md new file mode 100644 index 00000000..6de236f7 --- /dev/null +++ b/src/ext/PowerShell/README.md @@ -0,0 +1,2 @@ +# PowerShell.wixext +WixToolset.PowerShell.wixext - PowerShell WiX Toolset Extension diff --git a/src/ext/PowerShell/appveyor.cmd b/src/ext/PowerShell/appveyor.cmd new file mode 100644 index 00000000..27d33a5d --- /dev/null +++ b/src/ext/PowerShell/appveyor.cmd @@ -0,0 +1,13 @@ +@setlocal +@pushd %~dp0 + +nuget restore + +msbuild -p:Configuration=Release -t:Restore + +msbuild -p:Configuration=Release src\test\WixToolsetTest.PowerShell\WixToolsetTest.PowerShell.csproj + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.PowerShell.wixext.csproj + +@popd +@endlocal \ No newline at end of file diff --git a/src/ext/PowerShell/appveyor.yml b/src/ext/PowerShell/appveyor.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/ext/PowerShell/appveyor.yml @@ -0,0 +1,40 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/ext/PowerShell/nuget.config b/src/ext/PowerShell/nuget.config new file mode 100644 index 00000000..f4f0704e --- /dev/null +++ b/src/ext/PowerShell/nuget.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs new file mode 100644 index 00000000..b2f27ecf --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.PowerShell +{ + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.PowerShell; + using Xunit; + + public class PowerShellExtensionFixture + { + [Fact] + public void CantBuildUsingTypesFileWithoutSnapIn() + { + var folder = TestData.Get(@"TestData\TypesFile"); + var build = new Builder(folder, typeof(PowerShellExtensionFactory), new[] { folder }); + + WixRunnerResult wixRunnerResult = null; + var results = build.BuildAndQuery(args => { + wixRunnerResult = WixRunner.Execute(args); + }); + Assert.NotNull(wixRunnerResult); + Assert.Equal((int)PSErrors.Ids.NeitherIdSpecified, wixRunnerResult.ExitCode); + } + } +} diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs new file mode 100644 index 00000000..411893bc --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs new file mode 100644 index 00000000..049f9a51 --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/PowerShell/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj new file mode 100644 index 00000000..69645fb7 --- /dev/null +++ b/src/ext/PowerShell/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj @@ -0,0 +1,41 @@ + + + + + + netcoreapp3.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/PowerShell/wix.snk b/src/ext/PowerShell/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/ext/PowerShell/wix.snk differ diff --git a/src/ext/PowerShell/wixext/PSCompiler.cs b/src/ext/PowerShell/wixext/PSCompiler.cs new file mode 100644 index 00000000..37591282 --- /dev/null +++ b/src/ext/PowerShell/wixext/PSCompiler.cs @@ -0,0 +1,285 @@ +// 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.PowerShell +{ + using System; + using System.Collections.Generic; + using System.Globalization; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Data.Symbols; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset PowerShell Extension. + /// + public sealed class PSCompiler : BaseCompilerExtension + { + private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; + private const string VarPrefix = "PSVersionMajor"; + + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/powershell"; + + /// + /// 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) + { + switch (parentElement.Name.LocalName) + { + case "File": + var fileId = context["FileId"]; + var componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "FormatsFile": + this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId); + break; + + case "SnapIn": + this.ParseSnapInElement(intermediate, section, element, fileId, componentId); + break; + + case "TypesFile": + this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, componentId); + break; + + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a SnapIn element. + /// + /// Element to parse. + /// Identifier for parent file. + /// Identifier for parent component. + private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + string id = null; + string customSnapInType = null; + string description = null; + string descriptionIndirect = null; + var requiredPowerShellVersion = CompilerConstants.IllegalVersion; + string vendor = null; + string vendorIndirect = null; + string version = 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; + + case "CustomSnapInType": + customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "Description": + description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "DescriptionIndirect": + descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "RequiredPowerShellVersion": + var ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); + requiredPowerShellVersion = new Version(ver); + break; + + case "Vendor": + vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "VendorIndirect": + vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + case "Version": + version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + if (null == id) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + // Default to require PowerShell 1.0. + if (CompilerConstants.IllegalVersion == requiredPowerShellVersion) + { + requiredPowerShellVersion = new Version(1, 0); + } + + // If the snap-in version isn't explicitly specified, get it + // from the assembly version at bind time. + if (null == version) + { + version = String.Format("!(bind.assemblyVersion.{0})", fileId); + } + + foreach (var child in node.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + switch (child.Name.LocalName) + { + case "FormatsFile": + this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId); + break; + case "TypesFile": + this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId); + break; + default: + this.ParseHelper.UnexpectedElement(node, child); + break; + } + } + else + { + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); + } + } + + // Get the major part of the required PowerShell version which is + // needed for the registry key, and put that into a WiX variable + // for use in Formats and Types files. PowerShell v2 still uses 1. + var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; + + var variableId = new Identifier(AccessModifier.Global, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); + section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, variableId) + { + Value = major.ToString(CultureInfo.InvariantCulture), + Overridable = false, + }); + + var registryRoot = RegistryRootType.LocalMachine; // HKLM + var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); + + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); + + // set the assembly name automatically when binding. + // processorArchitecture is not handled correctly by PowerShell v1.0 + // so format the assembly name explicitly. + var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); + + if (null != customSnapInType) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); + } + + if (null != description) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); + } + + if (null != descriptionIndirect) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); + } + + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); + + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); + + if (null != vendor) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); + } + + if (null != vendorIndirect) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); + } + + if (null != version) + { + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); + } + } + + /// + /// Parses a FormatsFile and TypesFile element. + /// + /// Element to parse. + /// Registry value name. + /// Idendifier for parent file or snap-in. + /// Identifier for parent component. + private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); + string fileId = null; + string snapIn = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "FileId": + fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + snapIn = id; + break; + + case "SnapIn": + fileId = id; + snapIn = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + + default: + this.ParseHelper.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); + } + } + + if (null == fileId && null == snapIn) + { + this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); + + var registryRoot = RegistryRootType.LocalMachine; // HKLM + var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); + + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); + this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); + } + } +} diff --git a/src/ext/PowerShell/wixext/PSErrors.cs b/src/ext/PowerShell/wixext/PSErrors.cs new file mode 100644 index 00000000..704cf5cd --- /dev/null +++ b/src/ext/PowerShell/wixext/PSErrors.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System.Resources; + using WixToolset.Data; + + public static class PSErrors + { + public static Message NeitherIdSpecified(SourceLineNumber sourceLineNumbers, string element) + { + return Message(sourceLineNumbers, Ids.NeitherIdSpecified, "Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element.", element); + } + + 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 + { + NeitherIdSpecified = 5301, + } + } +} diff --git a/src/ext/PowerShell/wixext/PSExtensionData.cs b/src/ext/PowerShell/wixext/PSExtensionData.cs new file mode 100644 index 00000000..66627942 --- /dev/null +++ b/src/ext/PowerShell/wixext/PSExtensionData.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset PowerShell Extension. + /// + public sealed class PSExtensionData : BaseExtensionData + { + /// + /// Gets the default culture. + /// + /// The default culture. + public override string DefaultCulture => "en-US"; + + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", symbolDefinitions); + } + + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = null; + return symbolDefinition != null; + } + } +} diff --git a/src/ext/PowerShell/wixext/PSWarnings.cs b/src/ext/PowerShell/wixext/PSWarnings.cs new file mode 100644 index 00000000..9be14948 --- /dev/null +++ b/src/ext/PowerShell/wixext/PSWarnings.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System.Resources; + using WixToolset.Data; + + public static class PSWarnings + { + public static Message DeprecatedAssemblyNameAttribute(SourceLineNumber sourceLineNumbers) + { + return Message(sourceLineNumbers, Ids.DeprecatedAssemblyNameAttribute, "The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically."); + } + + 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 + { + DeprecatedAssemblyNameAttribute = 5350, + } + } +} diff --git a/src/ext/PowerShell/wixext/PowerShellExtensionFactory.cs b/src/ext/PowerShell/wixext/PowerShellExtensionFactory.cs new file mode 100644 index 00000000..44f836e0 --- /dev/null +++ b/src/ext/PowerShell/wixext/PowerShellExtensionFactory.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.PowerShell +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class PowerShellExtensionFactory : BaseExtensionFactory + { + protected override IReadOnlyCollection ExtensionTypes => new[] + { + typeof(PSCompiler), + typeof(PSExtensionData), + }; + } +} diff --git a/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.csproj b/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.csproj new file mode 100644 index 00000000..a89a574c --- /dev/null +++ b/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.csproj @@ -0,0 +1,30 @@ + + + + + + netstandard2.0 + WixToolset.PowerShell + WiX Toolset PowerShell Extension + WiX Toolset PowerShell Extension + true + build + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.targets b/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.targets new file mode 100644 index 00000000..bf06e1e4 --- /dev/null +++ b/src/ext/PowerShell/wixext/WixToolset.PowerShell.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.PowerShell.wixext.dll + + + + + diff --git a/src/ext/PowerShell/wixlib/PSExtension.wxs b/src/ext/PowerShell/wixlib/PSExtension.wxs new file mode 100644 index 00000000..a1f16ee6 --- /dev/null +++ b/src/ext/PowerShell/wixlib/PSExtension.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/ext/PowerShell/wixlib/powershell.wixproj b/src/ext/PowerShell/wixlib/powershell.wixproj new file mode 100644 index 00000000..6d6b413b --- /dev/null +++ b/src/ext/PowerShell/wixlib/powershell.wixproj @@ -0,0 +1,11 @@ + + + + Library + true + + + + + + diff --git a/src/ext/global.json b/src/ext/global.json new file mode 100644 index 00000000..23dd3fa6 --- /dev/null +++ b/src/ext/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0211" + } +} diff --git a/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs b/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.cs deleted file mode 100644 index b2f27ecf..00000000 --- a/src/test/WixToolsetTest.PowerShell/PowerShellExtensionFixture.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 WixToolsetTest.PowerShell -{ - using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; - using WixToolset.PowerShell; - using Xunit; - - public class PowerShellExtensionFixture - { - [Fact] - public void CantBuildUsingTypesFileWithoutSnapIn() - { - var folder = TestData.Get(@"TestData\TypesFile"); - var build = new Builder(folder, typeof(PowerShellExtensionFactory), new[] { folder }); - - WixRunnerResult wixRunnerResult = null; - var results = build.BuildAndQuery(args => { - wixRunnerResult = WixRunner.Execute(args); - }); - Assert.NotNull(wixRunnerResult); - Assert.Equal((int)PSErrors.Ids.NeitherIdSpecified, wixRunnerResult.ExitCode); - } - } -} diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs deleted file mode 100644 index 411893bc..00000000 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/Package.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs deleted file mode 100644 index 049f9a51..00000000 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/PackageComponents.wxs +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt b/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.PowerShell/TestData/TypesFile/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj b/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj deleted file mode 100644 index 69645fb7..00000000 --- a/src/test/WixToolsetTest.PowerShell/WixToolsetTest.Powershell.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - netcoreapp3.1 - false - - - - NU1701 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/version.json b/src/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/src/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} diff --git a/src/wix.snk b/src/wix.snk deleted file mode 100644 index 3908a66a..00000000 Binary files a/src/wix.snk and /dev/null differ diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs deleted file mode 100644 index 37591282..00000000 --- a/src/wixext/PSCompiler.cs +++ /dev/null @@ -1,285 +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.PowerShell -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.Xml.Linq; - using WixToolset.Data; - using WixToolset.Data.Symbols; - using WixToolset.Extensibility; - - /// - /// The compiler for the WiX Toolset PowerShell Extension. - /// - public sealed class PSCompiler : BaseCompilerExtension - { - private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; - private const string VarPrefix = "PSVersionMajor"; - - public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/powershell"; - - /// - /// 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) - { - switch (parentElement.Name.LocalName) - { - case "File": - var fileId = context["FileId"]; - var componentId = context["ComponentId"]; - - switch (element.Name.LocalName) - { - case "FormatsFile": - this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId); - break; - - case "SnapIn": - this.ParseSnapInElement(intermediate, section, element, fileId, componentId); - break; - - case "TypesFile": - this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, componentId); - break; - - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - } - - /// - /// Parses a SnapIn element. - /// - /// Element to parse. - /// Identifier for parent file. - /// Identifier for parent component. - private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - string id = null; - string customSnapInType = null; - string description = null; - string descriptionIndirect = null; - var requiredPowerShellVersion = CompilerConstants.IllegalVersion; - string vendor = null; - string vendorIndirect = null; - string version = 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; - - case "CustomSnapInType": - customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - case "Description": - description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - case "DescriptionIndirect": - descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - case "RequiredPowerShellVersion": - var ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); - requiredPowerShellVersion = new Version(ver); - break; - - case "Vendor": - vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - case "VendorIndirect": - vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - case "Version": - version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - if (null == id) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); - } - - // Default to require PowerShell 1.0. - if (CompilerConstants.IllegalVersion == requiredPowerShellVersion) - { - requiredPowerShellVersion = new Version(1, 0); - } - - // If the snap-in version isn't explicitly specified, get it - // from the assembly version at bind time. - if (null == version) - { - version = String.Format("!(bind.assemblyVersion.{0})", fileId); - } - - foreach (var child in node.Elements()) - { - if (this.Namespace == child.Name.Namespace) - { - switch (child.Name.LocalName) - { - case "FormatsFile": - this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId); - break; - case "TypesFile": - this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId); - break; - default: - this.ParseHelper.UnexpectedElement(node, child); - break; - } - } - else - { - this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); - } - } - - // Get the major part of the required PowerShell version which is - // needed for the registry key, and put that into a WiX variable - // for use in Formats and Types files. PowerShell v2 still uses 1. - var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; - - var variableId = new Identifier(AccessModifier.Global, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); - section.AddSymbol(new WixVariableSymbol(sourceLineNumbers, variableId) - { - Value = major.ToString(CultureInfo.InvariantCulture), - Overridable = false, - }); - - var registryRoot = RegistryRootType.LocalMachine; // HKLM - var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); - - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); - - // set the assembly name automatically when binding. - // processorArchitecture is not handled correctly by PowerShell v1.0 - // so format the assembly name explicitly. - var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); - - if (null != customSnapInType) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); - } - - if (null != description) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); - } - - if (null != descriptionIndirect) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); - } - - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); - - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); - - if (null != vendor) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); - } - - if (null != vendorIndirect) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); - } - - if (null != version) - { - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); - } - } - - /// - /// Parses a FormatsFile and TypesFile element. - /// - /// Element to parse. - /// Registry value name. - /// Idendifier for parent file or snap-in. - /// Identifier for parent component. - private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); - string fileId = null; - string snapIn = null; - - foreach (var attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "FileId": - fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - snapIn = id; - break; - - case "SnapIn": - fileId = id; - snapIn = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - - default: - this.ParseHelper.UnexpectedAttribute(node, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); - } - } - - if (null == fileId && null == snapIn) - { - this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); - - var registryRoot = RegistryRootType.LocalMachine; // HKLM - var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); - - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.File, fileId); - this.ParseHelper.CreateRegistrySymbol(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); - } - } -} diff --git a/src/wixext/PSErrors.cs b/src/wixext/PSErrors.cs deleted file mode 100644 index 704cf5cd..00000000 --- a/src/wixext/PSErrors.cs +++ /dev/null @@ -1,30 +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.PowerShell -{ - using System.Resources; - using WixToolset.Data; - - public static class PSErrors - { - public static Message NeitherIdSpecified(SourceLineNumber sourceLineNumbers, string element) - { - return Message(sourceLineNumbers, Ids.NeitherIdSpecified, "Either the {0}/@FileId attribute must be specified if nested under a SnapIn element, or the {0}/@SnapIn attribute must be specified if nested under under a File element.", element); - } - - 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 - { - NeitherIdSpecified = 5301, - } - } -} diff --git a/src/wixext/PSExtensionData.cs b/src/wixext/PSExtensionData.cs deleted file mode 100644 index 66627942..00000000 --- a/src/wixext/PSExtensionData.cs +++ /dev/null @@ -1,30 +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.PowerShell -{ - using WixToolset.Data; - using WixToolset.Extensibility; - - /// - /// The WiX Toolset PowerShell Extension. - /// - public sealed class PSExtensionData : BaseExtensionData - { - /// - /// Gets the default culture. - /// - /// The default culture. - public override string DefaultCulture => "en-US"; - - public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) - { - return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", symbolDefinitions); - } - - public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = null; - return symbolDefinition != null; - } - } -} diff --git a/src/wixext/PSWarnings.cs b/src/wixext/PSWarnings.cs deleted file mode 100644 index 9be14948..00000000 --- a/src/wixext/PSWarnings.cs +++ /dev/null @@ -1,30 +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.PowerShell -{ - using System.Resources; - using WixToolset.Data; - - public static class PSWarnings - { - public static Message DeprecatedAssemblyNameAttribute(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.DeprecatedAssemblyNameAttribute, "The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically."); - } - - 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 - { - DeprecatedAssemblyNameAttribute = 5350, - } - } -} diff --git a/src/wixext/PowerShellExtensionFactory.cs b/src/wixext/PowerShellExtensionFactory.cs deleted file mode 100644 index 44f836e0..00000000 --- a/src/wixext/PowerShellExtensionFactory.cs +++ /dev/null @@ -1,17 +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.PowerShell -{ - using System; - using System.Collections.Generic; - using WixToolset.Extensibility; - - public class PowerShellExtensionFactory : BaseExtensionFactory - { - protected override IReadOnlyCollection ExtensionTypes => new[] - { - typeof(PSCompiler), - typeof(PSExtensionData), - }; - } -} diff --git a/src/wixext/WixToolset.PowerShell.wixext.csproj b/src/wixext/WixToolset.PowerShell.wixext.csproj deleted file mode 100644 index a89a574c..00000000 --- a/src/wixext/WixToolset.PowerShell.wixext.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - netstandard2.0 - WixToolset.PowerShell - WiX Toolset PowerShell Extension - WiX Toolset PowerShell Extension - true - build - - - - - - - - - - - - - - - - - - - diff --git a/src/wixext/WixToolset.PowerShell.wixext.targets b/src/wixext/WixToolset.PowerShell.wixext.targets deleted file mode 100644 index bf06e1e4..00000000 --- a/src/wixext/WixToolset.PowerShell.wixext.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\tools\WixToolset.PowerShell.wixext.dll - - - - - diff --git a/src/wixlib/PSExtension.wxs b/src/wixlib/PSExtension.wxs deleted file mode 100644 index a1f16ee6..00000000 --- a/src/wixlib/PSExtension.wxs +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/wixlib/powershell.wixproj b/src/wixlib/powershell.wixproj deleted file mode 100644 index 6d6b413b..00000000 --- a/src/wixlib/powershell.wixproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Library - true - - - - - - diff --git a/version.json b/version.json deleted file mode 100644 index 5f857771..00000000 --- a/version.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "4.0", - "publicReleaseRefSpec": [ - "^refs/heads/master$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} -- cgit v1.2.3-55-g6feb