Exemple #1
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);
                }
            }
        }
Exemple #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);
                }
            }
        }