Пример #1
0
        internal static IList <EnvDTE.Project> GetReferencedProjects(EnvDTE.Project envDTEProject)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (EnvDTEProjectInfoUtility.IsWebSite(envDTEProject))
            {
                return(GetWebsiteReferencedProjects(envDTEProject));
            }

            var        envDTEProjects = new List <EnvDTE.Project>();
            References references;

            try
            {
                references = GetReferences(envDTEProject);
            }
            catch (RuntimeBinderException)
            {
                //References property doesn't exist, project does not have references
                references = null;
            }
            if (references != null)
            {
                foreach (Reference reference in references)
                {
                    var reference3 = reference as Reference3;

                    // Get the referenced project from the reference if any
                    // C++ projects will throw on reference.SourceProject if reference3.Resolved is false.
                    // It's also possible that the referenced project is the project itself
                    // for C++ projects. In this case this reference should be skipped to avoid circular
                    // references.
                    if (reference3 != null &&
                        reference3.Resolved &&
                        reference.SourceProject != null &&
                        reference.SourceProject != envDTEProject)
                    {
                        envDTEProjects.Add(reference.SourceProject);
                    }
                }
            }
            return(envDTEProjects);
        }
Пример #2
0
        private static HashSet <string> GetLocalProjectAssemblies(EnvDTE.Project envDTEProject)
        {
            Debug.Assert(ThreadHelper.CheckAccess());

            if (EnvDTEProjectInfoUtility.IsWebSite(envDTEProject))
            {
                var websiteLocalAssemblies = GetWebsiteLocalAssemblies(envDTEProject);
                return(websiteLocalAssemblies);
            }

            var        assemblies = new HashSet <string>(PathComparer.Default);
            References references;

            try
            {
                references = GetReferences(envDTEProject);
            }
            catch (RuntimeBinderException)
            {
                //References property doesn't exist, project does not have references
                references = null;
            }
            if (references != null)
            {
                foreach (Reference reference in references)
                {
                    var reference3 = reference as Reference3;

                    // Get the referenced project from the reference if any
                    // In C++ projects if reference3.Resolved is false reference3.SourceProject will throw.
                    if (reference3 != null &&
                        reference3.Resolved &&
                        reference.SourceProject == null &&
                        reference.CopyLocal &&
                        File.Exists(reference.Path))
                    {
                        assemblies.Add(reference.Path);
                    }
                }
            }
            return(assemblies);
        }