Ejemplo n.º 1
0
        private static void RunTestProject(string project,
                                           string[] frameworks,
                                           BuildPlan buildPlan,
                                           DotNetExecutor dotnet,
                                           string xunitTools,
                                           List <string> failures)
        {
            var testFolder = Path.Combine(buildPlan.Root, "tests", project);

            if (dotnet.Build(testFolder) != 0)
            {
                failures.Add($"Test build failed: {project}");
            }

            foreach (var framework in frameworks)
            {
                if (framework == "dnx451")
                {
                    if (!RunTestProjectForFullCLR(testFolder, project, xunitTools))
                    {
                        failures.Add($"Test failed: {project} / {framework}");
                    }
                }
                else
                {
                    if (dotnet.Test(testFolder) != 0)
                    {
                        failures.Add($"Test failed: {project} / {framework}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static bool RunTests(BuildPlan buildPlan)
        {
            var xunitTools = PrepareTools(buildPlan);
            var dotnet     = new DotNetExecutor(buildPlan);
            var failures   = new List <string>();

            dotnet.Restore(Path.Combine(buildPlan.Root, "src"));
            dotnet.Restore(Path.Combine(buildPlan.Root, "tests"));

            foreach (var pair in buildPlan.TestProjects)
            {
                RunTestProject(pair.Key, pair.Value, buildPlan, dotnet, xunitTools, failures);
            }

            if (failures.Any())
            {
                foreach (var f in failures)
                {
                    Console.Error.WriteLine(f);
                }

                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 3
0
        private static void RunTestProject(string project,
                                           string[] frameworks,
                                           BuildPlan buildPlan,
                                           DotNetExecutor dotnet,
                                           string xunitTools,
                                           List<string> failures)
        {
            var testFolder = Path.Combine(buildPlan.Root, "tests", project);

            if (dotnet.Build(testFolder) != 0)
            {
                failures.Add($"Test build failed: {project}");
            }

            foreach (var framework in frameworks)
            {
                if (framework == "dnx451")
                {
                    if (!RunTestProjectForFullCLR(testFolder, project, xunitTools))
                    {
                        failures.Add($"Test failed: {project} / {framework}");
                    }
                }
                else
                {
                    if (dotnet.Test(testFolder) != 0)
                    {
                        failures.Add($"Test failed: {project} / {framework}");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static bool RunTests(BuildPlan buildPlan)
        {
            var xunitTools = PrepareTools(buildPlan);
            var dotnet = new DotNetExecutor(buildPlan);
            var failures = new List<string>();
            
            dotnet.Restore(Path.Combine(buildPlan.Root, "src"));
            dotnet.Restore(Path.Combine(buildPlan.Root, "tests"));

            foreach (var pair in buildPlan.TestProjects)
            {
                RunTestProject(pair.Key, pair.Value, buildPlan, dotnet, xunitTools, failures);
            }

            if (failures.Any())
            {
                foreach (var f in failures)
                {
                    Console.Error.WriteLine(f);
                }
                
                return false;
            }
            else
            {
                return true;
            }
        }
Ejemplo n.º 5
0
        public static int Main(string[] args)
        {
            Console.WriteLine("Publish project OmniSharp");
            var root      = FindRoot();
            var buildPlan = BuildPlan.Parse(root);

            var projectPath = Path.Combine(root, "src", buildPlan.MainProject);

            if (!Directory.Exists(projectPath))
            {
                Console.WriteLine($"Can't find project {buildPlan.MainProject}");
                return(1);
            }

            var publishOutput = Path.Combine(root, buildPlan.ArtifactsFolder, "publish");

            if (!Directory.Exists(publishOutput))
            {
                Directory.CreateDirectory(publishOutput);
            }

            var packageOutput = Path.Combine(root, buildPlan.ArtifactsFolder, "package");

            if (!Directory.Exists(packageOutput))
            {
                Directory.CreateDirectory(packageOutput);
            }

            var dotnetExecutable = new DotNetExecutor(buildPlan);

            Console.WriteLine($"       root: {root}");
            Console.WriteLine($"    project: {buildPlan.MainProject}");
            Console.WriteLine($"     dotnet: {dotnetExecutable}");
            Console.WriteLine($"     source: {projectPath}");
            Console.WriteLine($"publish out: {publishOutput}");
            Console.WriteLine($"package out: {packageOutput}");
            Console.WriteLine($" frameworks: {string.Join(", ", buildPlan.Frameworks)}");
            Console.WriteLine($"    runtime: {string.Join(", ", buildPlan.Rids)}");

            if (!TestActions.RunTests(buildPlan))
            {
                return(1);
            }

            if (dotnetExecutable.Restore(Path.Combine(root, "src")) != 0)
            {
                Console.Error.WriteLine("Fail to restore projects for {rid}");
                return(1);
            }

            foreach (var rid in buildPlan.Rids)
            {
                foreach (var framework in buildPlan.Frameworks)
                {
                    var publish = Path.Combine(publishOutput, buildPlan.MainProject, rid, framework);
                    if (dotnetExecutable.Publish(publish, projectPath, rid, framework) != 0)
                    {
                        Console.Error.WriteLine($"Fail to publish {projectPath} on {framework} for {rid}");
                        return(1);
                    }

                    Package(publish, packageOutput, buildPlan.MainProject, rid, framework);
                }
            }

            return(0);
        }
Ejemplo n.º 6
0
        public static int Main(string[] args)
        {
            Console.WriteLine("Publish project OmniSharp");
            var root = FindRoot();
            var buildPlan = BuildPlan.Parse(root);

            var projectPath = Path.Combine(root, "src", buildPlan.MainProject);
            if (!Directory.Exists(projectPath))
            {
                Console.WriteLine($"Can't find project {buildPlan.MainProject}");
                return 1;
            }

            var publishOutput = Path.Combine(root, buildPlan.ArtifactsFolder, "publish");
            if (!Directory.Exists(publishOutput))
            {
                Directory.CreateDirectory(publishOutput);
            }

            var packageOutput = Path.Combine(root, buildPlan.ArtifactsFolder, "package");
            if (!Directory.Exists(packageOutput))
            {
                Directory.CreateDirectory(packageOutput);
            }

            var dotnetExecutable = new DotNetExecutor(buildPlan);

            Console.WriteLine($"       root: {root}");
            Console.WriteLine($"    project: {buildPlan.MainProject}");
            Console.WriteLine($"     dotnet: {dotnetExecutable}");
            Console.WriteLine($"     source: {projectPath}");
            Console.WriteLine($"publish out: {publishOutput}");
            Console.WriteLine($"package out: {packageOutput}");
            Console.WriteLine($" frameworks: {string.Join(", ", buildPlan.Frameworks)}");
            Console.WriteLine($"    runtime: {string.Join(", ", buildPlan.Rids)}");

            if (!TestActions.RunTests(buildPlan))
            {
                return 1;
            }

            if (dotnetExecutable.Restore(Path.Combine(root, "src")) != 0)
            {
                Console.Error.WriteLine("Fail to restore projects for {rid}");
                return 1;
            }

            foreach (var rid in buildPlan.Rids)
            {
                foreach (var framework in buildPlan.Frameworks)
                {
                    var publish = Path.Combine(publishOutput, buildPlan.MainProject, rid, framework);
                    if(dotnetExecutable.Publish(publish, projectPath, rid, framework) != 0)
                    {
                        Console.Error.WriteLine($"Fail to publish {projectPath} on {framework} for {rid}");
                        return 1;
                    }

                    Package(publish, packageOutput, buildPlan.MainProject, rid, framework);
                }
            }

            return 0;
        }