Beispiel #1
0
        internal void OnSolutionOpen(IVsSolution solution)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var loadedProjects = SolutionHelper.GetLoadedProjectsInSolution(solution);

            foreach (var loadedProject in loadedProjects)
            {
                AddProjectReferencesToSolution(solution, loadedProject);
            }
        }
Beispiel #2
0
        internal void AddProjectReferencesToSolution(IVsSolution solution, KeyValuePair <string, IVsHierarchy> project)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var referencedProjectPaths = new List <string>();

            try
            {
                referencedProjectPaths = ProjectHelper.GetProjectReferencePaths(project);
            }
            catch (Exception e)
            {
                PackageHelper.WriteMessage("*** FAILED to read project references. ***\t" + e.Message);
            }

            foreach (string referencedProjectPath in referencedProjectPaths)
            {
                PackageHelper.WriteMessage(string.Empty);

                try
                {
                    var newProjectHierarchy = SolutionHelper.AddProjectToSolution(solution, referencedProjectPath);

                    if (newProjectHierarchy != null)
                    {
                        AddProjectReferencesToSolution(solution, new KeyValuePair <string, IVsHierarchy>(referencedProjectPath, newProjectHierarchy));
                    }
                }
                catch (Exception e)
                {
                    PackageHelper.WriteMessage("*** FAILED to resolve project properties. ***\t" + e.Message);
                }
            }

            SharedProjectHelper.AddSharedProjectReferencesToSolution(solution, project.Key);
        }