From 9bdf3730cd43e1af8a4ea9be6cf2fba77fcff2d2 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 1 Jul 2021 09:30:10 -0500 Subject: Add bundle option for command line variables to always be uppercase. Fixes #3777 --- src/ext/Bal/wixext/BalBurnBackendExtension.cs | 21 +++++++++++++++++++++ src/ext/Bal/wixext/BalErrors.cs | 6 ++++++ 2 files changed, 27 insertions(+) (limited to 'src/ext/Bal/wixext') diff --git a/src/ext/Bal/wixext/BalBurnBackendExtension.cs b/src/ext/Bal/wixext/BalBurnBackendExtension.cs index c6a1e0c1..854b8b35 100644 --- a/src/ext/Bal/wixext/BalBurnBackendExtension.cs +++ b/src/ext/Bal/wixext/BalBurnBackendExtension.cs @@ -31,6 +31,8 @@ namespace WixToolset.Bal { base.SymbolsFinalized(section); + this.VerifyOverridableVariables(section); + var baSymbol = section.Symbols.OfType().SingleOrDefault(); var baId = baSymbol?.Id?.Id; if (null == baId) @@ -118,6 +120,25 @@ namespace WixToolset.Bal } } + private void VerifyOverridableVariables(IntermediateSection section) + { + var bundleSymbol = section.Symbols.OfType().Single(); + if (bundleSymbol.CommandLineVariables != WixBundleCommandLineVariables.UpperCase) + { + return; + } + + var overridableVariableSymbols = section.Symbols.OfType().ToList(); + foreach (var overridableVariableSymbol in overridableVariableSymbols) + { + var upperName = overridableVariableSymbol.Name.ToUpperInvariant(); + if (upperName != overridableVariableSymbol.Name) + { + this.Messaging.Write(BalErrors.NonUpperCaseOverridableVariable(overridableVariableSymbol.SourceLineNumbers, overridableVariableSymbol.Name, upperName)); + } + } + } + private void VerifyPrereqPackages(IntermediateSection section, bool isDNC) { var prereqInfoSymbols = section.Symbols.OfType().ToList(); diff --git a/src/ext/Bal/wixext/BalErrors.cs b/src/ext/Bal/wixext/BalErrors.cs index bc0186c1..e9f68b24 100644 --- a/src/ext/Bal/wixext/BalErrors.cs +++ b/src/ext/Bal/wixext/BalErrors.cs @@ -38,6 +38,11 @@ namespace WixToolset.Bal return Message(sourceLineNumbers, Ids.MultiplePrereqLicenses, "There may only be one package in the bundle that has either the PrereqLicenseFile attribute or the PrereqLicenseUrl attribute."); } + public static Message NonUpperCaseOverridableVariable(SourceLineNumber sourceLineNumbers, string name, string expectedName) + { + return Message(sourceLineNumbers, Ids.NonUpperCaseOverridableVariable, "Overridable variable '{0}' must be '{1}' with Bundle/@CommandLineVariables value 'upperCase'.", name, expectedName); + } + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) { return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); @@ -56,6 +61,7 @@ namespace WixToolset.Bal MultipleBAFunctions = 6804, BAFunctionsPayloadRequiredInUXContainer = 6805, MissingDNCPrereq = 6806, + NonUpperCaseOverridableVariable = 6807, } } } -- cgit v1.2.3-55-g6feb