static void Main(string[] args) { //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); //AssemblyPath = EverythingFileSearcher.Searcher.Search(string.Format(@"{0}\Ref\bin !{0}\Ref\bin\3rd (.dll|.exe)", InitPath)).ToList(); AssemblyPath = SampleFileSearcher.SearchFiles($@"{InitPath}\Ref\Bin\Lib|{InitPath}\Ref\Bin\Impl", "*.dll|*.exe"); Console.WriteLine(Resources.Program_Main_Total_file_count__0__, AssemblyPath.Count); prjInfoDic = new Dictionary<string, PrjInfo>(); prjInfoFileNameDic = new Dictionary<string, PrjInfo>(); errorPrjInfo = new List<PrjInfo>(); root = new List<PrjInfo>(); AssemblyPath.ForEach(assPath => { if (!assPath.EndsWith("dll") && !assPath.EndsWith("exe")) return; CreatePrjInfo(assPath); } ); Console.WriteLine(Resources.Program_Main_Total_aasembly_count__0_, prjInfoDic.Count); RebuildRef(); var csprojFilePathList = SampleFileSearcher.SearchFiles($"{InitPath}\\Src", "*.csproj"); foreach (var csprjFile in csprojFilePathList) { var analyzer = new ProjectAnalyzer(csprjFile); var assName = analyzer.GetAssemblyName(); if (string.IsNullOrEmpty(assName)) { Console.WriteLine($"Prj File {csprjFile} could not output a assembly"); continue; } if (!prjInfoFileNameDic.ContainsKey(assName)) { Console.WriteLine($"Prj File {csprjFile} output assembly:{assName} did not registed"); continue; } var pf = new FileInfo(csprjFile); var prjInfo = prjInfoFileNameDic[assName]; prjInfo.PrjFilePath = pf.DirectoryName; prjInfo.PrjFileName = pf.Name; } PrintAss(); }
private void ScanProjectReferences(SolutionProject project, IList <SolutionProject> referencedProjects, SolutionFileVersion solutionFileVersion, IEnumerable <string> includeFilter, IEnumerable <string> excludeFilter) { var projectAnalyzer = new ProjectAnalyzer(Path.Combine(this._options.SolutionFolderPath, project.Path)); var projectReferences = projectAnalyzer.GetProjectReferences(); foreach (var projectReference in projectReferences) { if (File.Exists(projectReference.Path)) { ProcessProjectFile(projectReference.Path, referencedProjects, includeFilter, excludeFilter, projectAnalyzer, true); ScanProjectReferences(projectReference, referencedProjects, solutionFileVersion, includeFilter, excludeFilter); } } }
private void ScanProjectDirectory(DirectoryInfo dir, IList <SolutionProject> projects, SolutionFileVersion solutionFileVersion, IEnumerable <string> includeFilter, IEnumerable <string> excludeFilter, bool recursive) { FileSystemInfo[] files = dir.GetFileSystemInfos(); foreach (FileSystemInfo file in files) { var projectAnalyzer = new ProjectAnalyzer(file.FullName); if (projectAnalyzer.IsProjectFile(solutionFileVersion)) { ProcessProjectFile(file.FullName, projects, includeFilter, excludeFilter, projectAnalyzer, false); } } if (recursive) { foreach (var subdir in dir.GetDirectories("*")) { ScanProjectDirectory(subdir, projects, solutionFileVersion, includeFilter, excludeFilter, recursive); } } }
private void ProcessProjectFile(string projectPath, IList <SolutionProject> projects, IEnumerable <string> includeFilter, IEnumerable <string> excludeFilter, ProjectAnalyzer projectAnalyzer, bool allowDuplicates) { ++this.NumberOfProjectsFound; string message = string.Format("Found project {0}", Path.GetFileNameWithoutExtension(projectPath)); bool skip = false; if (includeFilter.Any() && !ProjectHasMatch(projectPath, includeFilter)) { skip = true; } if (excludeFilter.Any() && ProjectHasMatch(projectPath, excludeFilter)) { skip = true; } if (skip) { ++this.NumberOfProjectsSkipped; message += " (skipped)"; } else { var project = new SolutionProject(); project.ProjectTypeId = ProjectTypes.Find(Path.GetExtension(projectPath).Substring(1)).ProjectGuid; project.ProjectId = projectAnalyzer.GetProjectId(); project.Name = Path.GetFileNameWithoutExtension(projectPath); project.Path = Utils.GetRelativePath(this._options.SolutionFolderPath, projectPath); if (!allowDuplicates && projects.Any(x => x.Name == project.Name)) { throw new InvalidOperationException(string.Format("Duplicate project: {0}. All projects should have unique names across the solution.", project.Name)); } projects.Add(project); } this._logger.Write(message); }
private void ScanProjectDirectory(DirectoryInfo dir, IList<SolutionProject> projects, SolutionFileVersion solutionFileVersion, IEnumerable<string> includeFilter, IEnumerable<string> excludeFilter, bool recursive) { FileSystemInfo[] files = dir.GetFileSystemInfos(); foreach (FileSystemInfo file in files) { var projectAnalyzer = new ProjectAnalyzer(file.FullName); if (projectAnalyzer.IsProjectFile(solutionFileVersion)) { ProcessProjectFile(file.FullName, projects, includeFilter, excludeFilter, projectAnalyzer, false); } } if (recursive) { foreach (var subdir in dir.GetDirectories("*")) { ScanProjectDirectory(subdir, projects, solutionFileVersion, includeFilter, excludeFilter, recursive); } } }
private void ProcessProjectFile(string projectPath, IList<SolutionProject> projects, IEnumerable<string> includeFilter, IEnumerable<string> excludeFilter, ProjectAnalyzer projectAnalyzer, bool allowDuplicates) { ++this.NumberOfProjectsFound; string message = string.Format("Found project {0}", Path.GetFileNameWithoutExtension(projectPath)); bool skip = false; if (includeFilter.Any() && !ProjectHasMatch(projectPath, includeFilter)) { skip = true; } if (excludeFilter.Any() && ProjectHasMatch(projectPath, excludeFilter)) { skip = true; } if (skip) { ++this.NumberOfProjectsSkipped; message += " (skipped)"; } else { var project = new SolutionProject(); project.ProjectTypeId = ProjectTypes.Find(Path.GetExtension(projectPath).Substring(1)).ProjectGuid; project.ProjectId = projectAnalyzer.GetProjectId(); project.Name = Path.GetFileNameWithoutExtension(projectPath); project.Path = Utils.GetRelativePath(this._options.SolutionFolderPath, projectPath); if (!allowDuplicates && projects.Any(x => x.Name == project.Name)) { throw new InvalidOperationException(string.Format("Duplicate project: {0}. All projects should have unique names across the solution.", project.Name)); } projects.Add(project); } this._logger.Write(message); }
private void ScanProjectReferences(SolutionProject project, IList<SolutionProject> referencedProjects, SolutionFileVersion solutionFileVersion, IEnumerable<string> includeFilter, IEnumerable<string> excludeFilter) { var projectAnalyzer = new ProjectAnalyzer(Path.Combine(this._options.SolutionFolderPath, project.Path)); var projectReferences = projectAnalyzer.GetProjectReferences(); foreach (var projectReference in projectReferences) { if (File.Exists(projectReference.Path)) { ProcessProjectFile(projectReference.Path, referencedProjects, includeFilter, excludeFilter, projectAnalyzer, true); ScanProjectReferences(projectReference, referencedProjects, solutionFileVersion, includeFilter, excludeFilter); } } }