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 | |
| 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')
| -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 | ||||
| -rw-r--r-- | src/api/burn/balutil/balinfo.cpp | 47 | ||||
| -rw-r--r-- | src/api/burn/balutil/inc/balinfo.h | 2 | ||||
| -rw-r--r-- | src/api/wix/WixToolset.Data/Symbols/WixBundleSymbol.cs | 14 |
6 files changed, 57 insertions, 65 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 | { |
diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp index 52a7f911..751ba4f1 100644 --- a/src/api/burn/balutil/balinfo.cpp +++ b/src/api/burn/balutil/balinfo.cpp | |||
| @@ -348,7 +348,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 348 | ) | 348 | ) |
| 349 | { | 349 | { |
| 350 | HRESULT hr = S_OK; | 350 | HRESULT hr = S_OK; |
| 351 | LPWSTR sczKey = NULL; | ||
| 352 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; | 351 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; |
| 353 | 352 | ||
| 354 | for (DWORD i = 0; i < pCommand->cVariables; ++i) | 353 | for (DWORD i = 0; i < pCommand->cVariables; ++i) |
| @@ -356,14 +355,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 356 | LPCWSTR wzVariableName = pCommand->rgVariableNames[i]; | 355 | LPCWSTR wzVariableName = pCommand->rgVariableNames[i]; |
| 357 | LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; | 356 | LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; |
| 358 | 357 | ||
| 359 | if (BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE == pOverridableVariables->commandLineType) | ||
| 360 | { | ||
| 361 | hr = StrAllocStringToUpperInvariant(&sczKey, wzVariableName, 0); | ||
| 362 | ExitOnFailure(hr, "Failed to upper case variable name."); | ||
| 363 | |||
| 364 | wzVariableName = sczKey; | ||
| 365 | } | ||
| 366 | |||
| 367 | hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast<void**>(&pOverridableVariable)); | 358 | hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast<void**>(&pOverridableVariable)); |
| 368 | if (E_NOTFOUND == hr) | 359 | if (E_NOTFOUND == hr) |
| 369 | { | 360 | { |
| @@ -378,8 +369,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( | |||
| 378 | } | 369 | } |
| 379 | 370 | ||
| 380 | LExit: | 371 | LExit: |
| 381 | ReleaseStr(sczKey); | ||
| 382 | |||
| 383 | return hr; | 372 | return hr; |
| 384 | } | 373 | } |
| 385 | 374 | ||
| @@ -604,29 +593,37 @@ static HRESULT ParseOverridableVariablesFromXml( | |||
| 604 | { | 593 | { |
| 605 | HRESULT hr = S_OK; | 594 | HRESULT hr = S_OK; |
| 606 | IXMLDOMNode* pCommandLineNode = NULL; | 595 | IXMLDOMNode* pCommandLineNode = NULL; |
| 596 | BOOL fXmlFound = FALSE; | ||
| 607 | LPWSTR scz = NULL; | 597 | LPWSTR scz = NULL; |
| 608 | IXMLDOMNode* pNode = NULL; | 598 | IXMLDOMNode* pNode = NULL; |
| 609 | IXMLDOMNodeList* pNodes = NULL; | 599 | IXMLDOMNodeList* pNodes = NULL; |
| 610 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; | 600 | BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; |
| 611 | 601 | ||
| 612 | hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/CommandLine", &pCommandLineNode); | 602 | hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaCommandLine", &pCommandLineNode); |
| 613 | ExitOnRequiredXmlQueryFailure(hr, "Failed to select command line information."); | 603 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to select command line information."); |
| 614 | |||
| 615 | // @Variables | ||
| 616 | hr = XmlGetAttributeEx(pCommandLineNode, L"Variables", &scz); | ||
| 617 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get command line variable type."); | ||
| 618 | 604 | ||
| 619 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"upperCase", -1)) | 605 | if (!fXmlFound) |
| 620 | { | ||
| 621 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE; | ||
| 622 | } | ||
| 623 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseSensitive", -1)) | ||
| 624 | { | 606 | { |
| 625 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; | 607 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; |
| 626 | } | 608 | } |
| 627 | else | 609 | else |
| 628 | { | 610 | { |
| 629 | ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for CommandLine/@Variables: %ls", scz); | 611 | // @Variables |
| 612 | hr = XmlGetAttributeEx(pCommandLineNode, L"VariableType", &scz); | ||
| 613 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get command line variable type."); | ||
| 614 | |||
| 615 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseInsensitive", -1)) | ||
| 616 | { | ||
| 617 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_INSENSITIVE; | ||
| 618 | } | ||
| 619 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseSensitive", -1)) | ||
| 620 | { | ||
| 621 | pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; | ||
| 622 | } | ||
| 623 | else | ||
| 624 | { | ||
| 625 | ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for CommandLine/@Variables: %ls", scz); | ||
| 626 | } | ||
| 630 | } | 627 | } |
| 631 | 628 | ||
| 632 | // Get the list of variables users can override on the command line. | 629 | // Get the list of variables users can override on the command line. |
| @@ -638,7 +635,9 @@ static HRESULT ParseOverridableVariablesFromXml( | |||
| 638 | 635 | ||
| 639 | if (pOverridableVariables->cVariables) | 636 | if (pOverridableVariables->cVariables) |
| 640 | { | 637 | { |
| 641 | hr = DictCreateWithEmbeddedKey(&pOverridableVariables->sdVariables, pOverridableVariables->cVariables, reinterpret_cast<void**>(&pOverridableVariables->rgVariables), offsetof(BAL_INFO_OVERRIDABLE_VARIABLE, sczName), DICT_FLAG_NONE); | 638 | DICT_FLAG dfFlags = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_INSENSITIVE == pOverridableVariables->commandLineType ? DICT_FLAG_CASEINSENSITIVE : DICT_FLAG_NONE; |
| 639 | |||
| 640 | hr = DictCreateWithEmbeddedKey(&pOverridableVariables->sdVariables, pOverridableVariables->cVariables, reinterpret_cast<void**>(&pOverridableVariables->rgVariables), offsetof(BAL_INFO_OVERRIDABLE_VARIABLE, sczName), dfFlags); | ||
| 642 | ExitOnFailure(hr, "Failed to create the overridable variables string dictionary."); | 641 | ExitOnFailure(hr, "Failed to create the overridable variables string dictionary."); |
| 643 | 642 | ||
| 644 | hr = MemAllocArray(reinterpret_cast<LPVOID*>(&pOverridableVariables->rgVariables), sizeof(pOverridableVariable), pOverridableVariables->cVariables); | 643 | hr = MemAllocArray(reinterpret_cast<LPVOID*>(&pOverridableVariables->rgVariables), sizeof(pOverridableVariable), pOverridableVariables->cVariables); |
diff --git a/src/api/burn/balutil/inc/balinfo.h b/src/api/burn/balutil/inc/balinfo.h index 818ff5ef..3ef3a61a 100644 --- a/src/api/burn/balutil/inc/balinfo.h +++ b/src/api/burn/balutil/inc/balinfo.h | |||
| @@ -40,8 +40,8 @@ typedef enum _BAL_INFO_RESTART | |||
| 40 | 40 | ||
| 41 | typedef enum _BAL_INFO_VARIABLE_COMMAND_LINE_TYPE | 41 | typedef enum _BAL_INFO_VARIABLE_COMMAND_LINE_TYPE |
| 42 | { | 42 | { |
| 43 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE, | ||
| 44 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE, | 43 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE, |
| 44 | BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_INSENSITIVE, | ||
| 45 | } BAL_INFO_VARIABLE_COMMAND_LINE_TYPE; | 45 | } BAL_INFO_VARIABLE_COMMAND_LINE_TYPE; |
| 46 | 46 | ||
| 47 | 47 | ||
diff --git a/src/api/wix/WixToolset.Data/Symbols/WixBundleSymbol.cs b/src/api/wix/WixToolset.Data/Symbols/WixBundleSymbol.cs index c4db0c21..ffeb5f3b 100644 --- a/src/api/wix/WixToolset.Data/Symbols/WixBundleSymbol.cs +++ b/src/api/wix/WixToolset.Data/Symbols/WixBundleSymbol.cs | |||
| @@ -33,7 +33,6 @@ namespace WixToolset.Data | |||
| 33 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.BundleId), IntermediateFieldType.String), | 33 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.BundleId), IntermediateFieldType.String), |
| 34 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.ProviderKey), IntermediateFieldType.String), | 34 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.ProviderKey), IntermediateFieldType.String), |
| 35 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.InProgressName), IntermediateFieldType.String), | 35 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.InProgressName), IntermediateFieldType.String), |
| 36 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.CommandLineVariables), IntermediateFieldType.String), | ||
| 37 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.DisableModify), IntermediateFieldType.String), | 36 | new IntermediateFieldDefinition(nameof(WixBundleSymbolFields.DisableModify), IntermediateFieldType.String), |
| 38 | }, | 37 | }, |
| 39 | typeof(WixBundleSymbol)); | 38 | typeof(WixBundleSymbol)); |
| @@ -69,7 +68,6 @@ namespace WixToolset.Data.Symbols | |||
| 69 | BundleId, | 68 | BundleId, |
| 70 | ProviderKey, | 69 | ProviderKey, |
| 71 | InProgressName, | 70 | InProgressName, |
| 72 | CommandLineVariables, | ||
| 73 | DisableModify, | 71 | DisableModify, |
| 74 | } | 72 | } |
| 75 | 73 | ||
| @@ -81,12 +79,6 @@ namespace WixToolset.Data.Symbols | |||
| 81 | PerMachine = 0x2, | 79 | PerMachine = 0x2, |
| 82 | } | 80 | } |
| 83 | 81 | ||
| 84 | public enum WixBundleCommandLineVariables | ||
| 85 | { | ||
| 86 | UpperCase, | ||
| 87 | CaseSensitive, | ||
| 88 | } | ||
| 89 | |||
| 90 | public enum WixBundleModifyType | 82 | public enum WixBundleModifyType |
| 91 | { | 83 | { |
| 92 | Allowed = 0, | 84 | Allowed = 0, |
| @@ -244,12 +236,6 @@ namespace WixToolset.Data.Symbols | |||
| 244 | set => this.Set((int)WixBundleSymbolFields.InProgressName, value); | 236 | set => this.Set((int)WixBundleSymbolFields.InProgressName, value); |
| 245 | } | 237 | } |
| 246 | 238 | ||
| 247 | public WixBundleCommandLineVariables CommandLineVariables | ||
| 248 | { | ||
| 249 | get => (WixBundleCommandLineVariables)this.Fields[(int)WixBundleSymbolFields.CommandLineVariables].AsNumber(); | ||
| 250 | set => this.Set((int)WixBundleSymbolFields.CommandLineVariables, (int)value); | ||
| 251 | } | ||
| 252 | |||
| 253 | public WixBundleModifyType DisableModify | 239 | public WixBundleModifyType DisableModify |
| 254 | { | 240 | { |
| 255 | get | 241 | get |
