diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-01-01 10:30:42 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-01-01 22:47:02 -0800 |
| commit | 60d7baefb4e87bf0ddaae58a653faee0be0429f6 (patch) | |
| tree | e520865fd6da2368c5d33a4c98cca457bd8a8343 /src/wixext | |
| parent | 9c66865ab3e4b3c4cbcb721e22fd668dd4350afa (diff) | |
| download | wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.tar.gz wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.tar.bz2 wix-60d7baefb4e87bf0ddaae58a653faee0be0429f6.zip | |
Initial code commit
Diffstat (limited to 'src/wixext')
| -rw-r--r-- | src/wixext/NetFxCompiler.cs | 159 | ||||
| -rw-r--r-- | src/wixext/NetFxDecompiler.cs | 139 | ||||
| -rw-r--r-- | src/wixext/NetFxExtensionData.cs | 25 | ||||
| -rw-r--r-- | src/wixext/NetfxExtensionFactory.cs | 18 | ||||
| -rw-r--r-- | src/wixext/NetfxWindowsInstallerBackendExtension.cs | 27 | ||||
| -rw-r--r-- | src/wixext/Tuples/NetFxNativeImageTuple.cs | 65 | ||||
| -rw-r--r-- | src/wixext/Tuples/NetfxTupleDefinitions.cs | 27 | ||||
| -rw-r--r-- | src/wixext/WixToolset.Netfx.wixext.csproj | 35 | ||||
| -rw-r--r-- | src/wixext/WixToolset.Netfx.wixext.targets | 11 | ||||
| -rw-r--r-- | src/wixext/netfx.xsd | 235 |
10 files changed, 741 insertions, 0 deletions
diff --git a/src/wixext/NetFxCompiler.cs b/src/wixext/NetFxCompiler.cs new file mode 100644 index 00000000..55db4297 --- /dev/null +++ b/src/wixext/NetFxCompiler.cs | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Xml.Linq; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Extensibility; | ||
| 10 | |||
| 11 | /// <summary> | ||
| 12 | /// The compiler for the WiX Toolset .NET Framework Extension. | ||
| 13 | /// </summary> | ||
| 14 | public sealed class NetfxCompiler : BaseCompilerExtension | ||
| 15 | { | ||
| 16 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/netfx"; | ||
| 17 | |||
| 18 | /// <summary> | ||
| 19 | /// Processes an element for the Compiler. | ||
| 20 | /// </summary> | ||
| 21 | /// <param name="parentElement">Parent element of element to process.</param> | ||
| 22 | /// <param name="element">Element to process.</param> | ||
| 23 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | ||
| 24 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
| 25 | { | ||
| 26 | switch (parentElement.Name.LocalName) | ||
| 27 | { | ||
| 28 | case "File": | ||
| 29 | string fileId = context["FileId"]; | ||
| 30 | |||
| 31 | switch (element.Name.LocalName) | ||
| 32 | { | ||
| 33 | case "NativeImage": | ||
| 34 | this.ParseNativeImageElement(intermediate, section, element, fileId); | ||
| 35 | break; | ||
| 36 | default: | ||
| 37 | this.ParseHelper.UnexpectedElement(parentElement, element); | ||
| 38 | break; | ||
| 39 | } | ||
| 40 | break; | ||
| 41 | default: | ||
| 42 | this.ParseHelper.UnexpectedElement(parentElement, element); | ||
| 43 | break; | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | /// <summary> | ||
| 48 | /// Parses a NativeImage element. | ||
| 49 | /// </summary> | ||
| 50 | /// <param name="element">The element to parse.</param> | ||
| 51 | /// <param name="fileId">The file identifier of the parent element.</param> | ||
| 52 | private void ParseNativeImageElement(Intermediate intermediate, IntermediateSection section, XElement element, string fileId) | ||
| 53 | { | ||
| 54 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); | ||
| 55 | Identifier id = null; | ||
| 56 | string appBaseDirectory = null; | ||
| 57 | string assemblyApplication = null; | ||
| 58 | int attributes = 0x8; // 32bit is on by default | ||
| 59 | int priority = 3; | ||
| 60 | |||
| 61 | foreach (XAttribute attrib in element.Attributes()) | ||
| 62 | { | ||
| 63 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
| 64 | { | ||
| 65 | switch (attrib.Name.LocalName) | ||
| 66 | { | ||
| 67 | case "Id": | ||
| 68 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); | ||
| 69 | break; | ||
| 70 | case "AppBaseDirectory": | ||
| 71 | appBaseDirectory = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 72 | |||
| 73 | // See if a formatted value is specified. | ||
| 74 | if (-1 == appBaseDirectory.IndexOf("[", StringComparison.Ordinal)) | ||
| 75 | { | ||
| 76 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Directory", appBaseDirectory); | ||
| 77 | } | ||
| 78 | break; | ||
| 79 | case "AssemblyApplication": | ||
| 80 | assemblyApplication = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 81 | |||
| 82 | // See if a formatted value is specified. | ||
| 83 | if (-1 == assemblyApplication.IndexOf("[", StringComparison.Ordinal)) | ||
| 84 | { | ||
| 85 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", assemblyApplication); | ||
| 86 | } | ||
| 87 | break; | ||
| 88 | case "Debug": | ||
| 89 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
| 90 | { | ||
| 91 | attributes |= 0x1; | ||
| 92 | } | ||
| 93 | break; | ||
| 94 | case "Dependencies": | ||
| 95 | if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
| 96 | { | ||
| 97 | attributes |= 0x2; | ||
| 98 | } | ||
| 99 | break; | ||
| 100 | case "Platform": | ||
| 101 | string platformValue = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | ||
| 102 | if (0 < platformValue.Length) | ||
| 103 | { | ||
| 104 | switch (platformValue) | ||
| 105 | { | ||
| 106 | case "32bit": | ||
| 107 | // 0x8 is already on by default | ||
| 108 | break; | ||
| 109 | case "64bit": | ||
| 110 | attributes &= ~0x8; | ||
| 111 | attributes |= 0x10; | ||
| 112 | break; | ||
| 113 | case "all": | ||
| 114 | attributes |= 0x10; | ||
| 115 | break; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | break; | ||
| 119 | case "Priority": | ||
| 120 | priority = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 3); | ||
| 121 | break; | ||
| 122 | case "Profile": | ||
| 123 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
| 124 | { | ||
| 125 | attributes |= 0x4; | ||
| 126 | } | ||
| 127 | break; | ||
| 128 | default: | ||
| 129 | this.ParseHelper.UnexpectedAttribute(element, attrib); | ||
| 130 | break; | ||
| 131 | } | ||
| 132 | } | ||
| 133 | else | ||
| 134 | { | ||
| 135 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | if (null == id) | ||
| 140 | { | ||
| 141 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); | ||
| 142 | } | ||
| 143 | |||
| 144 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | ||
| 145 | |||
| 146 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "NetFxScheduleNativeImage"); | ||
| 147 | |||
| 148 | if (!this.Messaging.EncounteredError) | ||
| 149 | { | ||
| 150 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "NetFxNativeImage", id); | ||
| 151 | row.Set(1, fileId); | ||
| 152 | row.Set(2, priority); | ||
| 153 | row.Set(3, attributes); | ||
| 154 | row.Set(4, assemblyApplication); | ||
| 155 | row.Set(5, appBaseDirectory); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
diff --git a/src/wixext/NetFxDecompiler.cs b/src/wixext/NetFxDecompiler.cs new file mode 100644 index 00000000..e30905d1 --- /dev/null +++ b/src/wixext/NetFxDecompiler.cs | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensions | ||
| 4 | { | ||
| 5 | #if TODO_CONSIDER_DECOMPILER | ||
| 6 | using System; | ||
| 7 | using System.Collections; | ||
| 8 | using System.Diagnostics; | ||
| 9 | using System.Globalization; | ||
| 10 | using WixToolset.Data; | ||
| 11 | using WixToolset.Extensibility; | ||
| 12 | using NetFx = WixToolset.Extensions.Serialize.NetFx; | ||
| 13 | using Wix = WixToolset.Data.Serialize; | ||
| 14 | |||
| 15 | /// <summary> | ||
| 16 | /// The decompiler for the WiX Toolset .NET Framework Extension. | ||
| 17 | /// </summary> | ||
| 18 | public sealed class NetFxDecompiler : DecompilerExtension | ||
| 19 | { | ||
| 20 | /// <summary> | ||
| 21 | /// Creates a decompiler for NetFx Extension. | ||
| 22 | /// </summary> | ||
| 23 | public NetFxDecompiler() | ||
| 24 | { | ||
| 25 | this.TableDefinitions = NetFxExtensionData.GetExtensionTableDefinitions(); | ||
| 26 | } | ||
| 27 | |||
| 28 | /// <summary> | ||
| 29 | /// Get the extensions library to be removed. | ||
| 30 | /// </summary> | ||
| 31 | /// <param name="tableDefinitions">Table definitions for library.</param> | ||
| 32 | /// <returns>Library to remove from decompiled output.</returns> | ||
| 33 | public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) | ||
| 34 | { | ||
| 35 | return NetFxExtensionData.GetExtensionLibrary(tableDefinitions); | ||
| 36 | } | ||
| 37 | |||
| 38 | /// <summary> | ||
| 39 | /// Decompiles an extension table. | ||
| 40 | /// </summary> | ||
| 41 | /// <param name="table">The table to decompile.</param> | ||
| 42 | public override void DecompileTable(Table table) | ||
| 43 | { | ||
| 44 | switch (table.Name) | ||
| 45 | { | ||
| 46 | case "NetFxNativeImage": | ||
| 47 | this.DecompileNetFxNativeImageTable(table); | ||
| 48 | break; | ||
| 49 | default: | ||
| 50 | base.DecompileTable(table); | ||
| 51 | break; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | /// <summary> | ||
| 56 | /// Decompile the NetFxNativeImage table. | ||
| 57 | /// </summary> | ||
| 58 | /// <param name="table">The table to decompile.</param> | ||
| 59 | private void DecompileNetFxNativeImageTable(Table table) | ||
| 60 | { | ||
| 61 | foreach (Row row in table.Rows) | ||
| 62 | { | ||
| 63 | NetFx.NativeImage nativeImage = new NetFx.NativeImage(); | ||
| 64 | |||
| 65 | nativeImage.Id = (string)row[0]; | ||
| 66 | |||
| 67 | switch ((int)row[2]) | ||
| 68 | { | ||
| 69 | case 0: | ||
| 70 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item0; | ||
| 71 | break; | ||
| 72 | case 1: | ||
| 73 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item1; | ||
| 74 | break; | ||
| 75 | case 2: | ||
| 76 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item2; | ||
| 77 | break; | ||
| 78 | case 3: | ||
| 79 | nativeImage.Priority = NetFx.NativeImage.PriorityType.Item3; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | |||
| 83 | if (null != row[3]) | ||
| 84 | { | ||
| 85 | int attributes = (int)row[3]; | ||
| 86 | |||
| 87 | if (0x1 == (attributes & 0x1)) | ||
| 88 | { | ||
| 89 | nativeImage.Debug = NetFx.YesNoType.yes; | ||
| 90 | } | ||
| 91 | |||
| 92 | if (0x2 == (attributes & 0x2)) | ||
| 93 | { | ||
| 94 | nativeImage.Dependencies = NetFx.YesNoType.no; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (0x4 == (attributes & 0x4)) | ||
| 98 | { | ||
| 99 | nativeImage.Profile = NetFx.YesNoType.yes; | ||
| 100 | } | ||
| 101 | |||
| 102 | if (0x8 == (attributes & 0x8) && 0x10 == (attributes & 0x10)) | ||
| 103 | { | ||
| 104 | nativeImage.Platform = NetFx.NativeImage.PlatformType.all; | ||
| 105 | } | ||
| 106 | else if (0x8 == (attributes & 0x8)) | ||
| 107 | { | ||
| 108 | nativeImage.Platform = NetFx.NativeImage.PlatformType.Item32bit; | ||
| 109 | } | ||
| 110 | else if (0x10 == (attributes & 0x10)) | ||
| 111 | { | ||
| 112 | nativeImage.Platform = NetFx.NativeImage.PlatformType.Item64bit; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | if (null != row[4]) | ||
| 117 | { | ||
| 118 | nativeImage.AssemblyApplication = (string)row[4]; | ||
| 119 | } | ||
| 120 | |||
| 121 | if (null != row[5]) | ||
| 122 | { | ||
| 123 | nativeImage.AppBaseDirectory = (string)row[5]; | ||
| 124 | } | ||
| 125 | |||
| 126 | Wix.File file = (Wix.File)this.Core.GetIndexedElement("File", (string)row[1]); | ||
| 127 | if (null != file) | ||
| 128 | { | ||
| 129 | file.AddChild(nativeImage); | ||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "File_", (string)row[1], "File")); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | #endif | ||
| 139 | } | ||
diff --git a/src/wixext/NetFxExtensionData.cs b/src/wixext/NetFxExtensionData.cs new file mode 100644 index 00000000..b68741fd --- /dev/null +++ b/src/wixext/NetFxExtensionData.cs | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | using WixToolset.Extensibility; | ||
| 7 | using WixToolset.Netfx.Tuples; | ||
| 8 | |||
| 9 | /// <summary> | ||
| 10 | /// The WiX Toolset .NET Framework Extension. | ||
| 11 | /// </summary> | ||
| 12 | public sealed class NetfxExtensionData : BaseExtensionData | ||
| 13 | { | ||
| 14 | public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) | ||
| 15 | { | ||
| 16 | tupleDefinition = (name == NetfxTupleDefinitionNames.NetFxNativeImage) ? NetfxTupleDefinitions.NetFxNativeImage : null; | ||
| 17 | return tupleDefinition != null; | ||
| 18 | } | ||
| 19 | |||
| 20 | public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) | ||
| 21 | { | ||
| 22 | return Intermediate.Load(typeof(NetfxExtensionData).Assembly, "WixToolset.Netfx.netfx.wixlib", tupleDefinitions); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/src/wixext/NetfxExtensionFactory.cs b/src/wixext/NetfxExtensionFactory.cs new file mode 100644 index 00000000..756d1b2a --- /dev/null +++ b/src/wixext/NetfxExtensionFactory.cs | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using WixToolset.Extensibility; | ||
| 8 | |||
| 9 | public class NetfxExtensionFactory : BaseExtensionFactory | ||
| 10 | { | ||
| 11 | protected override IEnumerable<Type> ExtensionTypes => new[] | ||
| 12 | { | ||
| 13 | typeof(NetfxCompiler), | ||
| 14 | typeof(NetfxExtensionData), | ||
| 15 | typeof(NetfxWindowsInstallerBackendExtension), | ||
| 16 | }; | ||
| 17 | } | ||
| 18 | } | ||
diff --git a/src/wixext/NetfxWindowsInstallerBackendExtension.cs b/src/wixext/NetfxWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..50266ef4 --- /dev/null +++ b/src/wixext/NetfxWindowsInstallerBackendExtension.cs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx | ||
| 4 | { | ||
| 5 | using WixToolset.Data.WindowsInstaller; | ||
| 6 | using WixToolset.Extensibility; | ||
| 7 | |||
| 8 | public class NetfxWindowsInstallerBackendExtension : BaseWindowsInstallerBackendExtension | ||
| 9 | { | ||
| 10 | private static readonly TableDefinition[] Tables = new[] { | ||
| 11 | new TableDefinition( | ||
| 12 | "NetFxNativeImage", | ||
| 13 | new[] | ||
| 14 | { | ||
| 15 | new ColumnDefinition("NetFxNativeImage", ColumnType.String, 72, true, false, ColumnCategory.Identifier, description: "The primary key, a non-localized token."), | ||
| 16 | new ColumnDefinition("File_", ColumnType.String, 0, false, false, ColumnCategory.Identifier, keyTable:"File", keyColumn: 1, description: "The assembly for which a native image will be generated."), | ||
| 17 | new ColumnDefinition("Priority", ColumnType.Number, 2, false, false, ColumnCategory.Integer, maxValue: 3, description: "The priority for generating this native image: 0 is syncronous, 1-3 represent various levels of queued generation."), | ||
| 18 | new ColumnDefinition("Attributes", ColumnType.Number, 4, false, false, ColumnCategory.Integer, maxValue: 2147483647, description: "Integer containing bit flags representing native image attributes."), | ||
| 19 | new ColumnDefinition("File_Application", ColumnType.String, 72, false, true, ColumnCategory.Formatted, description: "The application which loads this assembly."), | ||
| 20 | new ColumnDefinition("Directory_ApplicationBase", ColumnType.String, 72, false, true, ColumnCategory.Formatted, description: "The directory containing the application which loads this assembly."), | ||
| 21 | } | ||
| 22 | ), | ||
| 23 | }; | ||
| 24 | |||
| 25 | protected override TableDefinition[] TableDefinitionsForTuples => Tables; | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/src/wixext/Tuples/NetFxNativeImageTuple.cs b/src/wixext/Tuples/NetFxNativeImageTuple.cs new file mode 100644 index 00000000..af507137 --- /dev/null +++ b/src/wixext/Tuples/NetFxNativeImageTuple.cs | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx.Tuples | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | |||
| 7 | public enum NetFxNativeImageTupleFields | ||
| 8 | { | ||
| 9 | NetFxNativeImage, | ||
| 10 | File_, | ||
| 11 | Priority, | ||
| 12 | Attributes, | ||
| 13 | File_Application, | ||
| 14 | Directory_ApplicationBase, | ||
| 15 | } | ||
| 16 | |||
| 17 | public class NetFxNativeImageTuple : IntermediateTuple | ||
| 18 | { | ||
| 19 | public NetFxNativeImageTuple() : base(NetfxTupleDefinitions.NetFxNativeImage, null, null) | ||
| 20 | { | ||
| 21 | } | ||
| 22 | |||
| 23 | public NetFxNativeImageTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(NetfxTupleDefinitions.NetFxNativeImage, sourceLineNumber, id) | ||
| 24 | { | ||
| 25 | } | ||
| 26 | |||
| 27 | public IntermediateField this[NetFxNativeImageTupleFields index] => this.Fields[(int)index]; | ||
| 28 | |||
| 29 | public string NetFxNativeImage | ||
| 30 | { | ||
| 31 | get => this.Fields[(int)NetFxNativeImageTupleFields.NetFxNativeImage].AsString(); | ||
| 32 | set => this.Set((int)NetFxNativeImageTupleFields.NetFxNativeImage, value); | ||
| 33 | } | ||
| 34 | |||
| 35 | public string File_ | ||
| 36 | { | ||
| 37 | get => this.Fields[(int)NetFxNativeImageTupleFields.File_].AsString(); | ||
| 38 | set => this.Set((int)NetFxNativeImageTupleFields.File_, value); | ||
| 39 | } | ||
| 40 | |||
| 41 | public int Priority | ||
| 42 | { | ||
| 43 | get => this.Fields[(int)NetFxNativeImageTupleFields.Priority].AsNumber(); | ||
| 44 | set => this.Set((int)NetFxNativeImageTupleFields.Priority, value); | ||
| 45 | } | ||
| 46 | |||
| 47 | public int Attributes | ||
| 48 | { | ||
| 49 | get => this.Fields[(int)NetFxNativeImageTupleFields.Attributes].AsNumber(); | ||
| 50 | set => this.Set((int)NetFxNativeImageTupleFields.Attributes, value); | ||
| 51 | } | ||
| 52 | |||
| 53 | public string File_Application | ||
| 54 | { | ||
| 55 | get => this.Fields[(int)NetFxNativeImageTupleFields.File_Application].AsString(); | ||
| 56 | set => this.Set((int)NetFxNativeImageTupleFields.File_Application, value); | ||
| 57 | } | ||
| 58 | |||
| 59 | public string Directory_ApplicationBase | ||
| 60 | { | ||
| 61 | get => this.Fields[(int)NetFxNativeImageTupleFields.Directory_ApplicationBase].AsString(); | ||
| 62 | set => this.Set((int)NetFxNativeImageTupleFields.Directory_ApplicationBase, value); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } \ No newline at end of file | ||
diff --git a/src/wixext/Tuples/NetfxTupleDefinitions.cs b/src/wixext/Tuples/NetfxTupleDefinitions.cs new file mode 100644 index 00000000..aa584b38 --- /dev/null +++ b/src/wixext/Tuples/NetfxTupleDefinitions.cs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | namespace WixToolset.Netfx.Tuples | ||
| 4 | { | ||
| 5 | using WixToolset.Data; | ||
| 6 | |||
| 7 | public static class NetfxTupleDefinitionNames | ||
| 8 | { | ||
| 9 | public static string NetFxNativeImage { get; } = "NetFxNativeImage"; | ||
| 10 | } | ||
| 11 | |||
| 12 | public static class NetfxTupleDefinitions | ||
| 13 | { | ||
| 14 | public static readonly IntermediateTupleDefinition NetFxNativeImage = new IntermediateTupleDefinition( | ||
| 15 | NetfxTupleDefinitionNames.NetFxNativeImage, | ||
| 16 | new[] | ||
| 17 | { | ||
| 18 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.NetFxNativeImage), IntermediateFieldType.String), | ||
| 19 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.File_), IntermediateFieldType.String), | ||
| 20 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.Priority), IntermediateFieldType.Number), | ||
| 21 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.Attributes), IntermediateFieldType.Number), | ||
| 22 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.File_Application), IntermediateFieldType.String), | ||
| 23 | new IntermediateFieldDefinition(nameof(NetFxNativeImageTupleFields.Directory_ApplicationBase), IntermediateFieldType.String), | ||
| 24 | }, | ||
| 25 | typeof(NetFxNativeImageTuple)); | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/src/wixext/WixToolset.Netfx.wixext.csproj b/src/wixext/WixToolset.Netfx.wixext.csproj new file mode 100644 index 00000000..d925e348 --- /dev/null +++ b/src/wixext/WixToolset.Netfx.wixext.csproj | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>netstandard2.0</TargetFramework> | ||
| 7 | <RootNamespace>WixToolset.Netfx</RootNamespace> | ||
| 8 | <Description>WiX Toolset .NET Framework Extension</Description> | ||
| 9 | <Title>WiX Toolset .NET Framework Extension</Title> | ||
| 10 | <IsTool>true</IsTool> | ||
| 11 | <ContentTargetFolders>build</ContentTargetFolders> | ||
| 12 | </PropertyGroup> | ||
| 13 | |||
| 14 | <ItemGroup> | ||
| 15 | <Content Include="$(MSBuildThisFileName).targets" /> | ||
| 16 | <Content Include="netfx.xsd" PackagePath="tools" /> | ||
| 17 | <EmbeddedResource Include="$(OutputPath)..\netfx.wixlib" /> | ||
| 18 | </ItemGroup> | ||
| 19 | |||
| 20 | <ItemGroup> | ||
| 21 | <ProjectReference Include="$(WixToolsetRootFolder)\Data\src\WixToolset.Data\WixToolset.Data.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Data\README.md') " /> | ||
| 22 | <PackageReference Include="WixToolset.Data" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Data\README.md') " PrivateAssets="all" /> | ||
| 23 | |||
| 24 | <ProjectReference Include="$(WixToolsetRootFolder)\Extensibility\src\WixToolset.Extensibility\WixToolset.Extensibility.csproj" Condition=" '$(Configuration)' == 'Debug' And Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " /> | ||
| 25 | <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" Condition=" '$(Configuration)' == 'Release' Or !Exists('$(WixToolsetRootFolder)\Extensibility\README.md') " PrivateAssets="all" /> | ||
| 26 | </ItemGroup> | ||
| 27 | |||
| 28 | <ItemGroup> | ||
| 29 | <ProjectReference Include="..\wixlib\netfx.wixproj" ReferenceOutputAssembly="false" /> | ||
| 30 | </ItemGroup> | ||
| 31 | |||
| 32 | <ItemGroup> | ||
| 33 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.7" PrivateAssets="all" /> | ||
| 34 | </ItemGroup> | ||
| 35 | </Project> | ||
diff --git a/src/wixext/WixToolset.Netfx.wixext.targets b/src/wixext/WixToolset.Netfx.wixext.targets new file mode 100644 index 00000000..17312abf --- /dev/null +++ b/src/wixext/WixToolset.Netfx.wixext.targets | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <WixToolsetNetfxWixextPath Condition=" '$(WixToolsetNetfxWixextPath)' == '' ">$(MSBuildThisFileDirectory)..\tools\WixToolset.Netfx.wixext.dll"</WixToolsetNetfxWixextPath> | ||
| 7 | </PropertyGroup> | ||
| 8 | <ItemGroup> | ||
| 9 | <WixExtension Include="$(WixToolsetNetfxWixextPath)" /> | ||
| 10 | </ItemGroup> | ||
| 11 | </Project> | ||
diff --git a/src/wixext/netfx.xsd b/src/wixext/netfx.xsd new file mode 100644 index 00000000..6ef4e9b6 --- /dev/null +++ b/src/wixext/netfx.xsd | |||
| @@ -0,0 +1,235 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | |||
| 5 | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
| 6 | xmlns:xse=" http://wixtoolset.org/schemas/XmlSchemaExtension" | ||
| 7 | xmlns:html="http://www.w3.org/1999/xhtml" | ||
| 8 | targetNamespace="http://wixtoolset.org/schemas/v4/wxs/netfx" | ||
| 9 | xmlns="http://wixtoolset.org/schemas/v4/wxs/netfx"> | ||
| 10 | <xs:annotation> | ||
| 11 | <xs:documentation> | ||
| 12 | The source code schema for the WiX Toolset .NET Framework Extension. | ||
| 13 | </xs:documentation> | ||
| 14 | </xs:annotation> | ||
| 15 | |||
| 16 | <xs:element name="NativeImage"> | ||
| 17 | <xs:annotation> | ||
| 18 | <xs:documentation> | ||
| 19 | Improves the performance of managed applications by creating native images. | ||
| 20 | Requires the .NET Framework 2.0 or newer to be installed on the target machine since | ||
| 21 | it runs <html:a href="http://msdn.microsoft.com/en-us/library/6t9t5wcf.aspx">NGen</html:a>. | ||
| 22 | </xs:documentation> | ||
| 23 | <xs:appinfo> | ||
| 24 | <xse:parent namespace="http://wixtoolset.org/schemas/v4/wxs" ref="File" /> | ||
| 25 | <xse:remarks> | ||
| 26 | <html:p> | ||
| 27 | Native images are files containing compiled processor-specific machine code, which | ||
| 28 | are installed into the native image cache on the local computer. The runtime | ||
| 29 | can use native images from the cache instead using the just-in-time (JIT) | ||
| 30 | compiler to compile the original assembly. | ||
| 31 | </html:p> | ||
| 32 | <html:p> | ||
| 33 | The native image custom actions are configured to ignore failures so that failing | ||
| 34 | to generate or remove a native image will not cause setup to fail and roll back. | ||
| 35 | </html:p> | ||
| 36 | <html:p> | ||
| 37 | <html:b>Note for patches:</html:b> if you built your target, or baseline, MSI with | ||
| 38 | previous versions 3.0 or 3.5 of this extension and want to upgrade to formattable | ||
| 39 | values for @AssemblyApplication or @AppBaseDirectory you must also include a | ||
| 40 | BinaryRef to "NetFxCA" to pull in necessary changes. If you do use formattable | ||
| 41 | values and do not include the binary changes ngen.exe will not optimize your | ||
| 42 | native images for the specified application. | ||
| 43 | </html:p> | ||
| 44 | <html:p> | ||
| 45 | This should be a rare occurrence, however. Because you cannot remove components | ||
| 46 | in a patch - and pyro does validate you do not - it is not practical to switch | ||
| 47 | from using identifiers to formattable values in a patch. One practical possibility | ||
| 48 | is if you wanted to use a different application to optimize your native images | ||
| 49 | and that application is not already installed with the MSI to be updated. | ||
| 50 | </html:p> | ||
| 51 | </xse:remarks> | ||
| 52 | </xs:appinfo> | ||
| 53 | </xs:annotation> | ||
| 54 | <xs:complexType> | ||
| 55 | <xs:attribute name="Id" type="xs:string" use="required"> | ||
| 56 | <xs:annotation> | ||
| 57 | <xs:documentation> | ||
| 58 | The identifier for this NativeImage. | ||
| 59 | </xs:documentation> | ||
| 60 | </xs:annotation> | ||
| 61 | </xs:attribute> | ||
| 62 | <xs:attribute name="AppBaseDirectory" type="xs:string"> | ||
| 63 | <xs:annotation> | ||
| 64 | <xs:documentation> | ||
| 65 | <html:p> | ||
| 66 | The directory to use for locating dependent assemblies. | ||
| 67 | For DLL assemblies and assemblies installed to the Global Assembly Cache (GAC), | ||
| 68 | this attribute should be set to the directory of the application which loads this | ||
| 69 | assembly. For EXE assemblies, this attribute does not need to be set because NGen | ||
| 70 | will use the directory of the assembly file by default. | ||
| 71 | </html:p> | ||
| 72 | <html:p> | ||
| 73 | The value can be in the form of a directory identifier, or a formatted string | ||
| 74 | that resolves to either a directory identifier or a full path to a directory. | ||
| 75 | </html:p> | ||
| 76 | </xs:documentation> | ||
| 77 | </xs:annotation> | ||
| 78 | </xs:attribute> | ||
| 79 | <xs:attribute name="AssemblyApplication" type="xs:string"> | ||
| 80 | <xs:annotation> | ||
| 81 | <xs:documentation> | ||
| 82 | <html:p> | ||
| 83 | The application which will load this assembly. | ||
| 84 | For DLL assemblies which are loaded via reflection, this attribute should | ||
| 85 | be set to indicate the application which will load this assembly. | ||
| 86 | The configuration of the application (usually specified via an exe.config file) will be used | ||
| 87 | to determine how to resolve dependencies for this assembly. | ||
| 88 | </html:p> | ||
| 89 | <html:p> | ||
| 90 | The value can be in the form of a file identifier, or a formatted string | ||
| 91 | that resolves to either a file identifier or a full path to a file. | ||
| 92 | </html:p> | ||
| 93 | <html:p> | ||
| 94 | When a shared component is loaded at run time, using the Load method, the | ||
| 95 | application's configuration file determines the dependencies that are loaded | ||
| 96 | for the shared component — for example, the version of a dependency that is loaded. | ||
| 97 | This attribute gives guidance on which dependencies would be loaded at run time in order | ||
| 98 | to figure out which dependency assemblies will also need to have native images generated | ||
| 99 | (assuming the Dependency attribute is not set to "no"). | ||
| 100 | </html:p> | ||
| 101 | <html:p> | ||
| 102 | This attribute cannot be set if the AssemblyApplication attribute is set on the parent | ||
| 103 | File element (please note that these attributes both refer to the same application | ||
| 104 | assembly but do very different things: specifiying File/@AssemblyApplication will force | ||
| 105 | an assembly to install to a private location next to the indicated application, whereas | ||
| 106 | this AssemblyApplication attribute will be used to help resolve dependent assemblies | ||
| 107 | while generating native images for this assembly). | ||
| 108 | </html:p> | ||
| 109 | </xs:documentation> | ||
| 110 | </xs:annotation> | ||
| 111 | </xs:attribute> | ||
| 112 | <xs:attribute name="Debug" type="YesNoType"> | ||
| 113 | <xs:annotation> | ||
| 114 | <xs:documentation> | ||
| 115 | Set to "yes" to generate native images that can be used under a debugger. | ||
| 116 | The default value is "no". | ||
| 117 | </xs:documentation> | ||
| 118 | </xs:annotation> | ||
| 119 | </xs:attribute> | ||
| 120 | <xs:attribute name="Dependencies" type="YesNoType"> | ||
| 121 | <xs:annotation> | ||
| 122 | <xs:documentation> | ||
| 123 | Set to "no" to generate the minimum number of native images. | ||
| 124 | The default value is "yes". | ||
| 125 | </xs:documentation> | ||
| 126 | </xs:annotation> | ||
| 127 | </xs:attribute> | ||
| 128 | <xs:attribute name="Platform"> | ||
| 129 | <xs:annotation> | ||
| 130 | <xs:documentation> | ||
| 131 | Sets the platform(s) for which native images will be generated. | ||
| 132 | </xs:documentation> | ||
| 133 | </xs:annotation> | ||
| 134 | <xs:simpleType> | ||
| 135 | <xs:restriction base="xs:NMTOKEN"> | ||
| 136 | <xs:enumeration value="32bit"> | ||
| 137 | <xs:annotation> | ||
| 138 | <xs:documentation> | ||
| 139 | Attempt to generate native images only for the 32-bit version of the .NET Framework | ||
| 140 | on the target machine. If the 32-bit version of the .NET Framework 2.0 or newer is not | ||
| 141 | present on the target machine, native image custom actions will not be scheduled. | ||
| 142 | This is the default value. | ||
| 143 | </xs:documentation> | ||
| 144 | </xs:annotation> | ||
| 145 | </xs:enumeration> | ||
| 146 | <xs:enumeration value="64bit"> | ||
| 147 | <xs:annotation> | ||
| 148 | <xs:documentation> | ||
| 149 | Attempt to generate native images only for the 64-bit version of the .NET Framework | ||
| 150 | on the target machine. If a 64-bit version of the .NET Framework 2.0 or newer is not | ||
| 151 | present on the target machine, native image custom actions will not be scheduled. | ||
| 152 | </xs:documentation> | ||
| 153 | </xs:annotation> | ||
| 154 | </xs:enumeration> | ||
| 155 | <xs:enumeration value="all"> | ||
| 156 | <xs:annotation> | ||
| 157 | <xs:documentation> | ||
| 158 | Attempt to generate native images for the 32-bit and 64-bit versions of the .NET Framework | ||
| 159 | on the target machine. If a version of the .NET Framework 2.0 or newer is not present on the | ||
| 160 | target machine for a processor architecture, native image custom actions will not be | ||
| 161 | scheduled for that processor architecture. | ||
| 162 | </xs:documentation> | ||
| 163 | </xs:annotation> | ||
| 164 | </xs:enumeration> | ||
| 165 | </xs:restriction> | ||
| 166 | </xs:simpleType> | ||
| 167 | </xs:attribute> | ||
| 168 | <xs:attribute name="Priority"> | ||
| 169 | <xs:annotation> | ||
| 170 | <xs:documentation> | ||
| 171 | Sets the priority of generating the native images for this assembly. | ||
| 172 | </xs:documentation> | ||
| 173 | </xs:annotation> | ||
| 174 | <xs:simpleType> | ||
| 175 | <xs:restriction base="xs:NMTOKEN"> | ||
| 176 | <xs:enumeration value="0"> | ||
| 177 | <xs:annotation> | ||
| 178 | <xs:documentation> | ||
| 179 | This is the highest priority, it means that image generation occurs syncronously | ||
| 180 | during the setup process. This option will slow down setup performance. | ||
| 181 | </xs:documentation> | ||
| 182 | </xs:annotation> | ||
| 183 | </xs:enumeration> | ||
| 184 | <xs:enumeration value="1"> | ||
| 185 | <xs:annotation> | ||
| 186 | <xs:documentation> | ||
| 187 | This will queue image generation to the NGen service to occur immediately. | ||
| 188 | This option will slow down setup performance. | ||
| 189 | </xs:documentation> | ||
| 190 | </xs:annotation> | ||
| 191 | </xs:enumeration> | ||
| 192 | <xs:enumeration value="2"> | ||
| 193 | <xs:annotation> | ||
| 194 | <xs:documentation> | ||
| 195 | This will queue image generation to the NGen service to occur after all priority 1 | ||
| 196 | assemblies have completed. | ||
| 197 | This option will slow down setup performance. | ||
| 198 | </xs:documentation> | ||
| 199 | </xs:annotation> | ||
| 200 | </xs:enumeration> | ||
| 201 | <xs:enumeration value="3"> | ||
| 202 | <xs:annotation> | ||
| 203 | <xs:documentation> | ||
| 204 | This is the lowest priority, it will queue image generation to occur when the | ||
| 205 | machine is idle. | ||
| 206 | This option should not slow down setup performance. | ||
| 207 | This is the default value. | ||
| 208 | </xs:documentation> | ||
| 209 | </xs:annotation> | ||
| 210 | </xs:enumeration> | ||
| 211 | </xs:restriction> | ||
| 212 | </xs:simpleType> | ||
| 213 | </xs:attribute> | ||
| 214 | <xs:attribute name="Profile" type="YesNoType"> | ||
| 215 | <xs:annotation> | ||
| 216 | <xs:documentation> | ||
| 217 | Set to "yes" to generate native images that can be used under a profiler. | ||
| 218 | The default value is "no". | ||
| 219 | </xs:documentation> | ||
| 220 | </xs:annotation> | ||
| 221 | </xs:attribute> | ||
| 222 | </xs:complexType> | ||
| 223 | </xs:element> | ||
| 224 | |||
| 225 | <xs:simpleType name="YesNoType"> | ||
| 226 | <xs:annotation> | ||
| 227 | <xs:documentation>Values of this type will either be "yes" or "no".</xs:documentation> | ||
| 228 | </xs:annotation> | ||
| 229 | <xs:restriction base='xs:NMTOKEN'> | ||
| 230 | <xs:enumeration value="no"/> | ||
| 231 | <xs:enumeration value="yes"/> | ||
| 232 | </xs:restriction> | ||
| 233 | </xs:simpleType> | ||
| 234 | |||
| 235 | </xs:schema> | ||
