public bool TestIsValidConfiguration(string filePath) { try { BuildConfigurationType buildConfig = DeserializeBuildConfigInternal(filePath); if (buildConfig == null) { _logger?.LogError($"The provided configuration {filePath} is empty."); return(false); } string versionMatch = ConfigurationUtility.IsVersionMatch(buildConfig.ConfigVersion, Version) ? "[MATCH]" : "[MISSMATCH]"; string msg = $"{versionMatch} The provided configuration {filePath} is a valid configuration file." + $"\n\tConfiguration version:\t{buildConfig.ConfigVersion}" + $"\n\tParser version: \t{Version}"; // [gruenwaldlu, 2020-07-14-14:14:39+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out. Console.Out.Write(msg); _logger?.LogInformation(msg); return(true); } catch (Exception e) { StringBuilder builder = new StringBuilder(); string msg = BuildErrorMessage(builder, e); // [gruenwaldlu, 2020-07-27-13:45:55+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out. Console.Out.Write(msg); _logger?.LogWarning(msg); return(false); } }
private IProject GetProjectFromConfig(BuildConfigurationType buildConfig, ProjectType buildConfigProject) { IProject project = _factory.MakeProject(); project.Name = buildConfigProject.Id; AddJobsToProject(buildConfig, buildConfigProject, project); return(project); }
private BuildConfigurationType DeserializeBuildConfigInternal(string filePath) { XmlSerializer xmlDataSerializer = new XmlSerializer(typeof(BuildConfigurationType)); XmlReaderSettings settings = GetXmlReaderSettings(); using Stream stream = _fileSystem.File.OpenRead(filePath); using XmlReader reader = XmlReader.Create(stream, settings); BuildConfigurationType buildConfig = (BuildConfigurationType)xmlDataSerializer.Deserialize(reader); return(buildConfig); }
private static object GetBuildConfigTaskFromTaskListItem(BuildConfigurationType buildConfig, object taskListItem) { object buildConfigTask = taskListItem; if (taskListItem is TaskReferenceType taskRef) { buildConfigTask = GetMatchingGlobalTask(buildConfig, taskRef); } return(buildConfigTask); }
public IEnumerable <IProject> Parse(string filePath) { BuildConfigurationType buildConfig = DeserializeBuildConfigInternal(filePath); IProject[] projects = new IProject[buildConfig.Projects.Length]; for (int i = 0; i < buildConfig.Projects.Length; i++) { ProjectType buildConfigProject = buildConfig.Projects[i]; projects[i] = GetProjectFromConfig(buildConfig, buildConfigProject); } return(projects); }
private void AddJobsToProject(BuildConfigurationType buildConfig, ProjectType buildConfigProject, IProject project) { if (buildConfigProject.Jobs.Length == 0) { return; } foreach (JobType buildConfigJob in buildConfigProject.Jobs) { IJob job = _factory.MakeJob(buildConfigJob.Name); AddTasksToJob(buildConfig, job, buildConfigJob); project.AddJob(job); } }
private static object GetMatchingGlobalTask(BuildConfigurationType buildConfig, TaskReferenceType taskRef) { object buildConfigTask = null; foreach (AbstractTaskType globalTask in buildConfig.GlobalTasks) { if (!globalTask.Id.Equals(taskRef.ReferenceId)) { continue; } buildConfigTask = globalTask; } return(buildConfigTask); }
private void AddTasksToJob(BuildConfigurationType buildConfig, IJob job, JobType buildConfigJob) { TasksType taskList = (TasksType)buildConfigJob.Item; if (taskList.Items == null) { return; } foreach (object taskListItem in taskList.Items) { object buildConfigTask = GetBuildConfigTaskFromTaskListItem(buildConfig, taskListItem); ITask task = MakeTask(buildConfigTask); job.AddTask(task); } }