Пример #1
0
        private static void ParseProjectInfo(ISolutionProjectInfo projectInfo, FilePathAbsolute baseDirectory, List<FilePathAbsolute> filePathListe)
        {
            string rawProjectPath = baseDirectory.ParentDirectoryPath.Path + @"\" + projectInfo.RawProjectPath;
            FilePathAbsolute absoluteProjectPath = new FilePathAbsolute(rawProjectPath);

            if (!absoluteProjectPath.Path.EndsWith(".csproj")) { return; }
            IProjectInfo project = new Project(absoluteProjectPath.FileInfo);

            foreach (var referenceInfo in project.ProjectReferenceListe)
            {
                try
                {
                    string rawReferencePath = absoluteProjectPath.ParentDirectoryPath.Path + @"\" + referenceInfo.RawReferencePath;
                    FilePathAbsolute absoluteReferencePath = new FilePathAbsolute(rawReferencePath);
                    filePathListe.Add(absoluteReferencePath);
                }
                catch (Exception) { }
            }
            foreach (var referenceInfo in project.AssemblyReferenceListe)
            {
                try
                {
                    string rawReferencePath = absoluteProjectPath.ParentDirectoryPath.Path + @"\" + referenceInfo.RawReferencePath;
                    FilePathAbsolute absoluteReferencePath = new FilePathAbsolute(rawReferencePath);
                    filePathListe.Add(absoluteReferencePath);
                }
                catch (Exception) { }
            }

            filePathListe.Add(absoluteProjectPath);
        }
Пример #2
0
        public void TestLoadProject()
        {
            MockProject expectedProject = MockDatenGenerator.SAPLogonPadUpdater;

            FileInfo projectFile = new FileInfo(Properties.Settings.Default.BaseTestDataPath + "SAPLogonPadUpdater.csproj");
            Project project = new Project(projectFile);

            Assert.AreEqual(expectedProject.RawProjectPath, project.RawProjectPath);
            Assert.AreEqual(expectedProject.ProductVersion, project.ProductVersion);
            Assert.AreEqual(expectedProject.ProjectFile.FullName, project.ProjectFile.FullName);
            Assert.AreEqual(expectedProject.ProjectGuid, project.ProjectGuid);
            Assert.AreEqual(expectedProject.ProjectName, project.ProjectName);
            Assert.AreEqual(expectedProject.RawContent, project.RawContent);
            Assert.AreEqual(expectedProject.RootNameSpace, project.RootNameSpace);

            Assert.AreEqual<int>(expectedProject.AssemblyReferenceListe.Count, project.AssemblyReferenceListe.Count);
            AssemblyReferenceListeEquivalent(expectedProject.AssemblyReferenceListe, project.AssemblyReferenceListe);
            Assert.AreEqual<int>(expectedProject.ProjectReferenceListe.Count, project.ProjectReferenceListe.Count);
            ProjectReferenceListeEquivalent(expectedProject.ProjectReferenceListe, project.ProjectReferenceListe);
        }
Пример #3
0
        static void Main(string[] args)
        {
            FileInfo[] fis = (new DirectoryInfo("c:\\dev")).GetFiles("*.sln", SearchOption.AllDirectories);

            FileInfo logfile = new FileInfo("c:\\output2.txt");
            if (logfile.Exists)
            {
                logfile.Delete();
            }

            using (StreamWriter sw = new StreamWriter(logfile.FullName, false))
            {
                foreach (var item in fis)
                {
                    try
                    {
                        List<ISolutionInfo> solutions = new List<ISolutionInfo>();
                        solutions.Add(new Solution(item));
                        ProductSourceStructure structure = new ProductSourceStructure(solutions);

                        IList<string> liste = structure.UniqueDirectoryListe;
                        List<string> sorted = new List<string>(structure.RootDirectoryListe);
                        sorted.Sort();

                        string error = string.Empty;
                        foreach (var item2 in sorted)
                        {
                            if (!item2.StartsWith("c:\\dev\\"))
                            {
                                error += item2 + Environment.NewLine;
                            }
                        }
                        if (!string.IsNullOrEmpty(error))
                        {
                            Console.WriteLine("there were items referenced that where outside of c:\\dev in " + item.FullName);
                            Console.WriteLine(error);
                        }
                        else
                        {
                            string solutionName = solutions[0].SolutionFile.FullName;
                            Console.WriteLine(solutionName);

                            sw.WriteLine(solutionName + ";;;");

                            foreach (var project in solutions[0].ProjectListe)
                            {
                                Project p = new Project(new FileInfo(Path.Combine(solutions[0].SolutionFile.DirectoryName, project.RawProjectPath)));
                                sw.WriteLine(solutionName + ";" + p.ProjectFile.FullName + ";;");

                                foreach (var assembly in p.AssemblyReferenceListe)
                                {
                                    FileInfo fi = new FileInfo(Path.Combine(p.ProjectFile.DirectoryName, assembly.RawHintPath));

                                    sw.WriteLine(solutionName + ";" + p.ProjectFile.FullName + ";" + fi.FullName + ";\"" + assembly.RawInclude + "\"");
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error parsing " + item.FullName);
                        Console.WriteLine(ex.GetType().ToString() + ": " + ex.Message);
                        //Console.WriteLine(ex.StackTrace);
                    }
                }
                sw.Flush();
                sw.Close();
            }
            Console.WriteLine("Done");
            Console.Read();
        }