/// <summary>
        /// Completely delete the contents of a solution folder
        /// </summary>
        ///
        public void DeleteSolutionFolderContents(VisualStudioSolutionProjectReference solutionFolder)
        {
            Guard.NotNull(solutionFolder, nameof(solutionFolder));

            if (solutionFolder.TypeId != VisualStudioProjectTypeIds.SolutionFolder)
            {
                throw new ArgumentException("Not a solution folder", "solutionFolder");
            }

            var solutionFolderId = solutionFolder.Id;

            for (;;)
            {
                var childProject =
                    NestedProjects
                    .Where(np => np.ParentProjectId == solutionFolderId)
                    .Select(np => GetProjectReference(np.ChildProjectId))
                    .FirstOrDefault();
                if (childProject == null)
                {
                    break;
                }

                if (childProject.TypeId == VisualStudioProjectTypeIds.SolutionFolder)
                {
                    DeleteSolutionFolder(childProject);
                }
                else
                {
                    DeleteProjectReferenceAndRelated(childProject);
                }
            }
        }
Example #2
0
 public void ReorderProjects()
 {
     projects = projects.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase).ToList();
     solution_configuration_platforms = solution_configuration_platforms.OrderBy(s => s, StringComparer.OrdinalIgnoreCase).ToList();
     nested_projects = NestedProjects.OrderBy(g => g.Key, StringComparer.OrdinalIgnoreCase).SelectMany(g => g.OrderBy(n => n.Item, StringComparer.OrdinalIgnoreCase)).ToList();
     project_configuration_platforms = project_configuration_platforms.OrderBy(c => projects.IndexOf(projects.First(p => p.ProjectGuid == c.ProjectGuid)))
                                       .ThenBy(c => c.SolutionConfigurationName, StringComparer.OrdinalIgnoreCase)
                                       .ThenBy(c => c.Property, StringComparer.OrdinalIgnoreCase)
                                       .ToList();
 }
        /// <summary>
        /// Delete a project reference and anything else relating to it
        /// </summary>
        ///
        public void DeleteProjectReferenceAndRelated(VisualStudioSolutionProjectReference projectReference)
        {
            Guard.NotNull(projectReference, nameof(projectReference));

            var projectId = projectReference.Id;

            //
            // Delete related NestedProjects entries
            //
            for (;;)
            {
                var nesting =
                    NestedProjects.FirstOrDefault(n => n.ParentProjectId == projectId || n.ChildProjectId == projectId);
                if (nesting == null)
                {
                    break;
                }

                DeleteNestedProject(nesting);
            }

            //
            // Delete related project configurations
            //
            for (;;)
            {
                var configuration = ProjectConfigurations.FirstOrDefault(c => c.ProjectId == projectId);
                if (configuration == null)
                {
                    break;
                }

                DeleteProjectConfiguration(configuration);
            }

            //
            // Delete the project reference itself
            //
            DeleteProjectReference(GetProjectReference(projectId));
        }