Exemple #1
0
        protected virtual bool TryLoad(XDocument doc)
        {
            var guidNode          = doc.XPathSelectElement(@"/x:Project/x:PropertyGroup/x:ProjectGuid", NamespaceManager);
            var targetNode        = doc.XPathSelectElements(@"/x:Project/x:PropertyGroup/x:PlatformTarget", NamespaceManager).FirstOrDefault();
            var startupObjectNode = doc.XPathSelectElement(@"/x:Project/x:PropertyGroup/x:StartupObject", NamespaceManager);
            var referenceNodes    = doc.XPathSelectElements(@"/x:Project/x:ItemGroup/x:ProjectReference", NamespaceManager).ToList();
            var forcedOutputNode  = doc.XPathSelectElement(@"/x:Project/x:Target[@Name='GetForcedOutput']", NamespaceManager);

            GUID          = Guid.Parse(guidNode.Value);
            StartupObject = startupObjectNode != null ? startupObjectNode.Value : string.Empty;
            Target        = targetNode != null ? targetNode.Value : "Any CPU";
            var dir = System.IO.Path.GetDirectoryName(Path);

            var references = new List <Project>();

            foreach (var node in referenceNodes)
            {
                var     path = System.IO.Path.GetFullPath(System.IO.Path.Combine(dir, node.Attribute("Include").Value.Replace(@"\", "/")));
                Project project;
                if (!Project.TryLoadFromFile(path, out project))
                {
                    return(false);
                }
                references.Add(project);
            }

            References      = references;
            HasForcedOutput = (forcedOutputNode != null);
            return(true);
        }
Exemple #2
0
        private static void HandleGenerateSolution(string mainProjectPath, string binariesPath, IEnumerable <string> additionalProjectsPaths, string output, bool generateEntryProject)
        {
            Project mainProject;

            if (!Project.TryLoadFromFile(mainProjectPath, out mainProject))
            {
                Console.Error.WriteLine("Could not load main project");
                return;
            }

            var additionalProjects = new List <Project>();

            foreach (var additionalProjectPath in additionalProjectsPaths ?? Enumerable.Empty <string>())
            {
                Project additionalProject;
                if (!Project.TryLoadFromFile(additionalProjectPath, out additionalProject))
                {
                    Console.Error.WriteLine("Could not load additional project: {0}", additionalProject);
                    return;
                }
                additionalProjects.Add(additionalProject);
            }

            var solution = SolutionGenerator.Generate(mainProject, generateEntryProject, binariesPath, additionalProjects);

            if (output == null)
            {
                Console.WriteLine(solution);
            }
            else
            {
                solution.Save(output);
                solution.SaveTestsFile(Path.Combine(output, testsFileName));
            }
        }
Exemple #3
0
        private static void HandleGenerateSolution(Options options)
        {
            Project mainProject;

            if (!Project.TryLoadFromFile(options.MainProject, out mainProject))
            {
                Console.Error.WriteLine("Could not load main project");
                return;
            }

            var additionalProjects = new List <Project>();

            foreach (var additionalProjectPath in options.AdditionalProjects ?? Enumerable.Empty <string>())
            {
                Project additionalProject;
                if (!Project.TryLoadFromFile(additionalProjectPath, out additionalProject))
                {
                    Console.Error.WriteLine("Could not load additional project: {0}", additionalProject);
                    return;
                }
                additionalProjects.Add(additionalProject);
            }

            var solution = SolutionGenerator.Generate(options.SolutionName, mainProject, options.GenerateEntryProject, options.BinariesDirectory, additionalProjects);

            if (options.OutputDirectory == null)
            {
                Console.WriteLine(solution);
            }
            else
            {
                var configuration = new Configuration(solution, options.RobotTests.Select(x => new RobotTestSuite(x)));
                configuration.Save(options.OutputDirectory);
            }
        }
Exemple #4
0
 public void ScanDirectory(string directory)
 {
     try
     {
         foreach (var file in Directory.GetFiles(directory, "*.csproj", SearchOption.AllDirectories))
         {
             Project project;
             if (Project.TryLoadFromFile(Path.GetFullPath(file), out project))
             {
                 Projects.Add(project);
             }
         }
     }
     catch (UnauthorizedAccessException)
     {
         // just skip folders you have no access rights to
     }
 }