diff --git a/CustomAction1/CustomAction.config b/CustomAction1/CustomAction.config new file mode 100644 index 0000000..cfae001 --- /dev/null +++ b/CustomAction1/CustomAction.config @@ -0,0 +1,17 @@ + + + + + + + diff --git a/CustomAction1/CustomAction.cs b/CustomAction1/CustomAction.cs new file mode 100644 index 0000000..932369a --- /dev/null +++ b/CustomAction1/CustomAction.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using WixToolset.Dtf.WindowsInstaller; + +namespace CustomAction1 +{ + public class CustomActions + { + [CustomAction] + public static ActionResult CustomAction1(Session session) + { + session.Log("Begin CustomAction1"); + + return ActionResult.Success; + } + } +} diff --git a/CustomAction1/CustomAction1.csproj b/CustomAction1/CustomAction1.csproj new file mode 100644 index 0000000..032c9dd --- /dev/null +++ b/CustomAction1/CustomAction1.csproj @@ -0,0 +1,14 @@ + + + net472 + + + + + + + + + + + diff --git a/PowerShellActions/PowerShellActions.csproj b/PowerShellActions/PowerShellActions.csproj index 8be44f8..c61ef70 100644 --- a/PowerShellActions/PowerShellActions.csproj +++ b/PowerShellActions/PowerShellActions.csproj @@ -1,58 +1,14 @@ - - + - Debug - x86 - 8.0.30703 - 2.0 - {0A83F788-68C1-4533-8732-6B8E3FBC5282} - Library - Properties - PowerShellActions - PowerShellActions - v4.5.2 - 512 - $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.CA.targets - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + net472 + - - - - False - ..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll - - - - - + + - - - - - - - - + + - - \ No newline at end of file diff --git a/PowerShellLibrary/Library.wxs b/PowerShellLibrary/Library.wxs index 234f4ef..63ff7ac 100644 --- a/PowerShellLibrary/Library.wxs +++ b/PowerShellLibrary/Library.wxs @@ -1,160 +1,87 @@ - - + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - NOT Installed + - NOT Installed + - NOT Installed + - NOT Installed + - NOT Installed + - NOT Installed + - NOT Installed + - NOT Installed + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - REMOVE="ALL" + - PowerShell Files - PowerShell Inline - PowerShell Inline (elevated) - PowerShell Files (elevated) - - PowerShell Uninstall Files - PowerShell Uninstall Inline - PowerShell Uninstall Inline (elevated) - PowerShell Uninstall Files (elevated) + + + + + + + + + \ No newline at end of file diff --git a/PowerShellLibrary/PowerShellLibrary.wixproj b/PowerShellLibrary/PowerShellLibrary.wixproj index 41be4af..23bd44b 100644 --- a/PowerShellLibrary/PowerShellLibrary.wixproj +++ b/PowerShellLibrary/PowerShellLibrary.wixproj @@ -1,36 +1,22 @@ - - + + - Debug - x86 3.8 - 598472f5-d044-41f2-a8f0-82976139c499 - 2.0 - PowerShellLibrary Library - $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets - $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets - bin\$(Configuration)\ - obj\$(Configuration)\ Debug - True + True False True True - bin\$(Configuration)\ - obj\$(Configuration)\ - True + True False True True - - - PowerShellActions @@ -41,15 +27,7 @@ INSTALLFOLDER - - + diff --git a/PowerShellWixExtension.sln b/PowerShellWixExtension.sln index 123ce20..792cf6d 100644 --- a/PowerShellWixExtension.sln +++ b/PowerShellWixExtension.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34701.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellWixExtension", "PowerShellWixExtension\PowerShellWixExtension.csproj", "{C1A335B5-3575-4AEC-9260-8C18CE59DB9B}" ProjectSection(ProjectDependencies) = postProject @@ -10,7 +10,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellWixExtension", "P EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellActions", "PowerShellActions\PowerShellActions.csproj", "{0A83F788-68C1-4533-8732-6B8E3FBC5282}" EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "PowerShellLibrary", "PowerShellLibrary\PowerShellLibrary.wixproj", "{598472F5-D044-41F2-A8F0-82976139C499}" +Project("{B7DD6F7E-DEF8-4E67-B5B7-07EF123DB6F0}") = "PowerShellLibrary", "PowerShellLibrary\PowerShellLibrary.wixproj", "{598472F5-D044-41F2-A8F0-82976139C499}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A176C3F-31D2-43DB-BAEA-A0DF71CC34FF}" ProjectSection(SolutionItems) = preProject @@ -92,4 +92,7 @@ Global {BBA07F7F-E4D8-47F7-9A05-4CD6644236C2} = {D7480EA6-0D6B-4010-A15F-460EB85DF682} {0E852B37-0DD2-4FE9-8E20-123C0040F8BA} = {D7480EA6-0D6B-4010-A15F-460EB85DF682} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {56452832-4D16-4FA6-ABED-EBA4ADA5C6D2} + EndGlobalSection EndGlobal diff --git a/PowerShellWixExtension/PowerShellCompilerExtension.cs b/PowerShellWixExtension/PowerShellCompilerExtension.cs index 40e7b94..8204d01 100644 --- a/PowerShellWixExtension/PowerShellCompilerExtension.cs +++ b/PowerShellWixExtension/PowerShellCompilerExtension.cs @@ -1,60 +1,66 @@ using System; +using System.Collections.Generic; using System.Reflection; using System.Text; -using System.Xml; -using System.Xml.Schema; -using Microsoft.Tools.WindowsInstallerXml; +using System.Xml.Linq; + +using WixToolset.Data; +using WixToolset.Data.WindowsInstaller; +using WixToolset.Extensibility; +using WixToolset.Extensibility.Data; namespace PowerShellWixExtension { - public class PowerShellCompilerExtension : CompilerExtension + public class PowerShellCompilerExtension : BaseCompilerExtension { - private readonly XmlSchema _schema; - - public PowerShellCompilerExtension() - { - _schema = LoadXmlSchemaHelper(Assembly.GetExecutingAssembly(), "PowerShellWixExtension.PowerShellWixExtensionSchema.xsd"); - } - - public override XmlSchema Schema - { - get - { - return _schema; - } - } - - public override void ParseElement(SourceLineNumberCollection sourceLineNumbers, XmlElement parentElement, XmlElement element, params string[] contextValues) + //private readonly XmlSchema _schema; + + //public PowerShellCompilerExtension() + //{ + // _schema = LoadXmlSchemaHelper(Assembly.GetExecutingAssembly(), "PowerShellWixExtension.PowerShellWixExtensionSchema.xsd"); + //} + + //public override XmlSchema Schema + //{ + // get + // { + // return _schema; + // } + //} + + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, + IDictionary context) { - switch (parentElement.LocalName) + switch (parentElement.Name.LocalName) { case "Product": case "Fragment": - switch (element.LocalName) + switch (element.Name.LocalName) { case "Script": ParseScriptElement(element); break; case "File": - ParseFileElement(element); + ParseFileElement(element, section); break; default: - Core.UnexpectedElement(parentElement, element); + ParseHelper.UnexpectedElement(parentElement, element); break; } break; default: - Core.UnexpectedElement( + ParseHelper.UnexpectedElement( parentElement, element); break; } + } - private void ParseFileElement(XmlNode node) + private void ParseFileElement(XElement node, IntermediateSection section) { - SourceLineNumberCollection sourceLineNumber = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumber = ParseHelper.GetSourceLineNumbers(node); string superElementId = null; string file = null; @@ -62,60 +68,63 @@ private void ParseFileElement(XmlNode node) string condition = null; var elevated = YesNoType.No; YesNoType ignoreErrors = YesNoType.No; - int order = 1000000000 + sourceLineNumber[0].LineNumber; + var order = 1000000000 + sourceLineNumber.LineNumber; - foreach (XmlAttribute attribute in node.Attributes) + foreach (var attribute in node.Attributes()) { - if (attribute.NamespaceURI.Length == 0 || - attribute.NamespaceURI == _schema.TargetNamespace) + if (attribute.Name.NamespaceName.Length == 0 || + attribute.Name.Namespace == Namespace) { - switch (attribute.LocalName) + switch (attribute.Name.LocalName) { case "Id": - superElementId = Core.GetAttributeIdentifierValue(sourceLineNumber, attribute); + superElementId = ParseHelper.GetAttributeIdentifierValue(sourceLineNumber, attribute); break; case "File": - file = Core.GetAttributeValue(sourceLineNumber, attribute, false); + file = ParseHelper.GetAttributeValue(sourceLineNumber, attribute); break; case "Arguments": - arguments = Core.GetAttributeValue(sourceLineNumber, attribute); + arguments = ParseHelper.GetAttributeValue(sourceLineNumber, attribute); break; case "Elevated": - elevated = Core.GetAttributeYesNoValue(sourceLineNumber, attribute); + elevated = ParseHelper.GetAttributeYesNoValue(sourceLineNumber, attribute); break; case "IgnoreErrors": - ignoreErrors = Core.GetAttributeYesNoValue(sourceLineNumber, attribute); + ignoreErrors = ParseHelper.GetAttributeYesNoValue(sourceLineNumber, attribute); break; case "Order": - order = Core.GetAttributeIntegerValue(sourceLineNumber, attribute, 0, 1000000000); + order = ParseHelper.GetAttributeIntegerValue(sourceLineNumber, attribute, 0, 1000000000); break; case "Condition": - condition = Core.GetAttributeValue(sourceLineNumber, attribute); + condition = ParseHelper.GetAttributeValue(sourceLineNumber, attribute); break; default: - Core.UnexpectedAttribute(sourceLineNumber, attribute); + ParseHelper.UnexpectedAttribute(node, attribute); break; } } else { - Core.UnsupportedExtensionAttribute(sourceLineNumber, attribute); + Messaging.Write(ErrorMessages.UnsupportedExtensionAttribute(sourceLineNumber, attribute.Parent.Name.LocalName, attribute.Name.LocalName)); } } if (string.IsNullOrEmpty(superElementId)) { - Core.OnMessage( - WixErrors.ExpectedAttribute(sourceLineNumber, node.Name, "Id")); + Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumber, node.Name.LocalName, "Id")); } if (string.IsNullOrEmpty(file)) { - Core.OnMessage( - WixErrors.ExpectedElement(sourceLineNumber, node.Name, "File")); + Messaging.Write(ErrorMessages.ExpectedElement(sourceLineNumber, "File")); } - if (!Core.EncounteredError) + if (order == null) + { + Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumber, node.Name.LocalName, "Order")); + } + + if (!Messaging.EncounteredError) { Row superElementRow = Core.CreateRow(sourceLineNumber, "PowerShellFiles"); @@ -128,10 +137,10 @@ private void ParseFileElement(XmlNode node) superElementRow[6] = condition; } - Core.CreateWixSimpleReferenceRow(sourceLineNumber, "CustomAction", "PowerShellFilesImmediate"); + ParseHelper.CreateCustomActionReference(sourceLineNumber, section, "PowerShellFilesImmediate", Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } - private void ParseScriptElement(XmlNode node) + private void ParseScriptElement(XElement node) { SourceLineNumberCollection sourceLineNumber = Preprocessor.GetSourceLineNumbers(node); @@ -150,23 +159,23 @@ private void ParseScriptElement(XmlNode node) switch (attribute.LocalName) { case "Id": - superElementId = Core.GetAttributeIdentifierValue(sourceLineNumber, attribute); + superElementId = ParseHelper.GetAttributeIdentifierValue(sourceLineNumber, attribute); break; case "Elevated": - elevated = Core.GetAttributeYesNoValue(sourceLineNumber, attribute); + elevated = ParseHelper.GetAttributeYesNoValue(sourceLineNumber, attribute); break; case "IgnoreErrors": - ignoreErrors = Core.GetAttributeYesNoValue(sourceLineNumber, attribute); + ignoreErrors = ParseHelper.GetAttributeYesNoValue(sourceLineNumber, attribute); break; case "Order": - order = Core.GetAttributeIntegerValue(sourceLineNumber, attribute, 0, 1000000000); + order = ParseHelper.GetAttributeIntegerValue(sourceLineNumber, attribute, 0, 1000000000); break; case "Condition": - condition = Core.GetAttributeValue(sourceLineNumber, attribute); + condition = ParseHelper.GetAttributeValue(sourceLineNumber, attribute); break; default: - Core.UnexpectedAttribute(sourceLineNumber, attribute); + ParseHelper.UnexpectedAttribute(sourceLineNumber, attribute); break; } } @@ -210,5 +219,7 @@ private void ParseScriptElement(XmlNode node) Core.CreateWixSimpleReferenceRow(sourceLineNumber, "CustomAction", "PowerShellScriptsImmediate"); } + + public override XNamespace Namespace => "http://schemas.gardiner.net.au/PowerShellWixExtensionSchema"; } } \ No newline at end of file diff --git a/PowerShellWixExtension/PowerShellInstallerBackendBinderExtension.cs b/PowerShellWixExtension/PowerShellInstallerBackendBinderExtension.cs new file mode 100644 index 0000000..721f4e1 --- /dev/null +++ b/PowerShellWixExtension/PowerShellInstallerBackendBinderExtension.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +using WixToolset.Data.WindowsInstaller; +using WixToolset.Extensibility; + +namespace PowerShellWixExtension +{ + public class PowerShellInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public override IReadOnlyCollection TableDefinitions => PowerShellTableDefinitions.All; + } +} \ No newline at end of file diff --git a/PowerShellWixExtension/PowerShellTableDefinitions.cs b/PowerShellWixExtension/PowerShellTableDefinitions.cs new file mode 100644 index 0000000..75cd186 --- /dev/null +++ b/PowerShellWixExtension/PowerShellTableDefinitions.cs @@ -0,0 +1,46 @@ +using PowerShellWixExtension.Symbols; + +using WixToolset.Data.WindowsInstaller; + +namespace PowerShellWixExtension +{ + public static class PowerShellTableDefinitions + { + public static readonly TableDefinition PowerShellScripts = new TableDefinition( + "PowerShellScripts", + PowerShellSymbolDefinitions.PowerShellScripts, + new[] + { + new ColumnDefinition("Id", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key for this element", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Script", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The PowerShell script to execute", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Elevated", ColumnType.Number, 0, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 1, description: "Run as elevated", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("IgnoreErrors", ColumnType.Number, 0, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 1, description: "When non-zero, PowerShell errors are ignored."), + new ColumnDefinition("Order", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 2000000000, description: "Order of execution."), + new ColumnDefinition("Condition", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Condition, modularizeType: ColumnModularizeType.Property) + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition PowerShellFiles = new TableDefinition( + "PowerShellFiles", + PowerShellSymbolDefinitions.PowerShellFiles, + new[] + { + new ColumnDefinition("Id", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key for this element", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FilePath", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Text, description: "The path to the PowerShell file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Arguments", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Text, description: "Arguments to pass to the PowerShell script", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Elevated", ColumnType.Number, 0, primaryKey: false, nullable: false, ColumnCategory.Unknown, minValue: 0, maxValue: 1, description: "Run as elevated", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("IgnoreErrors", ColumnType.Number, 0, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 1, description: "When non-zero, PowerShell errors are ignored."), + new ColumnDefinition("Order", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 2000000000, description: "Order of execution."), + new ColumnDefinition("Condition", ColumnType.String, 0, primaryKey: false, nullable: true, ColumnCategory.Condition, modularizeType: ColumnModularizeType.Property) + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + PowerShellScripts, + PowerShellFiles + }; + } +} \ No newline at end of file diff --git a/PowerShellWixExtension/PowerShellWixExtension.cs b/PowerShellWixExtension/PowerShellWixExtension.cs deleted file mode 100644 index 1ef270d..0000000 --- a/PowerShellWixExtension/PowerShellWixExtension.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using Microsoft.Tools.WindowsInstallerXml; - -namespace PowerShellWixExtension -{ - public class PowerShellWixExtension : WixExtension - { - private CompilerExtension _compilerExtension; - private Library _library; - private TableDefinitionCollection _tableDefinitions; - - public override CompilerExtension CompilerExtension - { - get - { - return _compilerExtension ?? (_compilerExtension = new PowerShellCompilerExtension()); - } - } - - public override TableDefinitionCollection TableDefinitions - { - get - { - return _tableDefinitions ?? (_tableDefinitions = LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "PowerShellWixExtension.TableDefinitions.xml")); - } - } - - public override Library GetLibrary(TableDefinitionCollection tableDefinitions) - { - return _library ?? (_library = LoadLibraryHelper(Assembly.GetExecutingAssembly(), "PowerShellWixExtension.PowerShellLibrary.wixlib", tableDefinitions)); - } - } -} \ No newline at end of file diff --git a/PowerShellWixExtension/PowerShellWixExtension.csproj b/PowerShellWixExtension/PowerShellWixExtension.csproj index 66be074..c1719ed 100644 --- a/PowerShellWixExtension/PowerShellWixExtension.csproj +++ b/PowerShellWixExtension/PowerShellWixExtension.csproj @@ -1,62 +1,24 @@ - - - + - Debug - AnyCPU - {C1A335B5-3575-4AEC-9260-8C18CE59DB9B} + netstandard2.0 Library - Properties - PowerShellWixExtension - PowerShellWixExtension - v4.5.2 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false + true - - - - - - - - - PowerShellLibrary - false - - - $(WIX)\bin\wix.dll - + + + + - - - + PowerShellWixExtensionSchema.xsd - @@ -69,16 +31,9 @@ - - PowerShellLibrary.wixlib - + + - - diff --git a/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd b/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd index e2e362d..703ad1f 100644 --- a/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd +++ b/PowerShellWixExtension/PowerShellWixExtensionSchema.xsd @@ -1,16 +1,6 @@ - - + - - The schema for the PowerShellWixExtension WiX Extension - + The schema for the PowerShellWixExtension WiX Extension @@ -21,17 +11,13 @@ - - Embed PowerShell commands using CDATA - + Embed PowerShell commands using CDATA - + The ID for the element. @@ -74,15 +60,11 @@ - - Run a PowerShell script file - + Run a PowerShell script file - + The ID for the element. diff --git a/PowerShellWixExtension/Symbols/PowerShellSymbol.cs b/PowerShellWixExtension/Symbols/PowerShellSymbol.cs new file mode 100644 index 0000000..b98dc7c --- /dev/null +++ b/PowerShellWixExtension/Symbols/PowerShellSymbol.cs @@ -0,0 +1,162 @@ +using WixToolset.Data; + +namespace PowerShellWixExtension.Symbols +{ + public static partial class PowerShellSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition PowerShellScripts = new IntermediateSymbolDefinition( + PowerShellSymbolDefinitionType.PowerShellScripts.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.Id), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.Script), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.Elevated), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.IgnoreErrors), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.Order), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellScriptsSymbolFields.Condition), IntermediateFieldType.String), + }, + typeof(PowerShellScriptSymbol) + ); + + public static IntermediateSymbolDefinition PowerShellFiles = new IntermediateSymbolDefinition( + PowerShellSymbolDefinitionType.PowerShellFiles.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.Id), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.FilePath), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.Arguments), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.Elevated), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.IgnoreErrors), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.Order), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(PowerShellFilesSymbolFields.Condition), IntermediateFieldType.String), + }, + typeof(PowerShellFileSymbol) + ); + } + + public enum PowerShellScriptsSymbolFields + { + Id, + Script, + Elevated, + IgnoreErrors, + Order, + Condition + } + + public class PowerShellScriptSymbol : IntermediateSymbol + { + public PowerShellScriptSymbol(IntermediateSymbolDefinition definition) : base(definition) + { + } + + public PowerShellScriptSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, Identifier id = null) : base(definition, sourceLineNumber, id) + { + } + + public IntermediateField this[PowerShellScriptsSymbolFields index] => Fields[(int)index]; + + public string Id + { + get => Fields[(int)PowerShellScriptsSymbolFields.Id].ToString(); + set => this.Set((int)PowerShellScriptsSymbolFields.Id, value); + } + + public string Script + { + get => Fields[(int)PowerShellScriptsSymbolFields.Script].ToString(); + set => this.Set((int)PowerShellScriptsSymbolFields.Script, value); + } + + public int Elevated + { + get => (int)Fields[(int)PowerShellScriptsSymbolFields.Elevated]; + set => this.Set((int)PowerShellScriptsSymbolFields.Elevated, value); + } + + public int IgnoreErrors + { + get => (int)Fields[(int)PowerShellScriptsSymbolFields.IgnoreErrors]; + set => this.Set((int)PowerShellScriptsSymbolFields.IgnoreErrors, value); + } + + public int Order + { + get => (int)Fields[(int)PowerShellScriptsSymbolFields.Order]; + set => this.Set((int)PowerShellScriptsSymbolFields.Order, value); + } + + public string Condition + { + get => Fields[(int)PowerShellScriptsSymbolFields.Condition].ToString(); + set => this.Set((int)PowerShellScriptsSymbolFields.Condition, value); + } + } + + public enum PowerShellFilesSymbolFields + { + Id, + FilePath, + Arguments, + Elevated, + IgnoreErrors, + Order, + Condition, + } + + public class PowerShellFileSymbol : IntermediateSymbol + { + public PowerShellFileSymbol(IntermediateSymbolDefinition definition) : base(definition) + { + } + + public PowerShellFileSymbol(IntermediateSymbolDefinition definition, SourceLineNumber sourceLineNumber, + Identifier id = null) : base(definition, sourceLineNumber, id) + { + } + + public IntermediateField this[PowerShellFilesSymbolFields index] => Fields[(int) index]; + + public string Id + { + get => Fields[(int) PowerShellFilesSymbolFields.Id].ToString(); + set => this.Set((int) PowerShellFilesSymbolFields.Id, value); + } + + public string FilePath + { + get => Fields[(int) PowerShellFilesSymbolFields.FilePath].ToString(); + set => this.Set((int) PowerShellFilesSymbolFields.FilePath, value); + } + + public string Arguments + { + get => Fields[(int) PowerShellFilesSymbolFields.Arguments].ToString(); + set => this.Set((int) PowerShellFilesSymbolFields.Arguments, value); + } + + public int Elevated + { + get => (int)Fields[(int) PowerShellFilesSymbolFields.Elevated]; + set => this.Set((int) PowerShellFilesSymbolFields.Elevated, value); + } + + public int IgnoreErrors + { + get => (int)Fields[(int) PowerShellFilesSymbolFields.IgnoreErrors]; + set => this.Set((int) PowerShellFilesSymbolFields.IgnoreErrors, value); + } + + public int Order + { + get => (int)Fields[(int) PowerShellFilesSymbolFields.Order]; + set => this.Set((int) PowerShellFilesSymbolFields.Order, value); + } + + public string Condition + { + get => Fields[(int) PowerShellFilesSymbolFields.Condition].ToString(); + set => this.Set((int) PowerShellFilesSymbolFields.Condition, value); + } + } +} \ No newline at end of file diff --git a/PowerShellWixExtension/Symbols/PowerShellSymbolDefinitions.cs b/PowerShellWixExtension/Symbols/PowerShellSymbolDefinitions.cs new file mode 100644 index 0000000..fcaa03d --- /dev/null +++ b/PowerShellWixExtension/Symbols/PowerShellSymbolDefinitions.cs @@ -0,0 +1,39 @@ +using System; +using WixToolset.Data; + +namespace PowerShellWixExtension.Symbols +{ + public enum PowerShellSymbolDefinitionType + { + PowerShellScripts, + PowerShellFiles + } + + public static partial class PowerShellSymbolDefinitions + { + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out PowerShellSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(PowerShellSymbolDefinitionType type) + { + switch (type) + { + case PowerShellSymbolDefinitionType.PowerShellScripts: + return PowerShellSymbolDefinitions.PowerShellScripts; + + case PowerShellSymbolDefinitionType.PowerShellFiles: + return PowerShellSymbolDefinitions.PowerShellFiles; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} \ No newline at end of file diff --git a/PowerShellWixExtension/TableDefinitions.xml b/PowerShellWixExtension/TableDefinitions.xml index b2b5313..9e9d2af 100644 --- a/PowerShellWixExtension/TableDefinitions.xml +++ b/PowerShellWixExtension/TableDefinitions.xml @@ -1,32 +1,11 @@ - - + - + - + - + @@ -35,45 +14,15 @@ - + - + - + - + - + diff --git a/version.json b/version.json index 60dd6e5..e705367 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "3.0", + "version": "4.0-preview", "publicReleaseRefSpec": [ "^refs/heads/main$", "^refs/heads/v\\d+(?:\\.\\d+)?$"