private void AddProject(string projectLine) { //string pattern = @"^Project\(""(?<unknown>\S+)""\) = ""(?<name>\S+)"", ""(?<path>\S+)"", ""(?<id>\S+)"""; // fix for bug 887476 string pattern = @"^Project\(""(?<projecttype>.*?)""\) = ""(?<name>.*?)"", ""(?<path>.*?)"", ""(?<id>.*?)"""; Regex regex = new Regex(pattern); Match match = regex.Match(projectLine); if (match.Success) { string projectTypeGUID = match.Groups["projecttype"].Value; string name = match.Groups["name"].Value; string path = match.Groups["path"].Value; string id = match.Groups["id"].Value; //we check the GUID as this tells us what type of VS project to process //this ensures that it a standard project type, and not an third-party one, //which might have a completely differant structure that we could not handle! if (projectTypeGUID=="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") //C# project { Project project = new Project(this, new Guid(id), name); string absoluteProjectPath = String.Empty; if (path.StartsWith("http:")) { Uri projectURL = new Uri(path); if (projectURL.Authority=="localhost") { //we will assume thet the virtual directory is on site 1 of localhost DirectoryEntry root = new DirectoryEntry("IIS://localhost/w3svc/1/root"); string rootPath = root.Properties["Path"].Value as String; //we will also assume that the user has been clever and changed to virtual directory local path... absoluteProjectPath=rootPath + projectURL.AbsolutePath; } } else { absoluteProjectPath = Path.Combine(_directory, path); } if (absoluteProjectPath.Length>0) { project.Read(absoluteProjectPath); string relativeProjectPath = Path.GetDirectoryName(absoluteProjectPath); project.RelativePath = relativeProjectPath; if (project.ProjectType == "C# Local") { _projects.Add(project.ID, project); } if (project.ProjectType == "C# Web") { _projects.Add(project.ID, project); } } } if (projectTypeGUID=="{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") // VB.NET project { } if (projectTypeGUID=="{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") // C++ project { } } }
private void AddProject(string projectLine) { //string pattern = @"^Project\(""(?<unknown>\S+)""\) = ""(?<name>\S+)"", ""(?<path>\S+)"", ""(?<id>\S+)"""; // fix for bug 887476 string pattern = @"^Project\(""(?<projecttype>.*?)""\) = ""(?<name>.*?)"", ""(?<path>.*?)"", ""(?<id>.*?)"""; Regex regex = new Regex(pattern); Match match = regex.Match(projectLine); if (match.Success) { string projectTypeGUID = match.Groups["projecttype"].Value; string name = match.Groups["name"].Value; string path = match.Groups["path"].Value; string id = match.Groups["id"].Value; //we check the GUID as this tells us what type of VS project to process //this ensures that it a standard project type, and not an third-party one, //which might have a completely differant structure that we could not handle! if (projectTypeGUID=="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") //C# project { if (!path.StartsWith("http:")) { Project project = new Project(this, new Guid(id), name); string absoluteProjectPath = Path.Combine(_directory, path); project.Read(absoluteProjectPath); string relativeProjectPath = Path.GetDirectoryName(path); project.RelativePath = relativeProjectPath; if (project.ProjectType == "C# Local") { _projects.Add(project.ID, project); } } } } }