/// <summary> /// Read a project file, plus all the project files it references. /// </summary> /// <param name="File">Project file to read</param> /// <param name="InitialProperties">Mapping of property name to value for the initial project</param> /// <param name="FileToProjectInfo"></param> /// <returns>True if the projects were read correctly, false (and prints an error to the log) if not</returns> static void ReadProjectsRecursively(FileReference File, Dictionary <string, string> InitialProperties, Dictionary <FileReference, CsProjectInfo> FileToProjectInfo) { // Early out if we've already read this project if (!FileToProjectInfo.ContainsKey(File)) { // Try to read this project CsProjectInfo ProjectInfo; if (!CsProjectInfo.TryRead(File, InitialProperties, out ProjectInfo)) { throw new AutomationException("Couldn't read project '{0}'", File.FullName); } // Add it to the project lookup, and try to read all the projects it references FileToProjectInfo.Add(File, ProjectInfo); foreach (FileReference ProjectReference in ProjectInfo.ProjectReferences.Keys) { ReadProjectsRecursively(ProjectReference, InitialProperties, FileToProjectInfo); } } }
/// <summary> /// Read a project file, plus all the project files it references. /// </summary> /// <param name="File">Project file to read</param> /// <param name="InitialProperties">Mapping of property name to value for the initial project</param> /// <param name="FileToProjectInfo"></param> /// <returns>True if the projects were read correctly, false (and prints an error to the log) if not</returns> static bool ReadProjectsRecursively(FileReference File, Dictionary <string, string> InitialProperties, Dictionary <FileReference, CsProjectInfo> FileToProjectInfo) { // Early out if we've already read this project, return success if (FileToProjectInfo.ContainsKey(File)) { return(true); } // Try to read this project CsProjectInfo ProjectInfo; if (!CsProjectInfo.TryRead(File, InitialProperties, out ProjectInfo)) { CommandUtils.LogError("Couldn't read project '{0}'", File.FullName); return(false); } // Add it to the project lookup, and try to read all the projects it references FileToProjectInfo.Add(File, ProjectInfo); return(ProjectInfo.ProjectReferences.Keys.All(x => ReadProjectsRecursively(x, InitialProperties, FileToProjectInfo))); }