Exemplo n.º 1
0
        private static Project GetProject(LexicalAnalizer lexan)
        {
            Project project = new Project();

            lexan.Expect(Semantics.PROJECT);
            lexan.MoveNext();

            lexan.Expect(Semantics.OPEN_PARENTHESIS);
            lexan.MoveNext();

            // Project Type GUID
            lexan.Expect(Semantics.QUOTED_STRING);
            project.ProjectTypeGUID = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.CLOSE_PARENTHESIS);
            lexan.MoveNext();

            lexan.Expect(Semantics.EQUALS);
            lexan.MoveNext();

            // project name
            lexan.Expect(Semantics.QUOTED_STRING);
            project.ProjectName = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.COMMA);
            lexan.MoveNext();

            // project path
            lexan.Expect(Semantics.QUOTED_STRING);
            project.ProjectPath = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.COMMA);
            lexan.MoveNext();

            // project guid
            lexan.Expect(Semantics.QUOTED_STRING);
            project.ProjectGUID = lexan.Current.Value;
            lexan.MoveNext();

            lexan.Expect(Semantics.EOL);

            while (lexan.MoveNext())
            {
                switch (lexan.Current.Token)
                {
                    case Semantics.END_PROJECT:
                        return project;
                    case Semantics.PROJECT_SECTION:
                        project.ProjectSections.Add(GetProjectSection(lexan));
                        break;
                    case Semantics.EOL:
                        break;
                    case Semantics.STRING_VALUE:
                        break;
                    default:
                        throw new Exception("Invalid Project Entry!");
                }

            }
            throw new Exception("Expecting EndProject!");
        }
Exemplo n.º 2
0
        protected void ParseProjectReferences(Dictionary <string, object> dictionary, NPanday.ProjectImporter.Parser.SlnParser.Model.Project project, NPanday.ProjectImporter.Parser.SlnParser.Model.Solution solution)
        {
            if (project.ProjectSections != null)
            {
                List <Microsoft.Build.BuildEngine.Project> projectReferenceList = new List <Microsoft.Build.BuildEngine.Project>();
                foreach (ProjectSection ps in project.ProjectSections)
                {
                    if ("WebsiteProperties".Equals(ps.Name))
                    {
                        // ProjectReferences = "{11F2FCC8-5941-418A-A0E7-42D250BA9D21}|SampleInterProject111.dll;{9F37BA7B-06F9-4B05-925D-B5BC16322E8B}|BongClassLib.dll;"

                        try
                        {
                            Regex           regex   = new Regex(PROJECT_REFERENCE_REGEX, RegexOptions.Multiline | RegexOptions.IgnoreCase);
                            MatchCollection matches = regex.Matches(ps.Map["ProjectReferences"]);


                            foreach (Match match in matches)
                            {
                                string projectReferenceGUID = match.Groups["ProjectReferenceGUID"].ToString();
                                string projectReferenceDll  = match.Groups["ProjectReferenceDll"].ToString();

                                Microsoft.Build.BuildEngine.Project prj = GetMSBuildProject(solution, projectReferenceGUID);
                                if (prj != null)
                                {
                                    projectReferenceList.Add(prj);
                                }
                            }
                        }
                        catch { }
                    }
                    else if ("ProjectDependencies".Equals(ps.Name))
                    {
                        //{0D80BE11-F1CE-409E-B9AC-039D3801209F} = {0D80BE11-F1CE-409E-B9AC-039D3801209F}

                        foreach (string key in ps.Map.Keys)
                        {
                            Microsoft.Build.BuildEngine.Project prj = GetMSBuildProject(solution, key.Replace("{", "").Replace("}", ""));
                            if (prj != null)
                            {
                                projectReferenceList.Add(prj);
                            }
                        }
                    }
                }

                dictionary.Add("InterProjectReferences", projectReferenceList.ToArray());
            }
        }