public static void AddProjectNesting(this SolutionFile solutionFile, ProjectNesting projectNesting)
        {
            var nestedProjectsGlobalSection = solutionFile.GlobalSections.AcquireNestedProjectsGlobalSection();

            nestedProjectsGlobalSection.ProjectNestings.Add(projectNesting);
        }
        public static IEnumerable <SolutionFileProjectReference> GetDependencyProjectReferences(this SolutionFile solutionFile)
        {
            var dependencyProjectGUIDs = solutionFile.GetDependencyProjectGUIDs();

            var dependencyProjectReferences = solutionFile.SolutionFileProjectReferences.Where(x => dependencyProjectGUIDs.Contains(x.ProjectGUID));

            return(dependencyProjectReferences);
        }
        public static void RemoveDependenciesSolutionFolder(this SolutionFile solutionFile)
        {
            var dependenciesSolutionFolder = solutionFile.GetDependenciesSolutionFolder();

            solutionFile.SolutionFileProjectReferences.Remove(dependenciesSolutionFolder);
        }
        /// <summary>
        /// Gets all project reference file paths for project in the dependencies solution folder.
        /// </summary>
        public static IEnumerable <string> GetProjectReferenceDependencyFilePaths(this SolutionFile solutionFile, string solutionFilePath)
        {
            var dependencies = solutionFile.GetDependencyProjectReferences().Select(projectReference => VsPathUtilities.GetProjectFilePath(solutionFilePath, projectReference.ProjectFileRelativePathValue));

            return(dependencies);
        }
        public static bool HasDependenciesSolutionFolder(this SolutionFile solutionFile)
        {
            var hasDependenciesSolutionFolder = solutionFile.HasDependenciesSolutionFolder(out var _);

            return(hasDependenciesSolutionFolder);
        }
        /// <summary>
        /// Must also specify dependency project file paths because the solution file types assembly does not reference the project file types assembly.
        /// </summary>
        public static void AddProjectReferenceDependencyAndAllDependenciesChecked(this SolutionFile solutionFile, string solutionFilePath, string projectFilePath, IEnumerable <string> dependencyProjectFilePaths)
        {
            solutionFile.AddProjectReferenceDependencyChecked(solutionFilePath, projectFilePath);

            solutionFile.AddProjectReferenceDependenciesChecked(solutionFilePath, dependencyProjectFilePaths);
        }
        /// <summary>
        /// Gets all project reference file paths.
        /// </summary>
        public static IEnumerable <string> GetProjectReferenceFilePaths(this SolutionFile solutionFile, string solutionFilePath)
        {
            var projectReferenceFilePaths = solutionFile.SolutionFileProjectReferences.Select(projectReference => VsPathUtilities.GetProjectFilePath(solutionFilePath, projectReference.ProjectFileRelativePathValue));

            return(projectReferenceFilePaths);
        }
        public static bool HasProjectReference(this SolutionFile solutionFile, SolutionFileProjectReference projectReference)
        {
            var hasProjectReference = solutionFile.HasProjectReferenceByProjectFileRelativePath(projectReference.ProjectFileRelativePathValue);

            return(hasProjectReference);
        }
        public static void AddProjectReferences(this SolutionFile solutionFile, string solutionFilePath, IEnumerable <string> projectFilePaths)
        {
            var projectReferences = projectFilePaths.Select(projectFilePath => SolutionFileProjectReference.NewNetCoreOrStandard(solutionFilePath, projectFilePath));

            solutionFile.AddProjectReferences(projectReferences);
        }
        public static bool HasProjectReferenceByProjectFileRelativePath(this SolutionFile solutionFile, string projectFileRelativePath)
        {
            var hasProjectReference = solutionFile.SolutionFileProjectReferences.Where(x => x.ProjectFileRelativePathValue == projectFileRelativePath).Any();

            return(hasProjectReference);
        }
        /// <summary>
        /// Adds a project reference to the solution's dependencies folder, checking first to avoid adding duplicates.
        /// </summary>
        public static void AddProjectReferenceDependencyChecked(this SolutionFile solutionFile, string solutionFilePath, string projectFilePath)
        {
            var projectReference = SolutionFileProjectReference.NewNetCoreOrStandard(solutionFilePath, projectFilePath);

            solutionFile.AddProjectReferenceDependencyChecked(projectReference);
        }
        /// <summary>
        /// Adds a project reference to a solution file under the solution dependencies solution folder.
        /// </summary>
        public static void AddProjectReferenceAsDependency(this SolutionFile solutionFile, SolutionFileProjectReference projectReference)
        {
            solutionFile.AddProjectReference(projectReference);

            solutionFile.AddProjectToDependenciesSolutionFolder(projectReference);
        }
 public static void Save(this SolutionFile solutionFile, string filePath)
 {
     SolutionFile.Save(filePath, solutionFile);
 }
        public static void Save(string solutionFilePath, SolutionFile solutionFile)
        {
            var serializer = new SolutionFileSerializer();

            serializer.Serialize(solutionFilePath, solutionFile);
        }