diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-09-09 16:03:29 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-09-09 21:14:27 -0500 |
commit | a1307cd4e76a89598c53cb68309358a7012db553 (patch) | |
tree | f79cf181b49f0b754afcd4ec25487bf2b284d45e /src/api/burn/WixToolset.Mba.Core | |
parent | f61479585d865372645cb18c982aa708dd975da3 (diff) | |
download | wix-a1307cd4e76a89598c53cb68309358a7012db553.tar.gz wix-a1307cd4e76a89598c53cb68309358a7012db553.tar.bz2 wix-a1307cd4e76a89598c53cb68309358a7012db553.zip |
Move `Bundle/@CommandLineVariables` into Bal.wixext.
Implements 6858
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core')
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs | 10 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/MbaCommand.cs | 5 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | 44 |
3 files changed, 33 insertions, 26 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs b/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs index 1ffe50e4..2b26d7b6 100644 --- a/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs +++ b/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs | |||
@@ -10,13 +10,13 @@ namespace WixToolset.Mba.Core | |||
10 | public enum VariableCommandLineType | 10 | public enum VariableCommandLineType |
11 | { | 11 | { |
12 | /// <summary> | 12 | /// <summary> |
13 | /// Similar to Windows Installer, all variable names specified on the command line are automatically converted to upper case. | ||
14 | /// </summary> | ||
15 | UpperCase, | ||
16 | /// <summary> | ||
17 | /// All variable names specified on the command line must match the case specified when building the bundle. | 13 | /// All variable names specified on the command line must match the case specified when building the bundle. |
18 | /// </summary> | 14 | /// </summary> |
19 | CaseSensitive, | 15 | CaseSensitive, |
16 | /// <summary> | ||
17 | /// Variable names specified on the command line do not have to match the case specified when building the bundle. | ||
18 | /// </summary> | ||
19 | CaseInsensitive, | ||
20 | } | 20 | } |
21 | 21 | ||
22 | /// <summary> | 22 | /// <summary> |
@@ -34,4 +34,4 @@ namespace WixToolset.Mba.Core | |||
34 | /// </summary> | 34 | /// </summary> |
35 | IDictionary<string, IOverridableVariableInfo> Variables { get; } | 35 | IDictionary<string, IOverridableVariableInfo> Variables { get; } |
36 | } | 36 | } |
37 | } \ No newline at end of file | 37 | } |
diff --git a/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs index 8917a334..bd93b7e7 100644 --- a/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs +++ b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace WixToolset.Mba.Core | 3 | namespace WixToolset.Mba.Core |
4 | { | 4 | { |
5 | using System; | ||
5 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
6 | 7 | ||
7 | /// <summary> | 8 | /// <summary> |
@@ -21,11 +22,11 @@ namespace WixToolset.Mba.Core | |||
21 | { | 22 | { |
22 | foreach (var kvp in this.Variables) | 23 | foreach (var kvp in this.Variables) |
23 | { | 24 | { |
24 | var key = overridableVariables.CommandLineType == VariableCommandLineType.UpperCase ? kvp.Key.ToUpperInvariant() : kvp.Key; | 25 | var key = kvp.Key; |
25 | 26 | ||
26 | if (!overridableVariables.Variables.TryGetValue(key, out var overridableVariable)) | 27 | if (!overridableVariables.Variables.TryGetValue(key, out var overridableVariable)) |
27 | { | 28 | { |
28 | engine.Log(LogLevel.Error, string.Format("Ignoring attempt to set non-overridable variable: '{0}'.", key)); | 29 | engine.Log(LogLevel.Error, String.Format("Ignoring attempt to set non-overridable variable: '{0}'.", key)); |
29 | } | 30 | } |
30 | else | 31 | else |
31 | { | 32 | { |
diff --git a/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs index 148acb34..121c6aee 100644 --- a/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs +++ b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | |||
@@ -29,37 +29,43 @@ namespace WixToolset.Mba.Core | |||
29 | { | 29 | { |
30 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); | 30 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); |
31 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); | 31 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); |
32 | XPathNavigator commandLineNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:CommandLine", namespaceManager); | 32 | XPathNavigator commandLineNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:WixStdbaCommandLine", namespaceManager); |
33 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager); | 33 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager); |
34 | 34 | ||
35 | var overridableVariables = new OverridableVariablesInfo(); | 35 | var overridableVariables = new OverridableVariablesInfo(); |
36 | IEqualityComparer<string> variableNameComparer; | ||
36 | 37 | ||
37 | if (commandLineNode == null) | 38 | if (commandLineNode == null) |
38 | { | 39 | { |
39 | throw new Exception("Failed to select command line information."); | ||
40 | } | ||
41 | |||
42 | string variablesValue = BootstrapperApplicationData.GetAttribute(commandLineNode, "Variables"); | ||
43 | |||
44 | if (variablesValue == null) | ||
45 | { | ||
46 | throw new Exception("Failed to get command line variable type."); | ||
47 | } | ||
48 | |||
49 | if (variablesValue.Equals("upperCase", StringComparison.InvariantCulture)) | ||
50 | { | ||
51 | overridableVariables.CommandLineType = VariableCommandLineType.UpperCase; | ||
52 | } | ||
53 | else if (variablesValue.Equals("caseSensitive", StringComparison.InvariantCulture)) | ||
54 | { | ||
55 | overridableVariables.CommandLineType = VariableCommandLineType.CaseSensitive; | 40 | overridableVariables.CommandLineType = VariableCommandLineType.CaseSensitive; |
41 | variableNameComparer = StringComparer.InvariantCulture; | ||
56 | } | 42 | } |
57 | else | 43 | else |
58 | { | 44 | { |
59 | throw new Exception(string.Format("Unknown command line variable type: '{0}'", variablesValue)); | 45 | string variablesValue = BootstrapperApplicationData.GetAttribute(commandLineNode, "Variables"); |
46 | |||
47 | if (variablesValue == null) | ||
48 | { | ||
49 | throw new Exception("Failed to get command line variable type."); | ||
50 | } | ||
51 | |||
52 | if (variablesValue.Equals("caseInsensitive", StringComparison.InvariantCulture)) | ||
53 | { | ||
54 | overridableVariables.CommandLineType = VariableCommandLineType.CaseInsensitive; | ||
55 | variableNameComparer = StringComparer.InvariantCultureIgnoreCase; | ||
56 | } | ||
57 | else if (variablesValue.Equals("caseSensitive", StringComparison.InvariantCulture)) | ||
58 | { | ||
59 | overridableVariables.CommandLineType = VariableCommandLineType.CaseSensitive; | ||
60 | variableNameComparer = StringComparer.InvariantCulture; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | throw new Exception(String.Format("Unknown command line variable type: '{0}'", variablesValue)); | ||
65 | } | ||
60 | } | 66 | } |
61 | 67 | ||
62 | overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>(); | 68 | overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>(variableNameComparer); |
63 | 69 | ||
64 | foreach (XPathNavigator node in nodes) | 70 | foreach (XPathNavigator node in nodes) |
65 | { | 71 | { |