Beispiel #1
0
        private async Task <bool> IsCpsProjectAsync(string projFile)
        {
            string[] targetFrameworkTags = { "</TargetFramework>", "</TargetFrameworks>" };

            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            var solution = await _vsShellService.GetVsSolutionAsync();

            solution.GetProjectOfUniqueName(projFile, out IVsHierarchy hierarchy);
            if (hierarchy != null)
            {
                return(hierarchy.IsCapabilityMatch("CPS"));
            }
            else
            {
                // Detect if project is CPS project system based
                // https://github.com/dotnet/project-system/blob/master/docs/opening-with-new-project-system.md
                return(targetFrameworkTags.Any(t => File.ReadAllText(projFile).Contains(t)));
            }
        }
Beispiel #2
0
        private async Task <string> GetProjectTypeGuidAsync(Project project)
        {
            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (project != null)
            {
                var solution = await _vsShellService.GetVsSolutionAsync();

                solution.GetProjectOfUniqueName(project.FullName, out IVsHierarchy hierarchy);

                if (hierarchy is IVsAggregatableProjectCorrected aggregatableProject)
                {
                    aggregatableProject.GetAggregateProjectTypeGuids(out string projTypeGuids);

                    return(projTypeGuids);
                }
            }

            return(string.Empty);
        }