void ReadAdditionalVariablesFromFile(CalamariVariables variables) { var path = variables.Get(AdditionalVariablesPathVariable) ?? variables.Get($"env:{AdditionalVariablesPathVariable}"); string BuildExceptionMessage(string reason) => $"Could not read additional variables from JSON file at '{path}'. " + $"{reason} Make sure the file can be read or remove the " + $"'{AdditionalVariablesPathVariable}' environment variable. " + $"See inner exception for details."; if (string.IsNullOrEmpty(path)) { return; } if (!fileSystem.FileExists(path)) { throw new CommandException(BuildExceptionMessage("File does not exist.")); } try { var readVars = new VariableDictionary(path); variables.Merge(readVars); } catch (Exception e) { throw new CommandException(BuildExceptionMessage("The file could not be read."), e); } }
public IVariables Clone() { var dict = new CalamariVariables(); dict.Merge(this); return(dict); }
void ReadUnencryptedVariablesFromFile(CommonOptions options, CalamariVariables variables) { var variablesFile = options.InputVariables.VariablesFile; if (string.IsNullOrEmpty(variablesFile)) { return; } if (!fileSystem.FileExists(variablesFile)) { throw new CommandException("Could not find variables file: " + variablesFile); } var readVars = new VariableDictionary(variablesFile); variables.Merge(readVars); }