public async Task <SolutionResult> ScanSolution(string rootDirectory) { var solutions = GetSolutions(rootDirectory); if (!solutions.Any()) { return(null); } var solutionPath = solutions.First(); var result = new SolutionResult(new FileInfo(solutionPath), this); foreach (var projectPath in GetProjects(result.Info.DirectoryName)) { var projectInfo = new FileInfo(projectPath); var packagePaths = GetPackages(projectInfo.DirectoryName); ProjectResult projectResult; if (packagePaths.Count() != 0) // Projects contains package.config file { var packageInfo = new FileInfo(packagePaths.First()); projectResult = new ProjectResult(projectInfo, packageInfo); } else { projectResult = new ProjectResult(projectInfo); } var nuspecInfo = GetNuspec(projectInfo.DirectoryName).FirstOrDefault(); if (!string.IsNullOrEmpty(nuspecInfo)) { projectResult.NuspecInfo = new FileInfo(nuspecInfo); } result.Projects.Add(projectResult); } var gitPath = DirectoryTools.SearchDirectory(solutionPath, GetGitFolder); if (!string.IsNullOrEmpty(gitPath)) { result.GitInformation = _gitCtor(gitPath); await result.GitInformation.Init(false); } return(result); }
private async Task <SolutionResult> ExecuteSolutionScan(string solutionPath, ICancelableProgress <ProgressMessage> progress, bool executeGitFetch) { var result = new SolutionResult(new FileInfo(solutionPath), this); foreach (var projectPath in GetProjects(result.Info.DirectoryName)) { if (progress.Token.IsCancellationRequested) { Log.Information("Cancelling scan"); throw new OperationCanceledException("Operation was canceled by user"); } var projectInfo = new FileInfo(projectPath); var packagePaths = GetPackages(projectInfo.DirectoryName); ProjectResult projectResult; if (packagePaths.Count() != 0) // Projects contains package.config file { var packageInfo = new FileInfo(packagePaths.First()); projectResult = new ProjectResult(projectInfo, packageInfo); } else { projectResult = new ProjectResult(projectInfo); } var nuspecInfo = GetNuspec(projectInfo.DirectoryName).FirstOrDefault(); if (!string.IsNullOrEmpty(nuspecInfo)) { projectResult.NuspecInfo = new FileInfo(nuspecInfo); } result.Projects.Add(projectResult); } var gitPath = DirectoryTools.SearchDirectory(solutionPath, GetGitFolder); if (!string.IsNullOrEmpty(gitPath)) { result.GitInformation = new GitInfo(gitPath, _gitEngine); await result.GitInformation.Init(executeGitFetch); } return(result); }
internal T_Result ReadDependencies(string solutionFolder) { var result = new T_Result(); var packagesDirectory = DirectoryTools.SearchDirectory(solutionFolder, GetPackagesFolder); if (string.IsNullOrEmpty(packagesDirectory)) { Log.Error("Can't fing packages folder in {solutionDirectory}. Aborting nuget reference scan.", solutionFolder); return(null); } foreach (var folder in Directory.GetDirectories(packagesDirectory)) { var nuspec = Directory.GetFiles(folder, "*.nupkg", SearchOption.TopDirectoryOnly).FirstOrDefault(); if (nuspec == null) { Log.Warning("Can't find nuspec in {source}", folder); continue; } var package = new ZipPackage(nuspec); var id = package.Id; var version = package.Version; var dependencies = package.DependencySets; if (result.ContainsKey(id)) { result[id].Add(version, dependencies); } else { var temp = new Dictionary <SemanticVersion, IEnumerable <PackageDependencySet> >() { { version, dependencies } }; result.Add(id, temp); } } return(result); }