public static void GenerateProjectDirs(NestedProjectsInfo nestedSection, List <BaseProject> projects, Dictionary <string, Dictionary <string, string> > allNestedProjects)
        {
            Func <BaseProject, string> getActualSolutionName = p =>
                                                               p is ProjectDirectory || p.Location.IsWebSiteUrl() || p.Location.StartsWith(p.SolutionDir)//Means it is a project that is located inside solution base folder or a project directory or its a website
                    ? p.SolutionName
                    : PathHelpers.GetDirName(Path.GetDirectoryName(Path.GetDirectoryName(p.Location)));

            var groupedSolutions = projects.ToArray().GroupBy(getActualSolutionName);

            foreach (var group in groupedSolutions)
            {
                var dir = new ProjectDirectory(group.Key);
                projects.Add(dir);

                dir.NestedProjectsInfo = nestedSection;
                nestedSection.Dirs.Add(dir);
                dir.NestedProjects.AddRange(group.Select(pr =>
                {
                    if (allNestedProjects.ContainsKey(group.Key) &&
                        allNestedProjects[group.Key].TryGetValue(pr.Guid, out var value))
                    {
                        // Use original subfolder/project association.
                        return(new ProjectRelationInfo(pr, new ProjectDirectory(group.Key, value)));
                    }

                    // Use updated subfolder/project association - we create a top level folder for each imported
                    // solution, for example, MySolution.sln creates a MySolution folder under the root (e.g. All.sln).
                    // This means that any previous subfolders/projects that used to be directly under the solution now
                    // has the new parent folder. This path handles such cases.
                    return(new ProjectRelationInfo(pr, dir));
                }));
            }
        }
Пример #2
0
        public static void GenerateProjectDirs(NestedProjectsInfo nestedSection, List <BaseProject> projects)
        {
            Func <BaseProject, string> getActualSolutionName = p =>
                                                               p is ProjectDirectory || p.Location.IsWebSiteUrl() || p.Location.StartsWith(p.SolutionDir)//Means it is a project that is located inside solution base folder or a project directory or its a website
                    ? p.SolutionName
                    : PathHelpers.GetDirName(Path.GetDirectoryName(Path.GetDirectoryName(p.Location)));

            var groupedSoltions = projects.ToArray().GroupBy(getActualSolutionName);

            foreach (var group in groupedSoltions)
            {
                var dir = new ProjectDirectory(group.Key);
                projects.Add(dir);

                dir.NestedProjectsInfo = nestedSection;
                nestedSection.Dirs.Add(dir);
                dir.NestedProjects.AddRange(group.Select(pr => new ProjectRelationInfo(pr, dir)));
            }
        }