From 8cbfc326cccf8d9b3b63cb6f752fc770f7dee0fc Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 29 Jun 2021 19:14:02 -0500 Subject: Expose overridable variable APIs in balutil and Mba.Core. Fixes #4777 --- src/api/burn/WixToolset.Mba.Core/MbaCommand.cs | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/api/burn/WixToolset.Mba.Core/MbaCommand.cs (limited to 'src/api/burn/WixToolset.Mba.Core/MbaCommand.cs') diff --git a/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs new file mode 100644 index 00000000..e7e49607 --- /dev/null +++ b/src/api/burn/WixToolset.Mba.Core/MbaCommand.cs @@ -0,0 +1,33 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Mba.Core +{ + using System.Collections.Generic; + + /// + /// Default implementation of . + /// + internal sealed class MbaCommand : IMbaCommand + { + public string[] UnknownCommandLineArgs { get; internal set; } + + public KeyValuePair[] Variables { get; internal set; } + + internal MbaCommand() { } + + public void SetOverridableVariables(IOverridableVariables overridableVariables, IEngine engine) + { + foreach (var kvp in this.Variables) + { + if (!overridableVariables.Variables.TryGetValue(kvp.Key, out var overridableVariable)) + { + engine.Log(LogLevel.Error, string.Format("Ignoring attempt to set non-overridable variable: '{0}'.", kvp.Key)); + } + else + { + engine.SetVariableString(overridableVariable.Name, kvp.Value, false); + } + } + } + } +} -- cgit v1.2.3-55-g6feb