private void _loadConfig(string configname, string rootname) { ConfigReader reader = null; _startInfo = new ProcessStartInfo(); _cfg_logFilters = new List <LogFilter>(); try { _base = Path.GetDirectoryName(configname); reader = new ConfigReader(configname); reader.ReadRootNode(rootname); if (!reader.hasChildren) { throw new ConfigException("Empty configuration"); } if (reader.hasChildren) { while (reader.ReadNextElement()) { switch (reader.ElementName) { case "process": foreach (string name in reader.GetAttibutes()) { string value = _expandValue(reader.GetValueString(name)); if (name.StartsWith("env.", StringComparison.Ordinal)) { _startInfo.EnvironmentVariables[name.Substring(4)] = value; } else { switch (name) { case "filename": _startInfo.FileName = value; break; case "workingdirectory": _startInfo.WorkingDirectory = value; break; case "arguments": _startInfo.Arguments = value; break; default: throw new Exception("Unknown process property '" + name + "'."); } } } reader.NoChildElements(); break; case "logfilter": _cfg_logFilters.Add(new LogFilter(reader)); break; default: throw new ConfigException("Unknown element '" + reader.ElementName + "'."); } } } if (_startInfo.FileName == null || _startInfo.WorkingDirectory == null || _startInfo.Arguments == null) { throw new BuildException("Missing parameter in config '" + ProcessBuildConfig + "' missing."); } } catch (Exception err) { throw new ConfigException("Loading configuration from " + configname + " failed" + (reader != null ? " at line " + reader.LineNumber.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." : "."), err); } finally { if (reader != null) { reader.Dispose(); } } }