/// <summary> /// Create the list of potential projects from the search paths. /// </summary> private static List <ProjectDependency> GetPotentialProjects(IEnumerable <string> searchPaths) { var projects = new List <ProjectDependency>(); // Resolve all of the potential projects foreach (var searchPath in searchPaths) { var directory = new DirectoryInfo(searchPath); if (!directory.Exists) { continue; } foreach (var projectDirectory in directory.EnumerateDirectories()) { // Create the path to the project.json file. var projectFilePath = Path.Combine(projectDirectory.FullName, "project.json"); // We INTENTIONALLY do not do an exists check here because it requires disk I/O // Instead, we'll do an exists check when we try to resolve // Check if we've already added this, just in case it was pre-loaded into the cache var project = new ProjectDependency(projectDirectory.Name, projectFilePath); projects.Add(project); } } return(projects); }
public IEnumerable <ProjectDependency> ResolveAllProjectDependenciesForFramework( ProjectDependency projectToResolve, NuGetFramework framework, IEnumerable <string> preResolvedProjects = null) { var projects = new List <ProjectDependency> { projectToResolve }; var allDependencies = new List <ProjectDependency>(); while (projects.Count > 0) { var project = projects.First(); projects.Remove(project); var projectContext = ProjectContext.CreateContextForEachFramework(project.ProjectFilePath).FirstOrDefault(); if (projectContext == null) { continue; } var dependencies = ResolveDirectProjectDependenciesForFramework( projectContext.ProjectFile, framework, preResolvedProjects ); projects.AddRange(dependencies); allDependencies.AddRange(dependencies); } return(allDependencies); }
private static void AddIfProjectExists(List <ProjectDependency> projects, DirectoryInfo projectDirectory) { var projectJSONFilePath = Path.Combine(projectDirectory.FullName, "project.json"); var csProjFilePath = Path.Combine(projectDirectory.FullName, $"{projectDirectory.Name}.csproj"); if (File.Exists(projectJSONFilePath) || File.Exists(csProjFilePath)) { var project = new ProjectDependency(projectDirectory.Name, projectJSONFilePath); projects.Add(project); } }
public IEnumerable <ProjectDependency> ResolveAllProjectDependenciesForFramework( ProjectDependency projectToResolve, NuGetFramework framework, IEnumerable <string> preResolvedProjects = null, SlnFile solutionFile = null) { var projects = new List <ProjectDependency> { projectToResolve }; var allDependencies = new HashSet <ProjectDependency>(); while (projects.Count > 0) { var project = projects.First(); projects.Remove(project); if (!File.Exists(project.ProjectFilePath)) { MigrationErrorCodes .MIGRATE1018(String.Format(LocalizableStrings.MIGRATE1018Arg, project.ProjectFilePath)).Throw(); } var projectContext = ProjectContext.CreateContextForEachFramework(project.ProjectFilePath).FirstOrDefault(); if (projectContext == null) { continue; } var dependencies = ResolveDirectProjectDependenciesForFramework( projectContext.ProjectFile, framework, preResolvedProjects, solutionFile, HoistDependenciesThatAreNotDirectDependencies(projectToResolve, project) ); projects.AddRange(dependencies); allDependencies.UnionWith(dependencies); } return(allDependencies); }
private bool HoistDependenciesThatAreNotDirectDependencies( ProjectDependency originalProject, ProjectDependency dependenciesOwner) { return(originalProject != dependenciesOwner); }