コード例 #1
0
        public void readProjectToProjectReferences(XmlContext doc)
        {
            var projectReferences = doc.GetNodes("//vs:ItemGroup/vs:ProjectReference/vs:Project");

            foreach (XmlElement project in projectReferences)
            {
                string id         = project.InnerText;
                var    newProject = new Project(id);
                newProject.Solution = this.Solution;    // wrong, !!
                var relativeProjectPath = Path.GetDirectoryName(this.Filename);
                newProject.Filename = Path.GetFullPath(relativeProjectPath + "\\" + project.ParentNode.Attributes["Include"].InnerText);
                newProject.Name     = Path.GetFileName(newProject.Filename);

                if (Settings.verbose)
                {
                    Console.WriteLine("  ProjectReference: " + id + " " + newProject.Name);
                }
                if (Settings.restrictToSolution && (!Solution.containsProjectId(id)))
                {
                    continue;
                }
                AddProjectToProjectDependency(newProject);
            }
        }
コード例 #2
0
        private void readProjectFileInternal()
        {
            FileInfo projectFile = new FileInfo(this.Filename);

            // defaults
            OutputName     = projectFile.Name;
            OutputType     = ConfigurationType.Unexpected;
            OutputTypeName = "";
            ProjectType    = "";

            // if the project file does not exist, we accept that no
            // additional information is available and continue.
            if (!projectFile.Exists)
            {
                Console.WriteLine("  Warning: " + this.Filename + " not found!");
                return;
            }

            XmlContext doc = new XmlContext();

            if (projectFile.Name.EndsWith(".csproj") || projectFile.Name.EndsWith(".vcproj") || projectFile.Name.EndsWith(".vcxproj"))
            {
                XmlTextReader reader = new XmlTextReader(this.Filename);
                reader.Read();
                doc.Load(reader);
                reader.Close();
                doc.SetNamespace("vs", doc.DocumentElement.NamespaceURI);
                // Xpath: // selects at any level in the document
                //        @label='foo'
            }

            // todo: .vbproj and .shproj project missing (visual basic and shared code)

            if (projectFile.Name.EndsWith(".csproj"))
            {
                // its a C# project
                Name        = "[C#] " + Name;
                ProjectType = "C#";

                var outputList = doc.GetNodes("/vs:Project/vs:PropertyGroup/vs:OutputType").ToList();
                if (outputList.Count > 0)
                {
                    OutputTypeName = outputList[0].FirstChild.Value;
                }
                var outputNameList = doc.GetNodes("/vs:Project/vs:PropertyGroup/vs:AssemblyName").ToList();
                if (outputNameList.Count > 0)
                {
                    OutputName = outputNameList[0].FirstChild.Value;
                }
                var projectGuidList = doc.GetNodes("/vs:Project/vs:PropertyGroup/vs:ProjectGuid").ToList();
                if (projectGuidList.Count > 0)
                {
                    string projectGuid = projectGuidList[0].FirstChild.Value.ToLower();
                    //Console.WriteLine("GUID: " + id + " S: " + projectGuid);
                    if ((!string.IsNullOrEmpty(Id)) && !Id.Equals(projectGuid))
                    {
                        Console.WriteLine("Project's guid (" + projectGuid + ") not equal to solution's project-guid (" + Id + "), we assue the project is right about it's own guid");
                    }
                    Id = projectGuid;
                }
                readProjectToProjectReferences(doc);
                DetermineOutputTypeByName();
            } // end C# part
            else if (projectFile.Name.EndsWith(".vcproj") || projectFile.Name.EndsWith(".vcxproj"))
            {
                // its a C++ project
                ProjectType = "C++";

                string projectGuid = doc.GetNodeContent("//vs:PropertyGroup[@Label='Globals']/vs:ProjectGuid", "").ToLower();
                if (!string.IsNullOrEmpty(projectGuid))
                {
                    //Console.WriteLine("GUID: " + id + " S: " + projectGuid);
                    if ((!string.IsNullOrEmpty(Id)) && !Id.Equals(projectGuid))
                    {
                        Console.WriteLine("Project's guid (" + projectGuid + ") not equal to solution's project-guid (" + Id + "), we assue the project is right about it's own guid");
                    }
                    Id = projectGuid;
                }

                // first try to read .vcxproj -style
                var configurations = doc.GetNodes("//vs:PropertyGroup[@Label='Configuration']");
                if (configurations.Count > 0)
                {
                    ReadVCXProjStyle(doc, configurations);
                    readProjectToProjectReferences(doc);
                }
                else
                {
                    var configs = doc.GetNodes("/vs:VisualStudioProject/vs:Configurations/vs:Configuration");
                    if (configs.Count > 0)
                    {
                        ReadVCProjStyle(configs); // before vs2010 the project xml layout was different.
                    }
                }
            } // end C++ part


            // FBT
            //< UserProperties ProjectDefines = "_SCL_SECURE_NO_WARNINGS;NOMINMAX"
            //ProjectRefers = "INFRA;FEI_CPPLIBS[SDK];HEP"
            //ProjectExlibs = "Libraries\boost;[32]Libraries\boost\lib;[64]Libraries\boost\lib64;Libraries\fftw\include;[32]Libraries\fftw\lib;[64]Libraries\fftw\lib64;Libraries\prodrivemotionlibrary_tsc_r14\include;[32]Libraries\prodrivemotionlibrary_tsc_r14\windows-x86_32\lib;[64]Libraries\prodrivemotionlibrary_tsc_r14\windows-x86_64\lib"
            //ProjectExport = "5"
            //PCHSupport = "yes"
            //ProjectType = "WinDLL"
            //ProjectUses = "common.motioninfra;common.EventsGenerator;motion2.HalMotion3;hardwareSpecific.HalMotionHardwareSpecific;common.MotionDiagnosticIOTypelib;motion2.HalMotion3Lib;hardwareSpecific.HalMotionProdriveSpecific" />


            // FEI (2012) specific extention
            var depsList = doc.GetNodes("//vs:ProjectExtensions/vs:VisualStudio/vs:UserProperties");

            if (depsList.Count > 0)
            {
                foreach (XmlAttribute a in depsList[0].Attributes)
                {
                    if (userProperties.ContainsKey(a.Name))
                    {
                        //if (Settings.verbose) Console.WriteLine("FEI UserProperties contains duplicated attibute '" + a.Name + " (ignored)");
                        continue;
                    }
                    if (!a.Value.Contains(";"))
                    {
                        //if (Settings.verbose) Console.WriteLine("FEI UserProperty[" + a.Name + "]: " + a.Value);
                    }
                    else
                    {
                        // assume it is a ; separated list.
                        //if (Settings.verbose) Console.WriteLine("FEI UserProperty[" + a.Name + "]:");
                        //foreach (string attr in a.Value.Split(';'))
                        //{
                        //    if (Settings.verbose) Console.WriteLine("  FBT reference: " + attr);
                        //}
                    }

                    userProperties[a.Name] = a.Value;
                }
            }
            // FEI (2012) specific extention
        }