public static NUnitProject FromVSSolution(string solutionPath) { NUnitProject project = new NUnitProject(Path.GetFullPath(solutionPath)); string solutionDirectory = Path.GetDirectoryName(solutionPath); using (StreamReader reader = new StreamReader(solutionPath)) { char[] delims = { '=', ',' }; char[] trimchars = { ' ', '"' }; string line = reader.ReadLine(); while (line != null) { if (line.StartsWith("Project")) { string[] parts = line.Split(delims); string vsProjectPath = parts[2].Trim(trimchars); if (VSProject.IsProjectFile(vsProjectPath)) { project.Add(new VSProject(Path.Combine(solutionDirectory, vsProjectPath))); } } line = reader.ReadLine(); } } project.isDirty = false; return(project); }
/// <summary> /// Return a test project by either loading it from /// the supplied path, creating one from a VS file /// or wrapping an assembly. /// </summary> public static NUnitProject LoadProject(string path) { if (NUnitProject.IsProjectFile(path)) { NUnitProject project = new NUnitProject(path); project.Load(); return(project); } else if (VSProject.IsProjectFile(path)) { return(NUnitProject.FromVSProject(path)); } else if (VSProject.IsSolutionFile(path)) { return(NUnitProject.FromVSSolution(path)); } else { return(NUnitProject.FromAssembly(path)); } }
// True if it's ours or one we can load public static bool CanLoadAsProject(string path) { return(IsProjectFile(path) || VSProject.IsProjectFile(path) || VSProject.IsSolutionFile(path)); }