From 549bb5ec0a5254da0ba6ad16de02ad38a6d4b862 Mon Sep 17 00:00:00 2001 From: Marko Zorec Date: Thu, 26 Dec 2019 02:39:09 +0100 Subject: [PATCH] Improve build script (#467) * Adds Flubu build script * Improve build script * update flubu global tool version * fix target name --- .travis.yml | 5 +++-- appveyor.yml | 2 +- build/BuildScript.cs | 21 ++++++++++++--------- build/BuildScript.csproj | 3 +-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f4209b..bfea858 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,6 @@ mono: none # Run the build script script: - - dotnet tool install --global FlubuCore.GlobalTool --version 4.2.8 - - flubu build test \ No newline at end of file + - export PATH="$PATH:$HOME/.dotnet/tools" + - dotnet tool install --global FlubuCore.GlobalTool --version 4.3.5 + - flubu build tests -s=build/BuildScript.cs \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 07857b0..1e21fc1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ environment: services: - mysql before_build: - - ps: dotnet tool install --global FlubuCore.GlobalTool --version 4.2.8 + - ps: dotnet tool install --global FlubuCore.GlobalTool --version 4.3.5 build_script: - ps: flubu test: off diff --git a/build/BuildScript.cs b/build/BuildScript.cs index a3c54d7..e4a514b 100644 --- a/build/BuildScript.cs +++ b/build/BuildScript.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using FlubuCore.Context; +using FlubuCore.IO; using FlubuCore.Scripting; using FlubuCore.Scripting.Attributes; using GlobExpressions; @@ -18,25 +19,27 @@ namespace BuildScript protected BuildVersion BuildVersion { get; set; } - protected List ProjectFiles { get; set; } + protected List ProjectFiles { get; set; } - protected List TestProjectFiles { get; set; } + protected List TestProjectFiles { get; set; } protected override void ConfigureBuildProperties(IBuildPropertiesContext context) { - context.Properties.Set(BuildProps.ProductId, "CAP"); context.Properties.Set(BuildProps.SolutionFileName, "CAP.sln"); context.Properties.Set(BuildProps.BuildConfiguration, string.IsNullOrEmpty(Configuration) ? "Release" : Configuration); - //// todo remove casting when new version of flubu is available - BuildVersion = FetchBuildVersion(context as ITaskContext); - Console.WriteLine(BuildVersion.Version()); - TestProjectFiles = Glob.Files("./test", "*/*.csproj", GlobOptions.MatchFullPath).Select(x => $"./test/{x}").ToList(); - ProjectFiles = Glob.Files("./src", "*/*.csproj").Select(x => $"./src/{x}").ToList(); + } + + protected override void BeforeBuildExecution(ITaskContext context) + { + BuildVersion = FetchBuildVersion(context); + TestProjectFiles = context.GetFiles("./test", "*/*.csproj"); + ProjectFiles = context.GetFiles("./src", "*/*.csproj"); } protected override void ConfigureTargets(ITaskContext context) { var clean = context.CreateTarget("Clean") + .SetDescription("") .AddCoreTask(x => x.Clean() .AddDirectoryToClean(ArtifactsDir, true)); @@ -58,7 +61,7 @@ namespace BuildScript .NoBuild()); }); - var pack = context.CreateTarget("Pack") + var pack = context.CreateTarget("Pack") .ForEach(ProjectFiles, (projectFile, target) => { target.AddCoreTask(x => x.Pack() diff --git a/build/BuildScript.csproj b/build/BuildScript.csproj index 75c20a0..ed278c1 100644 --- a/build/BuildScript.csproj +++ b/build/BuildScript.csproj @@ -5,8 +5,7 @@ - - +