private static bool IsProjectPackageReferenceCompatible(Project project)
        {
            var projectGuids = VsHierarchyUtility.GetProjectTypeGuids(project);

            if (projectGuids.Any(t => UnupgradeableProjectTypes.Contains(t)))
            {
                return(false);
            }

            // Project is supported language, and not an unsupported type
            return(UpgradeableProjectTypes.Contains(project.Kind) &&
                   projectGuids.All(projectTypeGuid => !SupportedProjectTypes.IsUnsupported(projectTypeGuid)));
        }
        private void IgnoreUnsupportProjectReference(PackageSpec project)
        {
            foreach (var frameworkInfo in project.RestoreMetadata.TargetFrameworks)
            {
                var projectReferences = new List <ProjectRestoreReference>();

                foreach (var projectReference in frameworkInfo.ProjectReferences)
                {
                    if (SupportedProjectTypes.IsSupportedProjectExtension(projectReference.ProjectPath))
                    {
                        projectReferences.Add(projectReference);
                    }
                }

                frameworkInfo.ProjectReferences = projectReferences;
            }
        }
示例#3
0
        public static bool IsSupported(EnvDTE.Project envDTEProject)
        {
            Assumes.Present(envDTEProject);

            ThreadHelper.ThrowIfNotOnUIThread();

            if (SupportsProjectKPackageManager(envDTEProject))
            {
                return(true);
            }

            if (IsProjectCapabilityCompliant(envDTEProject))
            {
                return(true);
            }

            return(envDTEProject.Kind != null && SupportedProjectTypes.IsSupported(envDTEProject.Kind) && !HasUnsupportedProjectCapability(envDTEProject));
        }
示例#4
0
        public async Task <IEnumerable <string> > GetReferencedProjectsAsync()
        {
            if (!IsDeferred)
            {
                if (Project.Kind != null &&
                    SupportedProjectTypes.IsSupportedForAddingReferences(Project.Kind))
                {
                    return(EnvDTEProjectUtility.GetReferencedProjects(Project).Select(p => p.UniqueName));
                }

                return(Enumerable.Empty <string>());
            }
            else
            {
                if (ProjectTypeGuids.All(SupportedProjectTypes.IsSupportedForAddingReferences))
                {
                    return(await _workspaceService.GetProjectReferencesAsync(FullProjectPath));
                }

                return(Enumerable.Empty <string>());
            }
        }
示例#5
0
 private static bool SupportsBindingRedirects(EnvDTE.Project Project)
 {
     return((Project.Kind != null && SupportedProjectTypes.IsSupportedForBindingRedirects(Project.Kind)) &&
            !EnvDTEProjectInfoUtility.IsWindowsStoreApp(Project));
 }
示例#6
0
        public static async Task <bool> IsNuGetProjectUpgradeableAsync(NuGetProject nuGetProject, Project envDTEProject = null)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (nuGetProject == null && envDTEProject == null)
            {
                return(false);
            }

            if (nuGetProject == null)
            {
                var solutionManager = ServiceLocator.GetInstance <IVsSolutionManager>();

                var projectSafeName = await EnvDTEProjectInfoUtility.GetCustomUniqueNameAsync(envDTEProject);

                nuGetProject = await solutionManager.GetNuGetProjectAsync(projectSafeName);

                if (nuGetProject == null)
                {
                    return(false);
                }
            }

            // check if current project is packages.config based or not
            var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject;

            if (msBuildNuGetProject == null || !msBuildNuGetProject.PackagesConfigNuGetProject.PackagesConfigExists())
            {
                return(false);
            }

            // this further check if current project system supports VSProject4 or not which is essential to skip
            // projects like c++ which currently doesn't support VSProject4 implementation for PackageReference
            if (!msBuildNuGetProject.ProjectServices.Capabilities.SupportsPackageReferences)
            {
                return(false);
            }

            if (envDTEProject == null)
            {
                var vsmsBuildNuGetProjectSystem =
                    msBuildNuGetProject.ProjectSystem as VsMSBuildProjectSystem;
                if (vsmsBuildNuGetProjectSystem == null)
                {
                    return(false);
                }
                envDTEProject = vsmsBuildNuGetProjectSystem.VsProjectAdapter.Project;
            }

            if (!EnvDTEProjectUtility.IsSupported(envDTEProject))
            {
                return(false);
            }
            var projectGuids = VsHierarchyUtility.GetProjectTypeGuids(envDTEProject);

            if (projectGuids.Any(t => UnupgradeableProjectTypes.Contains(t)))
            {
                return(false);
            }

            // Project is supported language, and not an unsupported type
            return(UpgradeableProjectTypes.Contains(envDTEProject.Kind) &&
                   projectGuids.All(projectTypeGuid => !SupportedProjectTypes.IsUnsupported(projectTypeGuid)));
        }
示例#7
0
        public static bool IsExplicitlyUnsupported(EnvDTE.Project envDTEProject)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            return(envDTEProject.Kind == null || SupportedProjectTypes.IsUnsupported(envDTEProject.Kind));
        }