aboutsummaryrefslogtreecommitdiff
path: root/src/wixext
diff options
context:
space:
mode:
Diffstat (limited to 'src/wixext')
-rw-r--r--src/wixext/PSCompiler.cs106
-rw-r--r--src/wixext/PSErrors.cs30
-rw-r--r--src/wixext/PSExtensionData.cs26
-rw-r--r--src/wixext/PSWarnings.cs30
-rw-r--r--src/wixext/PowerShellExtensionFactory.cs17
-rw-r--r--src/wixext/WixPSExtension.csproj43
-rw-r--r--src/wixext/WixToolset.PowerShell.wixext.csproj29
-rw-r--r--src/wixext/WixToolset.PowerShell.wixext.targets11
-rw-r--r--src/wixext/messages.xml20
9 files changed, 178 insertions, 134 deletions
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 @@
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. 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 2
3namespace WixToolset.Extensions 3namespace WixToolset.PowerShell
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Globalization; 7 using System.Globalization;
8 using System.Xml.Linq; 8 using System.Xml.Linq;
9 using WixToolset.Data; 9 using WixToolset.Data;
10 using WixToolset.Data.Rows; 10 using WixToolset.Data.Tuples;
11 using WixToolset.Extensibility; 11 using WixToolset.Extensibility;
12 12
13 /// <summary> 13 /// <summary>
14 /// The compiler for the WiX Toolset Internet Information Services Extension. 14 /// The compiler for the WiX Toolset PowerShell Extension.
15 /// </summary> 15 /// </summary>
16 public sealed class PSCompiler : CompilerExtension 16 public sealed class PSCompiler : BaseCompilerExtension
17 { 17 {
18 private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}"; 18 private const string KeyFormat = @"SOFTWARE\Microsoft\PowerShell\{0}\PowerShellSnapIns\{1}";
19 private const string VarPrefix = "PSVersionMajor"; 19 private const string VarPrefix = "PSVersionMajor";
20 20
21 /// <summary> 21 public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/powershell";
22 /// Instantiate a new PSCompiler.
23 /// </summary>
24 public PSCompiler()
25 {
26 this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/powershell";
27 }
28 22
29 /// <summary> 23 /// <summary>
30 /// Processes an element for the Compiler. 24 /// Processes an element for the Compiler.
@@ -33,7 +27,7 @@ namespace WixToolset.Extensions
33 /// <param name="parentElement">Parent element of element to process.</param> 27 /// <param name="parentElement">Parent element of element to process.</param>
34 /// <param name="element">Element to process.</param> 28 /// <param name="element">Element to process.</param>
35 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> 29 /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param>
36 public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) 30 public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context)
37 { 31 {
38 switch (parentElement.Name.LocalName) 32 switch (parentElement.Name.LocalName)
39 { 33 {
@@ -44,25 +38,25 @@ namespace WixToolset.Extensions
44 switch (element.Name.LocalName) 38 switch (element.Name.LocalName)
45 { 39 {
46 case "FormatsFile": 40 case "FormatsFile":
47 this.ParseExtensionsFile(element, "Formats", fileId, componentId); 41 this.ParseExtensionsFile(intermediate, section, element, "Formats", fileId, componentId);
48 break; 42 break;
49 43
50 case "SnapIn": 44 case "SnapIn":
51 this.ParseSnapInElement(element, fileId, componentId); 45 this.ParseSnapInElement(intermediate, section, element, fileId, componentId);
52 break; 46 break;
53 47
54 case "TypesFile": 48 case "TypesFile":
55 this.ParseExtensionsFile(element, "Types", fileId, componentId); 49 this.ParseExtensionsFile(intermediate, section, element, "Types", fileId, componentId);
56 break; 50 break;
57 51
58 default: 52 default:
59 this.Core.UnexpectedElement(parentElement, element); 53 this.ParseHelper.UnexpectedElement(parentElement, element);
60 break; 54 break;
61 } 55 }
62 break; 56 break;
63 57
64 default: 58 default:
65 this.Core.UnexpectedElement(parentElement, element); 59 this.ParseHelper.UnexpectedElement(parentElement, element);
66 break; 60 break;
67 } 61 }
68 } 62 }
@@ -73,9 +67,9 @@ namespace WixToolset.Extensions
73 /// <param name="node">Element to parse.</param> 67 /// <param name="node">Element to parse.</param>
74 /// <param name="fileId">Identifier for parent file.</param> 68 /// <param name="fileId">Identifier for parent file.</param>
75 /// <param name="componentId">Identifier for parent component.</param> 69 /// <param name="componentId">Identifier for parent component.</param>
76 private void ParseSnapInElement(XElement node, string fileId, string componentId) 70 private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId)
77 { 71 {
78 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 72 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
79 string id = null; 73 string id = null;
80 string assemblyName = null; 74 string assemblyName = null;
81 string customSnapInType = null; 75 string customSnapInType = null;
@@ -93,52 +87,52 @@ namespace WixToolset.Extensions
93 switch (attrib.Name.LocalName) 87 switch (attrib.Name.LocalName)
94 { 88 {
95 case "Id": 89 case "Id":
96 id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); 90 id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
97 break; 91 break;
98 92
99 case "CustomSnapInType": 93 case "CustomSnapInType":
100 customSnapInType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 94 customSnapInType = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
101 break; 95 break;
102 96
103 case "Description": 97 case "Description":
104 description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 98 description = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
105 break; 99 break;
106 100
107 case "DescriptionIndirect": 101 case "DescriptionIndirect":
108 descriptionIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 102 descriptionIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
109 break; 103 break;
110 104
111 case "RequiredPowerShellVersion": 105 case "RequiredPowerShellVersion":
112 string ver = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); 106 string ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib);
113 requiredPowerShellVersion = new Version(ver); 107 requiredPowerShellVersion = new Version(ver);
114 break; 108 break;
115 109
116 case "Vendor": 110 case "Vendor":
117 vendor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 111 vendor = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
118 break; 112 break;
119 113
120 case "VendorIndirect": 114 case "VendorIndirect":
121 vendorIndirect = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 115 vendorIndirect = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
122 break; 116 break;
123 117
124 case "Version": 118 case "Version":
125 version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); 119 version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib);
126 break; 120 break;
127 121
128 default: 122 default:
129 this.Core.UnexpectedAttribute(node, attrib); 123 this.ParseHelper.UnexpectedAttribute(node, attrib);
130 break; 124 break;
131 } 125 }
132 } 126 }
133 else 127 else
134 { 128 {
135 this.Core.ParseExtensionAttribute(node, attrib); 129 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
136 } 130 }
137 } 131 }
138 132
139 if (null == id) 133 if (null == id)
140 { 134 {
141 this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); 135 this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
142 } 136 }
143 137
144 // Default to require PowerShell 1.0. 138 // Default to require PowerShell 1.0.
@@ -161,19 +155,19 @@ namespace WixToolset.Extensions
161 switch (child.Name.LocalName) 155 switch (child.Name.LocalName)
162 { 156 {
163 case "FormatsFile": 157 case "FormatsFile":
164 this.ParseExtensionsFile(child, "Formats", id, componentId); 158 this.ParseExtensionsFile(intermediate, section, child, "Formats", id, componentId);
165 break; 159 break;
166 case "TypesFile": 160 case "TypesFile":
167 this.ParseExtensionsFile(child, "Types", id, componentId); 161 this.ParseExtensionsFile(intermediate, section, child, "Types", id, componentId);
168 break; 162 break;
169 default: 163 default:
170 this.Core.UnexpectedElement(node, child); 164 this.ParseHelper.UnexpectedElement(node, child);
171 break; 165 break;
172 } 166 }
173 } 167 }
174 else 168 else
175 { 169 {
176 this.Core.ParseExtensionElement(node, child); 170 this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child);
177 } 171 }
178 } 172 }
179 173
@@ -182,54 +176,54 @@ namespace WixToolset.Extensions
182 // for use in Formats and Types files. PowerShell v2 still uses 1. 176 // for use in Formats and Types files. PowerShell v2 still uses 1.
183 int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; 177 int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major;
184 178
185 WixVariableRow wixVariableRow = (WixVariableRow)this.Core.CreateRow(sourceLineNumbers, "WixVariable"); 179 var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id));
186 wixVariableRow.Id = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id); 180 var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable", variableId);
187 wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); 181 wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture);
188 wixVariableRow.Overridable = false; 182 wixVariableRow.Overridable = false;
189 183
190 int registryRoot = 2; // HKLM 184 int registryRoot = 2; // HKLM
191 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); 185 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id);
192 186
193 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); 187 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false);
194 188
195 // set the assembly name automatically when binding. 189 // set the assembly name automatically when binding.
196 // processorArchitecture is not handled correctly by PowerShell v1.0 190 // processorArchitecture is not handled correctly by PowerShell v1.0
197 // so format the assembly name explicitly. 191 // so format the assembly name explicitly.
198 assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); 192 assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId);
199 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); 193 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false);
200 194
201 if (null != customSnapInType) 195 if (null != customSnapInType)
202 { 196 {
203 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); 197 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false);
204 } 198 }
205 199
206 if (null != description) 200 if (null != description)
207 { 201 {
208 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); 202 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false);
209 } 203 }
210 204
211 if (null != descriptionIndirect) 205 if (null != descriptionIndirect)
212 { 206 {
213 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); 207 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false);
214 } 208 }
215 209
216 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); 210 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false);
217 211
218 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); 212 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false);
219 213
220 if (null != vendor) 214 if (null != vendor)
221 { 215 {
222 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); 216 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false);
223 } 217 }
224 218
225 if (null != vendorIndirect) 219 if (null != vendorIndirect)
226 { 220 {
227 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); 221 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false);
228 } 222 }
229 223
230 if (null != version) 224 if (null != version)
231 { 225 {
232 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); 226 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false);
233 } 227 }
234 } 228 }
235 229
@@ -240,9 +234,9 @@ namespace WixToolset.Extensions
240 /// <param name="valueName">Registry value name.</param> 234 /// <param name="valueName">Registry value name.</param>
241 /// <param name="id">Idendifier for parent file or snap-in.</param> 235 /// <param name="id">Idendifier for parent file or snap-in.</param>
242 /// <param name="componentId">Identifier for parent component.</param> 236 /// <param name="componentId">Identifier for parent component.</param>
243 private void ParseExtensionsFile(XElement node, string valueName, string id, string componentId) 237 private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId)
244 { 238 {
245 SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); 239 SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node);
246 string fileId = null; 240 string fileId = null;
247 string snapIn = null; 241 string snapIn = null;
248 242
@@ -253,38 +247,38 @@ namespace WixToolset.Extensions
253 switch (attrib.Name.LocalName) 247 switch (attrib.Name.LocalName)
254 { 248 {
255 case "FileId": 249 case "FileId":
256 fileId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 250 fileId = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
257 snapIn = id; 251 snapIn = id;
258 break; 252 break;
259 253
260 case "SnapIn": 254 case "SnapIn":
261 fileId = id; 255 fileId = id;
262 snapIn = this.Core.GetAttributeValue(sourceLineNumbers, attrib); 256 snapIn = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib);
263 break; 257 break;
264 258
265 default: 259 default:
266 this.Core.UnexpectedAttribute(node, attrib); 260 this.ParseHelper.UnexpectedAttribute(node, attrib);
267 break; 261 break;
268 } 262 }
269 } 263 }
270 else 264 else
271 { 265 {
272 this.Core.ParseExtensionAttribute(node, attrib); 266 this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib);
273 } 267 }
274 } 268 }
275 269
276 if (null == fileId && null == snapIn) 270 if (null == fileId && null == snapIn)
277 { 271 {
278 this.Core.OnMessage(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName)); 272 this.Messaging.Write(PSErrors.NeitherIdSpecified(sourceLineNumbers, valueName));
279 } 273 }
280 274
281 this.Core.ParseForExtensionElements(node); 275 this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node);
282 276
283 int registryRoot = 2; // HKLM 277 int registryRoot = 2; // HKLM
284 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); 278 string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn);
285 279
286 this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); 280 this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId);
287 this.Core.CreateRegistryRow(sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); 281 this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false);
288 } 282 }
289 } 283 }
290} 284}
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 @@
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
3namespace WixToolset.PowerShell
4{
5 using System.Resources;
6 using WixToolset.Data;
7
8 public static class PSErrors
9 {
10 public static Message NeitherIdSpecified(SourceLineNumber sourceLineNumbers, string element)
11 {
12 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);
13 }
14
15 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
16 {
17 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
18 }
19
20 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
21 {
22 return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args);
23 }
24
25 public enum Ids
26 {
27 NeitherIdSpecified = 5301,
28 }
29 }
30}
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 @@
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. 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 2
3namespace WixToolset.Extensions 3namespace WixToolset.PowerShell
4{ 4{
5 using System;
6 using System.Reflection;
7 using WixToolset.Data; 5 using WixToolset.Data;
8 using WixToolset.Extensibility; 6 using WixToolset.Extensibility;
9 7
10 /// <summary> 8 /// <summary>
11 /// The WiX Toolset PowerShell Extension. 9 /// The WiX Toolset PowerShell Extension.
12 /// </summary> 10 /// </summary>
13 public sealed class PSExtensionData : ExtensionData 11 public sealed class PSExtensionData : BaseExtensionData
14 { 12 {
15 /// <summary> 13 /// <summary>
16 /// Gets the library associated with this extension. 14 /// Gets the default culture.
17 /// </summary> 15 /// </summary>
18 /// <param name="tableDefinitions">The table definitions to use while loading the library.</param> 16 /// <value>The default culture.</value>
19 /// <returns>The loaded library.</returns> 17 public override string DefaultCulture => "en-US";
20 public override Library GetLibrary(TableDefinitionCollection tableDefinitions) 18
19 public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition)
21 { 20 {
22 return PSExtensionData.GetExtensionLibrary(tableDefinitions); 21 tupleDefinition = null;
22 return tupleDefinition != null;
23 } 23 }
24 24
25 /// <summary> 25 public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions)
26 /// Internal mechanism to access the extension's library.
27 /// </summary>
28 /// <returns>Extension's library.</returns>
29 internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions)
30 { 26 {
31 return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.ps.wixlib", tableDefinitions); 27 return Intermediate.Load(typeof(PSExtensionData).Assembly, "WixToolset.PowerShell.powershell.wixlib", tupleDefinitions);
32 } 28 }
33 } 29 }
34} 30}
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 @@
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
3namespace WixToolset.PowerShell
4{
5 using System.Resources;
6 using WixToolset.Data;
7
8 public static class PSWarnings
9 {
10 public static Message DeprecatedAssemblyNameAttribute(SourceLineNumber sourceLineNumbers)
11 {
12 return Message(sourceLineNumbers, Ids.DeprecatedAssemblyNameAttribute, "The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically.");
13 }
14
15 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
16 {
17 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, format, args);
18 }
19
20 private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args)
21 {
22 return new Message(sourceLineNumber, MessageLevel.Warning, (int)id, resourceManager, resourceName, args);
23 }
24
25 public enum Ids
26 {
27 DeprecatedAssemblyNameAttribute = 5350,
28 }
29 }
30}
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 @@
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
3namespace WixToolset.PowerShell
4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Extensibility;
8
9 public class PowerShellExtensionFactory : BaseExtensionFactory
10 {
11 protected override IEnumerable<Type> ExtensionTypes => new[]
12 {
13 typeof(PSCompiler),
14 typeof(PSExtensionData),
15 };
16 }
17}
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 @@
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<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
6 <PropertyGroup>
7 <ProjectGuid>{6F1482DF-1598-4D88-BDAA-B9D0E0242139}</ProjectGuid>
8 <AssemblyName>WixPSExtension</AssemblyName>
9 <OutputType>Library</OutputType>
10 <RootNamespace>WixToolset.Extensions</RootNamespace>
11 </PropertyGroup>
12 <ItemGroup>
13 <Compile Include="AssemblyInfo.cs" />
14 <Compile Include="PSCompiler.cs" />
15 <Compile Include="PSExtensionData.cs" />
16 <MsgGenSource Include="Data\messages.xml">
17 <ResourcesLogicalName>$(RootNamespace).Data.Messages.resources</ResourcesLogicalName>
18 </MsgGenSource>
19 <EmbeddedFlattenedResource Include="Xsd\ps.xsd">
20 <LogicalName>$(RootNamespace).Xsd.ps.xsd</LogicalName>
21 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22 </EmbeddedFlattenedResource>
23 <XsdGenSource Include="Xsd\ps.xsd">
24 <CommonNamespace>WixToolset.Data.Serialize</CommonNamespace>
25 <Namespace>WixToolset.Extensions.Serialize.PS</Namespace>
26 </XsdGenSource>
27 <EmbeddedResource Include="$(OutputPath)\ps.wixlib">
28 <Link>Data\ps.wixlib</Link>
29 </EmbeddedResource>
30 </ItemGroup>
31 <ItemGroup>
32 <Reference Include="System" />
33 <Reference Include="System.Xml" />
34 <ProjectReference Include="..\..\..\libs\WixToolset.Data\WixToolset.Data.csproj" />
35 <ProjectReference Include="..\..\..\libs\WixToolset.Extensibility\WixToolset.Extensibility.csproj" />
36 <ProjectReference Include="..\..\..\tools\wix\Wix.csproj" />
37 <ProjectReference Include="..\wixlib\PSExtension.wixproj">
38 <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
39 </ProjectReference>
40 <Reference Include="System.Xml.Linq" />
41 </ItemGroup>
42 <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.targets" />
43</Project>
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 @@
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.PowerShell</RootNamespace>
8 <Description>WiX Toolset PowerShell Extension</Description>
9 <Title>WiX Toolset PowerShell Extension</Title>
10 <IsTool>true</IsTool>
11 <ContentTargetFolders>build</ContentTargetFolders>
12 </PropertyGroup>
13 <ItemGroup>
14 <Content Include="$(MSBuildThisFileName).targets" />
15 <Content Include="ps.xsd" PackagePath="tools" />
16 <EmbeddedResource Include="$(OutputPath)..\powershell.wixlib" />
17 </ItemGroup>
18 <ItemGroup>
19 <PackageReference Include="WixToolset.Extensibility" Version="4.0.*" PrivateAssets="all" />
20 </ItemGroup>
21
22 <ItemGroup>
23 <ProjectReference Include="..\wixlib\powershell.wixproj" ReferenceOutputAssembly="false" Condition=" '$(NCrunch)'=='' " />
24 </ItemGroup>
25
26 <ItemGroup>
27 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" />
28 </ItemGroup>
29</Project>
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 @@
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 <WixToolsetPowerShellWixextPath Condition=" '$(WixToolsetPowerShellWixextPath)' == '' ">$(MSBuildThisFileDirectory)..\tools\WixToolset.PowerShell.wixext.dll</WixToolsetPowerShellWixextPath>
7 </PropertyGroup>
8 <ItemGroup>
9 <WixExtension Include="$(WixToolsetPowerShellWixextPath)" />
10 </ItemGroup>
11</Project>
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 @@
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<Messages Namespace="WixToolset.Extensions" Resources="Data.Messages" xmlns="http://schemas.microsoft.com/genmsgs/2004/07/messages">
6 <Class Name="PSErrors" ContainerName="PSErrorEventArgs" BaseContainerName="WixErrorEventArgs">
7 <Message Id="NeitherIdSpecified" Number="5301">
8 <Instance>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.
9 <Parameter Type="System.String" Name="element" />
10 </Instance>
11 </Message>
12 </Class>
13 <Class Name="PSWarnings" ContainerName="PSWarningEventArgs" BaseContainerName="WixWarningEventArgs">
14 <Message Id="DeprecatedAssemblyNameAttribute" Number="5350">
15 <Instance>The SnapIn/@AssemblyName attribute is deprecated. It is assigned automatically.</Instance>
16 </Message>
17 </Class>
18 <Class Name="PSVerboses" ContainerName="PSVerboseEventArgs" BaseContainerName="WixVerboseEventArgs">
19 </Class>
20</Messages>