예제 #1
0
        private int RunBuild(ICollection <string> args, TargetTree targetTree)
        {
            if (targetTree == null)
            {
                throw new ArgumentNullException("targetTree");
            }

            using (TaskSession session = new TaskSession(new SimpleTaskContextProperties(), args, targetTree))
            {
                session.IsInteractive = InteractiveSessionDetectionFunc();

                BuildTargets.FillDefaultProperties(session);
                session.Start(BuildTargets.OnBuildFinished);

                session.AddLogger(new MulticoloredConsoleLogger(Console.Out));

                ConfigureBuildProperties(session);
                bool   targetFoundInTargetTree;
                string targetToRun = ParseCmdLineArgs(args.ToList(), session, targetTree, out targetFoundInTargetTree);

                if (targetToRun == null)
                {
                    ITarget defaultTarget = targetTree.DefaultTarget;
                    if (defaultTarget == null)
                    {
                        throw new InvalidOperationException("The default build target is not defined");
                    }

                    targetTree.RunTarget(session, defaultTarget.TargetName);
                }
                else
                {
                    if (!targetFoundInTargetTree)
                    {
                        session.WriteError("ERROR: The specified target does not exist");
                        targetTree.RunTarget(session, targetToRun);
                        return(2);
                    }

                    targetTree.RunTarget(session, targetToRun);
                }

                session.Complete();

                return(0);
            }
        }
예제 #2
0
        public static int Main(string[] args)
        {
            TargetTree targetTree = new TargetTree();
            BuildTargets.FillBuildTargets(targetTree);

            int testsRunCounter = 0;

            targetTree.AddTarget("rebuild")
                .SetAsDefault()
                .SetDescription("Rebuilds the whole project")
                .DependsOn("compile", "fxcop", "tests", "package");

            targetTree.GetTarget("fetch.build.version")
                .Do(TargetFetchBuildVersion);

            targetTree.AddTarget("tests")
                .SetDescription("Runs unit tests")
                .Do(r =>
                    {
                        BuildTargets.TargetRunTests(r, "Detergent.Tests", null, ref testsRunCounter);
                    }).DependsOn("load.solution");

            targetTree.AddTarget("package")
                .SetDescription("Packages the build")
                .Do(TargetPackage).DependsOn("load.solution", "fetch.build.version");

            targetTree.AddTarget("nuget")
                .SetDescription("Produces NuGet packages for reusable components and publishes them to the NuGet server")
                .Do(c =>
                    {
                        TargetNuGet(c, "Detergent");
                    }).DependsOn("fetch.build.version");

            using (TaskSession session = new TaskSession(new SimpleTaskContextProperties(), args, targetTree))
            {
                BuildTargets.FillDefaultProperties(session);
                session.Start(BuildTargets.OnBuildFinished);

                session.AddLogger(new MulticoloredConsoleLogger(Console.Out));

                //session.Properties.Set(BuildProps.TargetDotNetVersion, "v4.0.30319");
                //session.Properties.Set(BuildProps.TargetDotNetVersionForGallio, "v4.0.30319");
                session.Properties.Set(BuildProps.CompanyName, CompanyName);
                session.Properties.Set(BuildProps.CompanyCopyright, CompanyCopyright);
                session.Properties.Set(BuildProps.GallioEchoPath, "lib/Gallio-3.2.750/bin/Gallio.Echo.exe");
                session.Properties.Set(BuildProps.ProductId, "Detergent");
                session.Properties.Set(BuildProps.ProductName, "Detergent");
                session.Properties.Set(BuildProps.SolutionFileName, "Detergent.2010.sln");
                session.Properties.Set(BuildProps.VersionControlSystem, VersionControlSystem.Subversion);

                try
                {
                    // actual run
                    if (args.Length == 0)
                        targetTree.RunTarget(session, targetTree.DefaultTarget.TargetName);
                    else
                    {
                        string targetName = args[0];
                        if (false == targetTree.HasTarget(targetName))
                        {
                            session.WriteError("ERROR: The target '{0}' does not exist", targetName);
                            targetTree.RunTarget(session, "help");
                            return 2;
                        }

                        targetTree.RunTarget(session, args[0]);
                    }

                    session.Complete();

                    return 0;
                }
                catch (TaskExecutionException)
                {
                    return 1;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return 1;
                }
            }
        }
예제 #3
0
        public static int Main(string[] args)
        {
            TargetTree targetTree = new TargetTree();

            BuildTargets.FillBuildTargets(targetTree);

            targetTree.GetTarget("fetch.build.version")
            .Do(TargetFetchBuildVersion);

            targetTree.AddTarget("rebuild")
            .SetDescription("Compiles the code and runs tests.")
            .SetAsDefault().DependsOn("compile", "fxcop", "unit.tests", "package");

            targetTree.AddTarget("tests")
            .SetDescription("Runs tests on the project")
            .Do(r =>
            {
                int testCounter = 0;
                BuildTargets.TargetRunTests(r, "GroundTruth.Tests", null, ref testCounter);
            }).DependsOn("load.solution");

            targetTree.AddTarget("package")
            .SetDescription("Packages all the build products into ZIP files.")
            .Do(TargetPackage)
            .SetAsDefault().DependsOn("load.solution");

            //runner.AddTarget ("package.source")
            //    .SetDescription ("Packages the souce code into ZIP file")
            //    .Do (TargetPackageSource).DependsOn ("load.solution");

            using (TaskSession session = new TaskSession(new SimpleTaskContextProperties(), args, targetTree))
            {
                BuildTargets.FillDefaultProperties(session);
                session.Start(BuildTargets.OnBuildFinished);

                session.AddLogger(new MulticoloredConsoleLogger(Console.Out));

                session.Properties.Set(BuildProps.CompanyName, "igorbrejc.net");
                session.Properties.Set(BuildProps.CompanyCopyright, "Copyright (C) 2008-2012 Igor Brejc.");
                session.Properties.Set(BuildProps.ProductId, "GroundTruth");
                session.Properties.Set(BuildProps.ProductName, "GroundTruth");
                session.Properties.Set(BuildProps.SolutionFileName, "GroundTruth.sln");
                session.Properties.Set(BuildProps.VersionControlSystem, VersionControlSystem.Mercurial);

                try
                {
                    // actual run
                    if (args.Length == 0)
                    {
                        targetTree.RunTarget(session, targetTree.DefaultTarget.TargetName);
                    }
                    else
                    {
                        string targetName = args[0];
                        if (false == targetTree.HasTarget(targetName))
                        {
                            session.WriteError("ERROR: The target '{0}' does not exist", targetName);
                            targetTree.RunTarget(session, "help");
                            return(2);
                        }

                        targetTree.RunTarget(session, args[0]);
                    }

                    session.Complete();

                    return(0);
                }
                catch (TaskExecutionException)
                {
                    return(1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return(1);
                }
            }
        }
예제 #4
0
        public static int Main(string[] args)
        {
            TargetTree targetTree = new TargetTree();

            BuildTargets.FillBuildTargets(targetTree);

            int testsRunCounter = 0;

            targetTree.AddTarget("rebuild")
            .SetAsDefault()
            .SetDescription("Rebuilds the whole project")
            .DependsOn("compile", "fxcop", "tests", "package");

            targetTree.GetTarget("fetch.build.version")
            .Do(TargetFetchBuildVersion);

            targetTree.AddTarget("tests")
            .SetDescription("Runs unit tests")
            .Do(r =>
            {
                BuildTargets.TargetRunTests(r, "Detergent.Tests", null, ref testsRunCounter);
            }).DependsOn("load.solution");

            targetTree.AddTarget("package")
            .SetDescription("Packages the build")
            .Do(TargetPackage).DependsOn("load.solution", "fetch.build.version");

            targetTree.AddTarget("nuget")
            .SetDescription("Produces NuGet packages for reusable components and publishes them to the NuGet server")
            .Do(c =>
            {
                TargetNuGet(c, "Detergent");
            }).DependsOn("fetch.build.version");

            using (TaskSession session = new TaskSession(new SimpleTaskContextProperties(), args, targetTree))
            {
                BuildTargets.FillDefaultProperties(session);
                session.Start(BuildTargets.OnBuildFinished);

                session.AddLogger(new MulticoloredConsoleLogger(Console.Out));

                //session.Properties.Set(BuildProps.TargetDotNetVersion, "v4.0.30319");
                //session.Properties.Set(BuildProps.TargetDotNetVersionForGallio, "v4.0.30319");
                session.Properties.Set(BuildProps.CompanyName, CompanyName);
                session.Properties.Set(BuildProps.CompanyCopyright, CompanyCopyright);
                session.Properties.Set(BuildProps.GallioEchoPath, "lib/Gallio-3.2.750/bin/Gallio.Echo.exe");
                session.Properties.Set(BuildProps.ProductId, "Detergent");
                session.Properties.Set(BuildProps.ProductName, "Detergent");
                session.Properties.Set(BuildProps.SolutionFileName, "Detergent.2010.sln");
                session.Properties.Set(BuildProps.VersionControlSystem, VersionControlSystem.Subversion);

                try
                {
                    // actual run
                    if (args.Length == 0)
                    {
                        targetTree.RunTarget(session, targetTree.DefaultTarget.TargetName);
                    }
                    else
                    {
                        string targetName = args[0];
                        if (false == targetTree.HasTarget(targetName))
                        {
                            session.WriteError("ERROR: The target '{0}' does not exist", targetName);
                            targetTree.RunTarget(session, "help");
                            return(2);
                        }

                        targetTree.RunTarget(session, args[0]);
                    }

                    session.Complete();

                    return(0);
                }
                catch (TaskExecutionException)
                {
                    return(1);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return(1);
                }
            }
        }