diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wixext/PSCompiler.cs | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/wixext/PSCompiler.cs b/src/wixext/PSCompiler.cs index 74e18bd7..2a384231 100644 --- a/src/wixext/PSCompiler.cs +++ b/src/wixext/PSCompiler.cs | |||
| @@ -32,8 +32,8 @@ namespace WixToolset.PowerShell | |||
| 32 | switch (parentElement.Name.LocalName) | 32 | switch (parentElement.Name.LocalName) |
| 33 | { | 33 | { |
| 34 | case "File": | 34 | case "File": |
| 35 | string fileId = context["FileId"]; | 35 | var fileId = context["FileId"]; |
| 36 | string componentId = context["ComponentId"]; | 36 | var componentId = context["ComponentId"]; |
| 37 | 37 | ||
| 38 | switch (element.Name.LocalName) | 38 | switch (element.Name.LocalName) |
| 39 | { | 39 | { |
| @@ -69,18 +69,17 @@ namespace WixToolset.PowerShell | |||
| 69 | /// <param name="componentId">Identifier for parent component.</param> | 69 | /// <param name="componentId">Identifier for parent component.</param> |
| 70 | private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) | 70 | private void ParseSnapInElement(Intermediate intermediate, IntermediateSection section, XElement node, string fileId, string componentId) |
| 71 | { | 71 | { |
| 72 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 72 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 73 | string id = null; | 73 | string id = null; |
| 74 | string assemblyName = null; | ||
| 75 | string customSnapInType = null; | 74 | string customSnapInType = null; |
| 76 | string description = null; | 75 | string description = null; |
| 77 | string descriptionIndirect = null; | 76 | string descriptionIndirect = null; |
| 78 | Version requiredPowerShellVersion = CompilerConstants.IllegalVersion; | 77 | var requiredPowerShellVersion = CompilerConstants.IllegalVersion; |
| 79 | string vendor = null; | 78 | string vendor = null; |
| 80 | string vendorIndirect = null; | 79 | string vendorIndirect = null; |
| 81 | string version = null; | 80 | string version = null; |
| 82 | 81 | ||
| 83 | foreach (XAttribute attrib in node.Attributes()) | 82 | foreach (var attrib in node.Attributes()) |
| 84 | { | 83 | { |
| 85 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 84 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 86 | { | 85 | { |
| @@ -103,7 +102,7 @@ namespace WixToolset.PowerShell | |||
| 103 | break; | 102 | break; |
| 104 | 103 | ||
| 105 | case "RequiredPowerShellVersion": | 104 | case "RequiredPowerShellVersion": |
| 106 | string ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); | 105 | var ver = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); |
| 107 | requiredPowerShellVersion = new Version(ver); | 106 | requiredPowerShellVersion = new Version(ver); |
| 108 | break; | 107 | break; |
| 109 | 108 | ||
| @@ -148,7 +147,7 @@ namespace WixToolset.PowerShell | |||
| 148 | version = String.Format("!(bind.assemblyVersion.{0})", fileId); | 147 | version = String.Format("!(bind.assemblyVersion.{0})", fileId); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | foreach (XElement child in node.Elements()) | 150 | foreach (var child in node.Elements()) |
| 152 | { | 151 | { |
| 153 | if (this.Namespace == child.Name.Namespace) | 152 | if (this.Namespace == child.Name.Namespace) |
| 154 | { | 153 | { |
| @@ -174,56 +173,58 @@ namespace WixToolset.PowerShell | |||
| 174 | // Get the major part of the required PowerShell version which is | 173 | // Get the major part of the required PowerShell version which is |
| 175 | // needed for the registry key, and put that into a WiX variable | 174 | // needed for the registry key, and put that into a WiX variable |
| 176 | // for use in Formats and Types files. PowerShell v2 still uses 1. | 175 | // for use in Formats and Types files. PowerShell v2 still uses 1. |
| 177 | int major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; | 176 | var major = (2 == requiredPowerShellVersion.Major) ? 1 : requiredPowerShellVersion.Major; |
| 178 | 177 | ||
| 179 | var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); | 178 | var variableId = new Identifier(AccessModifier.Public, String.Format(CultureInfo.InvariantCulture, "{0}_{1}", VarPrefix, id)); |
| 180 | var wixVariableRow = (WixVariableTuple)this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixVariable", variableId); | 179 | section.AddTuple(new WixVariableTuple(sourceLineNumbers, variableId) |
| 181 | wixVariableRow.Value = major.ToString(CultureInfo.InvariantCulture); | 180 | { |
| 182 | wixVariableRow.Overridable = false; | 181 | Value = major.ToString(CultureInfo.InvariantCulture), |
| 182 | Overridable = false, | ||
| 183 | }); | ||
| 183 | 184 | ||
| 184 | RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM | 185 | var registryRoot = RegistryRootType.LocalMachine; // HKLM |
| 185 | string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); | 186 | var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, major, id); |
| 186 | 187 | ||
| 187 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); | 188 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ApplicationBase", String.Format(CultureInfo.InvariantCulture, "[${0}]", componentId), componentId, false); |
| 188 | 189 | ||
| 189 | // set the assembly name automatically when binding. | 190 | // set the assembly name automatically when binding. |
| 190 | // processorArchitecture is not handled correctly by PowerShell v1.0 | 191 | // processorArchitecture is not handled correctly by PowerShell v1.0 |
| 191 | // so format the assembly name explicitly. | 192 | // so format the assembly name explicitly. |
| 192 | assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); | 193 | var assemblyName = String.Format(CultureInfo.InvariantCulture, "!(bind.assemblyName.{0}), Version=!(bind.assemblyVersion.{0}), Culture=!(bind.assemblyCulture.{0}), PublicKeyToken=!(bind.assemblyPublicKeyToken.{0})", fileId); |
| 193 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); | 194 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "AssemblyName", assemblyName, componentId, false); |
| 194 | 195 | ||
| 195 | if (null != customSnapInType) | 196 | if (null != customSnapInType) |
| 196 | { | 197 | { |
| 197 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); | 198 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "CustomPSSnapInType", customSnapInType, componentId, false); |
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | if (null != description) | 201 | if (null != description) |
| 201 | { | 202 | { |
| 202 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); | 203 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Description", description, componentId, false); |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | if (null != descriptionIndirect) | 206 | if (null != descriptionIndirect) |
| 206 | { | 207 | { |
| 207 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); | 208 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "DescriptionIndirect", descriptionIndirect, componentId, false); |
| 208 | } | 209 | } |
| 209 | 210 | ||
| 210 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); | 211 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "ModuleName", String.Format(CultureInfo.InvariantCulture, "[#{0}]", fileId), componentId, false); |
| 211 | 212 | ||
| 212 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); | 213 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "PowerShellVersion", requiredPowerShellVersion.ToString(2), componentId, false); |
| 213 | 214 | ||
| 214 | if (null != vendor) | 215 | if (null != vendor) |
| 215 | { | 216 | { |
| 216 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); | 217 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Vendor", vendor, componentId, false); |
| 217 | } | 218 | } |
| 218 | 219 | ||
| 219 | if (null != vendorIndirect) | 220 | if (null != vendorIndirect) |
| 220 | { | 221 | { |
| 221 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); | 222 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "VendorIndirect", vendorIndirect, componentId, false); |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | if (null != version) | 225 | if (null != version) |
| 225 | { | 226 | { |
| 226 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); | 227 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, "Version", version, componentId, false); |
| 227 | } | 228 | } |
| 228 | } | 229 | } |
| 229 | 230 | ||
| @@ -236,11 +237,11 @@ namespace WixToolset.PowerShell | |||
| 236 | /// <param name="componentId">Identifier for parent component.</param> | 237 | /// <param name="componentId">Identifier for parent component.</param> |
| 237 | private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) | 238 | private void ParseExtensionsFile(Intermediate intermediate, IntermediateSection section, XElement node, string valueName, string id, string componentId) |
| 238 | { | 239 | { |
| 239 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | 240 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
| 240 | string fileId = null; | 241 | string fileId = null; |
| 241 | string snapIn = null; | 242 | string snapIn = null; |
| 242 | 243 | ||
| 243 | foreach (XAttribute attrib in node.Attributes()) | 244 | foreach (var attrib in node.Attributes()) |
| 244 | { | 245 | { |
| 245 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | 246 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) |
| 246 | { | 247 | { |
| @@ -274,11 +275,11 @@ namespace WixToolset.PowerShell | |||
| 274 | 275 | ||
| 275 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); | 276 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
| 276 | 277 | ||
| 277 | RegistryRootType registryRoot = RegistryRootType.LocalMachine; // HKLM | 278 | var registryRoot = RegistryRootType.LocalMachine; // HKLM |
| 278 | string registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); | 279 | var registryKey = String.Format(CultureInfo.InvariantCulture, KeyFormat, String.Format(CultureInfo.InvariantCulture, "!(wix.{0}_{1})", VarPrefix, snapIn), snapIn); |
| 279 | 280 | ||
| 280 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "File", fileId); | 281 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.File, fileId); |
| 281 | this.ParseHelper.CreateRegistryRow(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); | 282 | this.ParseHelper.CreateRegistryTuple(section, sourceLineNumbers, registryRoot, registryKey, valueName, String.Format(CultureInfo.InvariantCulture, "[~][#{0}]", fileId), componentId, false); |
| 282 | } | 283 | } |
| 283 | } | 284 | } |
| 284 | } | 285 | } |
