private AssembliesReferences CollectAssembliesReferences(List <string> filePaths) { UpdateProgressText("Collecting references"); IsProgressIndeterminate(false); AssembliesReferences references = new AssembliesReferences(); int currentItem = 0; int allItemsCount = filePaths.Count; foreach (string filePath in filePaths) { string folder = Path.GetDirectoryName(filePath); try { AssemblyName fileAssembly = AssemblyManager.GetAssemblyName(filePath); references.AddAssembly(folder, fileAssembly); } catch { } currentItem++; UpdateProgress(100 * currentItem / allItemsCount); } return(references); }
private List <FileRecord> CollectFilesInfo(List <string> filePaths, string dirPath) { AssembliesReferences references = CollectAssembliesReferences(filePaths); UpdateProgressText("Collecting files info"); IsProgressIndeterminate(false); List <FileRecord> allFiles = new List <FileRecord>(filePaths.Count); int currentItem = 0; int allItemsCount = filePaths.Count; foreach (string filePath in filePaths) { FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(filePath); string fileCertificate = string.Empty; string fileAssebbly = string.Empty; string referencesCheck = string.Empty; try { fileCertificate = X509Certificate.CreateFromSignedFile(filePath).Subject; } catch { } try { fileAssebbly = AssemblyManager.GetAssemblyName(filePath).FullName; } catch { } try { string fileFolder = Path.GetDirectoryName(filePath); Assembly assembly = AssemblyManager.GetAssemblyByFile(filePath); referencesCheck = references.CheckAssembly(fileFolder, assembly); } catch { } allFiles.Add(new FileRecord() { FilePath = FilesHelper.GetRelativePath(filePath, dirPath), FileVersion = fileVersionInfo.FileVersion, ProductVersion = fileVersionInfo.ProductVersion, Signature = fileCertificate, AssemblyName = fileAssebbly, ReferencesCheck = referencesCheck, }); currentItem++; UpdateProgress(100 * currentItem / allItemsCount); } return(allFiles); }
private void FillProjectReferences(VSProject2 proj) { if (proj.Project != null) { var outputFilePath = PropertiesHelper.GetOutputFilePath(proj.Project); if (!string.IsNullOrEmpty(outputFilePath)) { if (_hash.Add(Path.GetFileName(outputFilePath)) && outputFilePath.IndexOf("mscorlib", StringComparison.InvariantCultureIgnoreCase) == -1 ) { AssembliesProjects.Add(outputFilePath); } } } foreach (var item in proj.References.OfType <Reference>()) { if (item.Type == prjReferenceType.prjReferenceTypeAssembly) { if (_hash.Add(Path.GetFileName(item.Path)) && item.Path.IndexOf("mscorlib", StringComparison.InvariantCultureIgnoreCase) == -1 ) { AssembliesReferences.Add(item.Path); } if (item.SourceProject != null && item.SourceProject.Object != null && item.SourceProject.Object is VSProject2 project2 ) { FillProjectReferences(project2); } } } }