Ejemplo n.º 1
0
        /// <summary>
        /// Checks if a native project type really is a managed project, by checking the CLRSupport item.
        /// </summary>
        public static bool IsClr(this Project project)
        {
            bool isClr = false;

            // Null properties on the DTE project item are a common source of bugs, make sure everything is non-null before attempting this check.
            // We will default to false since CLR projects should have all of these properties set.
            if (project != null && project.FullName != null && project.ConfigurationManager != null && project.ConfigurationManager.ActiveConfiguration != null)
            {
                var vcx = new VcxProject(project.FullName);
                isClr = vcx.HasClrSupport(project.ConfigurationManager.ActiveConfiguration);
            }

            return(isClr);
        }
        public static IProjectSystem CreateProjectSystem(Project project, IFileSystemProvider fileSystemProvider)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (String.IsNullOrEmpty(project.FullName))
            {
                throw new InvalidOperationException(
                          String.Format(CultureInfo.CurrentCulture,
                                        VsResources.DTE_ProjectUnsupported, project.GetName()));
            }

#if VS14
            if (project.SupportsINuGetProjectSystem())
            {
                return(new NuGetAwareProjectSystem(project));
            }
#endif


            var guids = project.GetProjectTypeGuids();
            if (guids.Contains(VsConstants.CppProjectTypeGuid)) // Got a cpp project
            {
                var vcx = new VcxProject(project.FullName);
                if (!vcx.HasClrSupport(project.ConfigurationManager.ActiveConfiguration))
                {
                    return(new NativeProjectSystem(project, fileSystemProvider));
                }
            }



            // Try to get a factory for the project type guid
            foreach (var guid in guids)
            {
                ProjectThunk factory;
                if (_factories.TryGetValue(guid, out factory))
                {
                    return(factory(project, fileSystemProvider));
                }
            }

            // Fall back to the default if we have no special project types
            return(new VsProjectSystem(project, fileSystemProvider));
        }
Ejemplo n.º 3
0
        public static IProjectSystem CreateProjectSystem(Project project, IFileSystemProvider fileSystemProvider)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (String.IsNullOrEmpty(project.FullName))
            {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    VsResources.DTE_ProjectUnsupported, project.GetName()));
            }

#if VS14
            if (project.SupportsINuGetProjectSystem())
            {
                return new NuGetAwareProjectSystem(project);
            }
#endif


            var guids = project.GetProjectTypeGuids();
            if (guids.Contains(VsConstants.CppProjectTypeGuid)) // Got a cpp project
            {
                var vcx = new VcxProject(project.FullName);
                if (!vcx.HasClrSupport(project.ConfigurationManager.ActiveConfiguration))
                    return new NativeProjectSystem(project, fileSystemProvider);
            }



            // Try to get a factory for the project type guid            
            foreach (var guid in guids)
            {
                ProjectThunk factory;
                if (_factories.TryGetValue(guid, out factory))
                {
                    return factory(project, fileSystemProvider);
                }
            }

            // Fall back to the default if we have no special project types
            return new VsProjectSystem(project, fileSystemProvider);
        }