예제 #1
0
        private List <ProjectDetails> GetProjects(string pathToSolution)
        {
            var solution = SolutionFile.Parse(pathToSolution);

            var projects = solution.ProjectsInOrder.Select(p =>
            {
                if (p.ProjectType != SolutionProjectType.KnownToBeMSBuildFormat && p.ProjectType != SolutionProjectType.WebProject)
                {
                    return(null);
                }

                var projectParser = new ProjectFileParser(p.AbsolutePath);

                return(new ProjectDetails
                {
                    ProjectName = p.ProjectName,
                    ProjectFilePath = p.AbsolutePath,
                    ProjectGuid = p.ProjectGuid,
                    TargetFrameworks = projectParser.GetTargetFrameworks().ConvertAll(tfm =>
                    {
                        var framework = NuGetFramework.Parse(tfm);
                        return string.Format("{0} {1}", framework.Framework, NuGetVersion.Parse(framework.Version.ToString()).ToNormalizedString());
                    }),
                    PackageReferences = projectParser.GetPackageReferences()
                });
            }).Where(p => p != null).ToList();

            return(projects);
        }
예제 #2
0
        public void ParseProjectWithCorruptContentThrowsException()
        {
            var corruptProjectFileParser = new ProjectFileParser(Path.Combine(TestContext.CurrentContext.TestDirectory,
                                                                              "TestXml", "SolutionWithFailedContent", "test", "ProjectWithCorruptContent.csproj"));

            Assert.AreEqual(0, corruptProjectFileParser.GetPackageReferences().Count);
        }
예제 #3
0
        public void ParseProjectInWrongDirectoryThrowsException()
        {
            var path = Path.Combine(TestContext.CurrentContext.TestDirectory,
                                    "TestXml", "SolutionWithFailedContent", "ProjectInWrongDirectory.csproj");

            Assert.Throws <PortingAssistantClientException>(() =>
            {
                var projectFileParser = new ProjectFileParser(path);
                projectFileParser.GetPackageReferences();
            });
        }
예제 #4
0
        public void ParseProjectWithProjectReferencesSucceeds()
        {
            var path = Path.Combine(TestContext.CurrentContext.TestDirectory,
                                    "TestXml", "ProjectWithReference", "ProjectWithReference.csproj");
            var handler = new ProjectFileParser(path);

            Assert.AreEqual(4, handler.GetPackageReferences().Count);
            Assert.AreEqual(1, handler.GetProjectReferences().Count);
            Assert.AreEqual(1, handler.GetTargetFrameworks().Count);
            Assert.AreEqual("netcoreapp3.1", handler.GetTargetFrameworks().First());
        }