protected override void RegisterTasks()
        {
            //// ----------------------------------------------------------------------------------------------------------------------------
            var initTask = Task(
                "Init the workflow",
                _ =>
            {
                IDirectory currentDirectory = WorkDirectory.Closest(dir => dir.Name.Equals("src", StringComparison.InvariantCultureIgnoreCase));

                if (currentDirectory == null)
                {
                    throw new Exception("Could not find Src directory");
                }

                IDirectory artifacts = currentDirectory.Parent / "Artifacts";
                artifacts.EnsureExists();

                return(new
                {
                    Root = currentDirectory.Parent,
                    Artifacts = artifacts,
                    Version = "3.1.0.0",
                    Src = currentDirectory,
                    Configuration = "Debug",
                    BuildAssets = (currentDirectory / "CrystalQuartz.Build" / "Assets").AsDirectory()
                }.AsTaskResult());
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var generateCommonAssemblyInfo = Task(
                "Generate common assembly info",
                from data in initTask
                select new GenerateAssemblyInfo(data.Src / "CommonAssemblyInfo.cs")
            {
                Attributes =
                {
                    _ => new AssemblyProductAttribute("CrystalQuartz"),
                    _ => new AssemblyVersionAttribute(data.Version),
                    _ => new AssemblyFileVersionAttribute(data.Version)
                }
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var compileTypescript = Task(
                "Compile TypescriptFiles",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = "tsc",
                Arguments =
                    (data.Src / "CrystalQuartz.Web" / "Client" / "Scripts" / "Application.ts").AsFile().GetRelativePath(WorkDirectory) + " -out " +
                    (data.Src / "CrystalQuartz.Web" / "Content" / "Scripts" / "application.js").AsFile().GetRelativePath(WorkDirectory)
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var transformIndexHtml = Task(
                "Transform intex.html template",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = (data.Src / "packages").AsDirectory().Directories.Last(dir => dir.Name.StartsWith("Mono.TextTransform")) / "tools" / "TextTransform.exe",
                Arguments = data.Src / "CrystalQuartz.Web/Content" / "index.tt"
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var buildSolution = Task(
                "Build solution",
                new MsBuildTask(),

                DependsOn(generateCommonAssemblyInfo),
                DependsOn(compileTypescript),
                DependsOn(transformIndexHtml));

            //// ----------------------------------------------------------------------------------------------------------------------------
            var cleanArtifacts = Task(
                "Clean artifacts",
                from data in initTask
                select _ => data.Artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll());

            //// ----------------------------------------------------------------------------------------------------------------------------
            var generateSimplePackageNuspec = Task(
                "Generate simple package spec",
                from data in initTask
                select new GenerateNuGetSpecTask(data.Artifacts / "CrystalQuartz.Simple.nuspec")
                .Id("CrystalQuartz.Simple")
                .FillCommonProperties(data.Root / "bin" / data.Configuration, data.Version)
                .Description("Installs CrystalQuartz panel (pluggable Qurtz.NET viewer) using simple scheduler provider. This approach is appropriate for scenarios where the scheduler and a web application works in the same AppDomain.")
                .WithFiles((data.BuildAssets / "Simple").AsDirectory().Files, "content"),

                DependsOn(cleanArtifacts),
                DependsOn(buildSolution));

            //// ----------------------------------------------------------------------------------------------------------------------------
            var generateRemotePackageNuspec = Task(
                "Generate remote package spec",
                from data in initTask
                select new GenerateNuGetSpecTask(data.Artifacts / "CrystalQuartz.Remote.nuspec")
                .Id("CrystalQuartz.Remote")
                .FillCommonProperties(data.Root / "bin" / data.Configuration, data.Version)
                .Description("Installs CrystalQuartz panel (pluggable Qurtz.NET viewer) using remote scheduler provider. Note that you should set remote scheduler URI after the installation.")
                .WithFiles(data.BuildAssets.GetDirectory("Remote").Files, "content"),

                DependsOn(generateSimplePackageNuspec));

            //// ----------------------------------------------------------------------------------------------------------------------------
            var buildPackages = Task(
                "Build packages",
                from data in initTask
                select ForEach(data.Artifacts.Files.IncludeByExtension(".nuspec")).Do(
                    nuspec => new GeneratePackageTask(nuspec)
            {
                WorkDirectory = data.Artifacts,
                ToolPath      = data.Src / ".nuget" / "NuGet.exe"
            },
                    nuspec => string.Format("Generate NuGet package for {0}", nuspec.NameWithoutExtension)),

                Default(),
                DependsOn(generateRemotePackageNuspec),
                DependsOn(generateSimplePackageNuspec));
        }
Beispiel #2
0
        protected override void RegisterTasks()
        {
            //// ----------------------------------------------------------------------------------------------------------------------------
            var initTask = Task(
                "Init the workflow",
                _ =>
            {
                IDirectory currentDirectory = WorkDirectory.Closest(dir => dir.Name.Equals("src", StringComparison.InvariantCultureIgnoreCase));

                if (currentDirectory == null)
                {
                    throw new Exception("Could not find Src directory " + WorkDirectory);
                }

                IDirectory artifacts = currentDirectory.Parent / "Artifacts";
                artifacts.EnsureExists();
                artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll();

                IDirectory mergedBin = currentDirectory.Parent / "bin" / "Merged";
                mergedBin.EnsureExists();

                return(new
                {
                    Version = "4.2.1.0",
                    Configuration = "Debug",
                    Solution = new SolutionStructure(currentDirectory.Parent)
                }.AsTaskResult());
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var generateCommonAssemblyInfo = Task(
                "Generate common assembly info",
                from data in initTask
                select new GenerateAssemblyInfo(data.Solution.Src / "CommonAssemblyInfo.cs")
            {
                Attributes =
                {
                    _ => new AssemblyProductAttribute("CrystalQuartz"),
                    _ => new AssemblyVersionAttribute(data.Version),
                    _ => new AssemblyFileVersionAttribute(data.Version)
                }
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var compileTypescript = Task(
                "Compile TypescriptFiles",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = "tsc",
                Arguments =
                    (data.Solution.CrystalQuartz_Application / "Client" / "Scripts" / "Application.ts").AsFile().GetRelativePath(WorkDirectory) + " -out " +
                    (data.Solution.CrystalQuartz_Application / "Content" / "Scripts" / "application.js").AsFile().GetRelativePath(WorkDirectory)
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var transformIndexHtml = Task(
                "Transform intex.html template",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = (data.Solution.Src / "packages").AsDirectory().Directories.Last(dir => dir.Name.StartsWith("Mono.TextTransform")) / "tools" / "TextTransform.exe",
                Arguments = data.Solution.CrystalQuartz_Application / "Content" / "index.tt"
            });

            //// ----------------------------------------------------------------------------------------------------------------------------
            var buildSolution = Task(
                "Build solution",
                new MsBuildTask(),

                DependsOn(generateCommonAssemblyInfo),
                DependsOn(compileTypescript),
                DependsOn(transformIndexHtml));

            //// ----------------------------------------------------------------------------------------------------------------------------
            var cleanArtifacts = Task(
                "Clean artifacts",
                from data in initTask
                select _ => data.Solution.Artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll());

            var mergeBinaries = Task(
                "MergeBinaries",

                from data in initTask
                select new MergeBinariesTask(data.Solution, data.Configuration).AsSubflow(),

                DependsOn(buildSolution));


            var generateNuspecs = Task(
                "GenerateNuspecs",
                from data in initTask
                select new GenerateNuspecsTask(data.Solution, data.Configuration, data.Version),

                DependsOn(cleanArtifacts),
                DependsOn(mergeBinaries));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildPackages = Task(
                "Build packages",
                from data in initTask
                select ForEach(data.Solution.Artifacts.Files.IncludeByExtension(".nuspec")).Do(
                    nuspec => new GeneratePackageTask(nuspec)
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe"
            },
                    nuspec => string.Format("Generate NuGet package for {0}", nuspec.NameWithoutExtension)),

                Default(),
                DependsOn(generateNuspecs));

            //// ----------------------------------------------------------------------------------------------------------------------------

            Task(
                "PushPackages",

                from data in initTask
                select
                ForEach(data.Solution.Artifacts.Files.IncludeByExtension("nupkg")).Do(
                    package => new PushPackageTask(package)
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe"
            },
                    package => "Push" + package.NameWithoutExtension),

                DependsOn(buildPackages));
        }
        protected override void RegisterTasks()
        {
            //// ----------------------------------------------------------------------------------------------------------------------------
            var initTask = Task(
                "Init the workflow",
                context =>
            {
                IDirectory currentDirectory = WorkDirectory.Closest(dir => dir.Name.Equals("src", StringComparison.InvariantCultureIgnoreCase));

                if (currentDirectory == null)
                {
                    throw new Exception("Could not find Src directory " + WorkDirectory);
                }

                IDirectory artifacts = currentDirectory.Parent / "Artifacts";
                artifacts.EnsureExists();
                artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll();

                IDirectory mergedBin = currentDirectory.Parent / "bin" / "Merged";
                mergedBin.EnsureExists();

                var solutionStructure = new SolutionStructure(currentDirectory.Parent);

                IFile versionNumberFile = solutionStructure.Src / "version.txt";

                return(new
                {
                    Version = versionNumberFile.Exists ? versionNumberFile.ReadAllText().Trim() : "1.0.0.0",
                    Configuration = "Release",
                    Solution = solutionStructure,
                    SkipCoreProject = context.Environment.IsMono
                }.AsTaskResult());
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var generateCommonAssemblyInfo = Task(
                "Generate common assembly info",
                from data in initTask
                select new GenerateAssemblyInfo(data.Solution.Src / "CommonAssemblyInfo.cs")
            {
                Attributes =
                {
                    _ => new AssemblyProductAttribute("CrystalQuartz"),
                    _ => new AssemblyVersionAttribute(data.Version),
                    _ => new AssemblyFileVersionAttribute(data.Version)
                }
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildClient = Task(
                "BuildClient",
                from data in initTask
                select new CompileClientAssets(data.Solution, data.Version).AsSubflow());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var copyGhPagesAssets = Task(
                "CopyAssetsToGhPagesArtifacts",
                from data in initTask
                select c =>
            {
                (data.Solution.Root / "_gh-pages-assets").AsDirectory().SearchFilesRecursively().CopyRelativelyTo(data.Solution.Artifacts / "gh-pages");
            });

            //// ----------------------------------------------------------------------------------------------------------------------------

            var restoreNugetPackages = Task(
                "RestoreNugetPackages",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = data.Solution.Src / ".nuget" / "NuGet.exe",
                Arguments = "restore " + (data.Solution.Src / "CrystalQuartz.sln").AsFile().AbsolutePath + " -Verbosity quiet"
            }.AsTask());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildSolution = Task(
                "Build solution",
                from data in initTask
                select new CustomMsBuildTask
            {
                ProjectFile = data.Solution.Src / "CrystalQuartz.sln",
                Switches    =
                {
                    MsBuildSwitch.Configuration(data.Configuration),
                    MsBuildSwitch.VerbosityQuiet()
                }
            }

                .AsTask(),

                DependsOn(restoreNugetPackages),
                DependsOn(generateCommonAssemblyInfo),
                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildCoreSolution = Task(
                "Build Core projects",
                from data in initTask
                select new ExecTask
            {
                ToolPath  = "dotnet",
                Arguments = "build " + (data.Solution.Src / "CrystalQuartz.AspNetCore" / "CrystalQuartz.AspNetCore.csproj") + " --verbosity quiet --configuration " + data.Configuration
            }

                .AsTask(),

                DependsOn(buildSolution),
                DependsOn(restoreNugetPackages),
                DependsOn(generateCommonAssemblyInfo),
                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var cleanArtifacts = Task(
                "Clean artifacts",
                from data in initTask
                select _ => data.Solution.Artifacts.Files.IncludeByExtension("nupkg", "nuspec").DeleteAll());

            //// ----------------------------------------------------------------------------------------------------------------------------

            var mergeBinaries = Task(
                "MergeBinaries",

                from data in initTask
                select new MergeBinariesTask(data.Solution, data.Configuration, data.SkipCoreProject).AsSubflow(),

                DependsOn(buildSolution),
                DependsOn(buildCoreSolution));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var generateNuspecs = Task(
                "GenerateNuspecs",
                from data in initTask
                select new GenerateNuspecsTask(data.Solution, data.Configuration, data.Version + "-beta", data.SkipCoreProject),

                DependsOn(cleanArtifacts),
                DependsOn(mergeBinaries));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildPackages = Task(
                "BuildPackages",
                from data in initTask
                select ForEach(data.Solution.Artifacts.Files.IncludeByExtension(".nuspec")).Do(
                    nuspec => new GeneratePackageTask(nuspec)
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe"
            },
                    nuspec => string.Format("Generate NuGet package for {0}", nuspec.NameWithoutExtension)),

                DependsOn(generateNuspecs));

            //// ----------------------------------------------------------------------------------------------------------------------------

            var buildDocs = Task(
                "BuildDocs",
                from data in initTask
                select new CompileDocsTask(data.Solution, data.Version).AsSubflow(),

                DependsOn(buildClient));

            //// ----------------------------------------------------------------------------------------------------------------------------

            Task(
                "DevBuild",
                () => { },

                Default(),
                DependsOn(buildClient),
                DependsOn(buildPackages),
                DependsOn(copyGhPagesAssets),
                DependsOn(buildDocs));

            //// ----------------------------------------------------------------------------------------------------------------------------
            ///
            Task(
                "CiBuild",
                () => { },

                DependsOn(buildPackages),
                DependsOn(copyGhPagesAssets),
                DependsOn(buildDocs));

            //// ----------------------------------------------------------------------------------------------------------------------------

            Task(
                "PushPackages",

                from data in initTask
                select
                ForEach(data.Solution.Artifacts.Files.IncludeByExtension("nupkg")).Do(
                    package => new ExecTask
            {
                WorkDirectory = data.Solution.Artifacts,
                ToolPath      = data.Solution.Src / ".nuget" / "NuGet.exe",
                Arguments     = "push " + package.AbsolutePath + " -Source https://api.nuget.org/v3/index.json -NonInteractive"
            },
                    package => "Push" + package.NameWithoutExtension),

                DependsOn(buildPackages));
        }