diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-07-01 09:30:10 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-07-02 12:50:09 -0500 |
commit | 9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2 (patch) | |
tree | ea2a05de5a8a1dfcb2af8e9e3805fe015729f66a /src/api/burn/WixToolset.Mba.Core | |
parent | 8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc (diff) | |
download | wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.tar.gz wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.tar.bz2 wix-9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2.zip |
Add bundle option for command line variables to always be uppercase.
Fixes #3777
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core')
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs | 20 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/MbaCommand.cs | 6 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | 30 |
3 files changed, 54 insertions, 2 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs b/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs index 3944913b..1ffe50e4 100644 --- a/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs +++ b/src/api/burn/WixToolset.Mba.Core/IOverridableVariables.cs | |||
@@ -5,11 +5,31 @@ namespace WixToolset.Mba.Core | |||
5 | using System.Collections.Generic; | 5 | using System.Collections.Generic; |
6 | 6 | ||
7 | /// <summary> | 7 | /// <summary> |
8 | /// The case sensitivity of variables from the command line. | ||
9 | /// </summary> | ||
10 | public enum VariableCommandLineType | ||
11 | { | ||
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. | ||
18 | /// </summary> | ||
19 | CaseSensitive, | ||
20 | } | ||
21 | |||
22 | /// <summary> | ||
8 | /// Overridable variable information from the BA manifest. | 23 | /// Overridable variable information from the BA manifest. |
9 | /// </summary> | 24 | /// </summary> |
10 | public interface IOverridableVariables | 25 | public interface IOverridableVariables |
11 | { | 26 | { |
12 | /// <summary> | 27 | /// <summary> |
28 | /// The <see cref="VariableCommandLineType"/> of the bundle. | ||
29 | /// </summary> | ||
30 | VariableCommandLineType CommandLineType { get; } | ||
31 | |||
32 | /// <summary> | ||
13 | /// Variable Dictionary of variable name to <see cref="IOverridableVariableInfo"/>. | 33 | /// Variable Dictionary of variable name to <see cref="IOverridableVariableInfo"/>. |
14 | /// </summary> | 34 | /// </summary> |
15 | IDictionary<string, IOverridableVariableInfo> Variables { get; } | 35 | IDictionary<string, IOverridableVariableInfo> Variables { get; } |
diff --git a/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs index e7e49607..424cde63 100644 --- a/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs +++ b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs | |||
@@ -19,9 +19,11 @@ namespace WixToolset.Mba.Core | |||
19 | { | 19 | { |
20 | foreach (var kvp in this.Variables) | 20 | foreach (var kvp in this.Variables) |
21 | { | 21 | { |
22 | if (!overridableVariables.Variables.TryGetValue(kvp.Key, out var overridableVariable)) | 22 | var key = overridableVariables.CommandLineType == VariableCommandLineType.UpperCase ? kvp.Key.ToUpperInvariant() : kvp.Key; |
23 | |||
24 | if (!overridableVariables.Variables.TryGetValue(key, out var overridableVariable)) | ||
23 | { | 25 | { |
24 | engine.Log(LogLevel.Error, string.Format("Ignoring attempt to set non-overridable variable: '{0}'.", kvp.Key)); | 26 | engine.Log(LogLevel.Error, string.Format("Ignoring attempt to set non-overridable variable: '{0}'.", key)); |
25 | } | 27 | } |
26 | else | 28 | else |
27 | { | 29 | { |
diff --git a/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs index 855ce9a9..148acb34 100644 --- a/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs +++ b/src/api/burn/WixToolset.Mba.Core/OverridableVariables.cs | |||
@@ -13,6 +13,9 @@ namespace WixToolset.Mba.Core | |||
13 | public class OverridableVariablesInfo : IOverridableVariables | 13 | public class OverridableVariablesInfo : IOverridableVariables |
14 | { | 14 | { |
15 | /// <inheritdoc /> | 15 | /// <inheritdoc /> |
16 | public VariableCommandLineType CommandLineType { get; internal set; } | ||
17 | |||
18 | /// <inheritdoc /> | ||
16 | public IDictionary<string, IOverridableVariableInfo> Variables { get; internal set; } | 19 | public IDictionary<string, IOverridableVariableInfo> Variables { get; internal set; } |
17 | 20 | ||
18 | internal OverridableVariablesInfo() { } | 21 | internal OverridableVariablesInfo() { } |
@@ -26,9 +29,36 @@ namespace WixToolset.Mba.Core | |||
26 | { | 29 | { |
27 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); | 30 | XmlNamespaceManager namespaceManager = new XmlNamespaceManager(root.NameTable); |
28 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); | 31 | namespaceManager.AddNamespace("p", BootstrapperApplicationData.XMLNamespace); |
32 | XPathNavigator commandLineNode = root.SelectSingleNode("/p:BootstrapperApplicationData/p:CommandLine", namespaceManager); | ||
29 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager); | 33 | XPathNodeIterator nodes = root.Select("/p:BootstrapperApplicationData/p:WixStdbaOverridableVariable", namespaceManager); |
30 | 34 | ||
31 | var overridableVariables = new OverridableVariablesInfo(); | 35 | var overridableVariables = new OverridableVariablesInfo(); |
36 | |||
37 | if (commandLineNode == null) | ||
38 | { | ||
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; | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | throw new Exception(string.Format("Unknown command line variable type: '{0}'", variablesValue)); | ||
60 | } | ||
61 | |||
32 | overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>(); | 62 | overridableVariables.Variables = new Dictionary<string, IOverridableVariableInfo>(); |
33 | 63 | ||
34 | foreach (XPathNavigator node in nodes) | 64 | foreach (XPathNavigator node in nodes) |