/// <summary>
        ///     Given a Solution File; Identify the new Projects that would
        /// need to be added to reflect the current dependency tree.
        /// </summary>
        /// <param name="solution">The Solution file to examine.</param>
        /// <returns>The new projects for the given solution</returns>
        internal static string[] GetNewDependenciesInSolution(SolutionFile solution, bool filterConditionalReferences)
        {
            // Get a list of projects in the solution
            IEnumerable <string> existingProjects = SolutionUtilities.GetProjectsFromSolution(solution);

            // Get an updated list of dependencies
            IEnumerable <string> resolvedNOrderReferences = MSBuildUtilities.ProjectsIncludingNOrderDependencies(existingProjects, filterConditionalReferences);

            // Filter to only new projects
            string[] newReferences = resolvedNOrderReferences.Except(existingProjects, StringComparer.InvariantCultureIgnoreCase).ToArray();

            return(newReferences);
        }
        /// <summary>
        /// Update the target solution to contain the new projects.
        /// </summary>
        /// <param name="targetSolutionPath">The path to the solution file.</param>
        /// <param name="solution">A <see cref="SolutionFile"/> that represents the solution.</param>
        /// <param name="newReferences">An <see cref="IEnumerable{string}"/> of projects to add to the solution.</param>
        /// <returns>The solution lines modified</returns>
        /// <remarks>
        ///     This internal version allows the lines to be updated in memory
        /// but does not write it to a file. This is done to assist in Unit
        /// Testing these changes.
        /// </remarks>
        internal static string[] _InsertNewProjectsInternal(string targetSolutionPath, SolutionFile solution, IEnumerable <string> newReferences)
        {
            string               solutionRoot             = PathUtilities.AddTrailingSlash(Path.GetDirectoryName(targetSolutionPath));
            List <string>        projectFragmentsToInsert = new List <string>();
            List <string>        dependencyFolderItems    = new List <string>();
            List <string>        projectConfigurationFragmentsToInsert = new List <string>();
            IEnumerable <string> solutionConfigurations = SolutionUtilities.GetSolutionConfigurations(solution);

            // Perform all the generation of the elements to insert
            string dependenciesFolderGuid;
            bool   dependenciesFolderExists = SolutionUtilities.TryGetDepedenciesFolderGuid(solution, out dependenciesFolderGuid);

            if (dependenciesFolderExists != true)
            {
                projectFragmentsToInsert.AddRange(SolutionGenerationUtilities.FragmentForSolutionFolder("Dependencies", dependenciesFolderGuid));
            }

            foreach (string newReference in newReferences)
            {
                (IEnumerable <string> ProjectFragment, string ProjectGuid)solutionFragment = SolutionGenerationUtilities.FragmentForProject(solutionRoot, newReference);
                projectFragmentsToInsert.AddRange(solutionFragment.ProjectFragment);
                dependencyFolderItems.Add(solutionFragment.ProjectGuid);
                projectConfigurationFragmentsToInsert.AddRange(SolutionGenerationUtilities.FragmentForSolutionConfiguration(solutionFragment.ProjectGuid, solutionConfigurations));
            }

            // We only want to read the file once
            string[] solutionLines = File.ReadLines(targetSolutionPath).ToArray();

            // Now each of these build upon each other; we need to evaluate
            // each of the actions completely prior to the next step.
            solutionLines = _InsertProjectFragments(solutionLines, projectFragmentsToInsert).ToArray();
            solutionLines = _InsertDependencyFolderItems(solutionLines, dependenciesFolderGuid, dependencyFolderItems).ToArray();
            solutionLines = _InsertProjectConfigurationFragments(solutionLines, projectConfigurationFragmentsToInsert).ToArray();

            return(solutionLines);
        }