Browse Source

update build script (#480)

master
Marko Zorec 5 years ago
committed by Savorboard
parent
commit
9ce812cf10
5 changed files with 20 additions and 16 deletions
  1. +2
    -2
      .travis.yml
  2. +1
    -1
      appveyor.yml
  3. +6
    -7
      build/BuildScript.Version.cs
  4. +10
    -5
      build/BuildScript.cs
  5. +1
    -1
      build/BuildScript.csproj

+ 2
- 2
.travis.yml View File

@@ -12,5 +12,5 @@ services:


script: script:
- export PATH="$PATH:$HOME/.dotnet/tools" - export PATH="$PATH:$HOME/.dotnet/tools"
- dotnet tool install --global FlubuCore.GlobalTool --version 4.3.5
- flubu build tests -s=build/BuildScript.cs
- dotnet tool install --global FlubuCore.GlobalTool --version 4.3.7
- flubu build tests

+ 1
- 1
appveyor.yml View File

@@ -7,7 +7,7 @@ environment:
services: services:
- mysql - mysql
before_build: before_build:
- ps: dotnet tool install --global FlubuCore.GlobalTool --version 4.3.5
- ps: dotnet tool install --global FlubuCore.GlobalTool --version 4.3.7
build_script: build_script:
- ps: flubu - ps: flubu
test: off test: off


+ 6
- 7
build/BuildScript.Version.cs View File

@@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Xml; using System.Xml;
using FlubuCore.Context; using FlubuCore.Context;
using FlubuCore.Scripting.Attributes; using FlubuCore.Scripting.Attributes;
@@ -10,7 +11,7 @@ namespace BuildScript
{ {
public BuildVersion FetchBuildVersion(ITaskContext context) public BuildVersion FetchBuildVersion(ITaskContext context)
{ {
var content = System.IO.File.ReadAllText("./build/version.props");
var content = System.IO.File.ReadAllText(RootDirectory.CombineWith("build/version.props"));


XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.LoadXml(content); doc.LoadXml(content);
@@ -28,22 +29,20 @@ namespace BuildScript
if (!context.BuildSystems().IsLocalBuild) if (!context.BuildSystems().IsLocalBuild)
{ {
isCi = true; isCi = true;
//// todo use flubu build system when available.
var appveyortag = context.GetEnvironmentVariable("APPVEYOR_REPO_TAG");
bool isTagAppveyor = !string.IsNullOrEmpty(appveyortag) && appveyortag.Equals("true", StringComparison.OrdinalIgnoreCase);
bool isTagAppveyor = context.BuildSystems().AppVeyor().IsTag;
if ((context.BuildSystems().RunningOn == BuildSystemType.AppVeyor && isTagAppveyor) ||
(context.BuildSystems().RunningOn == BuildSystemType.TravisCI && string.IsNullOrWhiteSpace(context.BuildSystems().Travis().TagName)))
if (context.BuildSystems().RunningOn == BuildSystemType.AppVeyor && isTagAppveyor ||
context.BuildSystems().RunningOn == BuildSystemType.TravisCI && string.IsNullOrWhiteSpace(context.BuildSystems().Travis().TagName))
{ {
isTagged = true; isTagged = true;
} }
} }



if (!isTagged) if (!isTagged)
{ {
suffix += (isCi ? "preview-" : "dv-") + CreateStamp(); suffix += (isCi ? "preview-" : "dv-") + CreateStamp();
} }

suffix = string.IsNullOrWhiteSpace(suffix) ? null : suffix; suffix = string.IsNullOrWhiteSpace(suffix) ? null : suffix;


var version = new BuildVersion(int.Parse(versionMajor), int.Parse(versionMinor), int.Parse(versionPatch), versionQuality); var version = new BuildVersion(int.Parse(versionMajor), int.Parse(versionMinor), int.Parse(versionPatch), versionQuality);


+ 10
- 5
build/BuildScript.cs View File

@@ -9,7 +9,7 @@ namespace BuildScript
[Include("./build/BuildVersion.cs")] [Include("./build/BuildVersion.cs")]
public partial class BuildScript : DefaultBuildScript public partial class BuildScript : DefaultBuildScript
{ {
private const string ArtifactsDir = "./artifacts";
protected string ArtifactsDir => RootDirectory.CombineWith("artifacts");


[FromArg("c|configuration")] [FromArg("c|configuration")]
public string Configuration { get; set; } public string Configuration { get; set; }
@@ -29,27 +29,30 @@ namespace BuildScript
protected override void BeforeBuildExecution(ITaskContext context) protected override void BeforeBuildExecution(ITaskContext context)
{ {
BuildVersion = FetchBuildVersion(context); BuildVersion = FetchBuildVersion(context);
TestProjectFiles = context.GetFiles("./test", "*/*.csproj");
ProjectFiles = context.GetFiles("./src", "*/*.csproj");
TestProjectFiles = context.GetFiles(RootDirectory.CombineWith("test"), "*/*.csproj");
ProjectFiles = context.GetFiles(RootDirectory.CombineWith("src"), "*/*.csproj");
} }


protected override void ConfigureTargets(ITaskContext context) protected override void ConfigureTargets(ITaskContext context)
{ {
var clean = context.CreateTarget("Clean") var clean = context.CreateTarget("Clean")
.SetDescription("")
.SetDescription("Cleans the output of all projects in the solution.")
.AddCoreTask(x => x.Clean() .AddCoreTask(x => x.Clean()
.AddDirectoryToClean(ArtifactsDir, true)); .AddDirectoryToClean(ArtifactsDir, true));


var restore = context.CreateTarget("Restore") var restore = context.CreateTarget("Restore")
.SetDescription("Restores the dependencies and tools of all projects in the solution.")
.DependsOn(clean) .DependsOn(clean)
.AddCoreTask(x => x.Restore()); .AddCoreTask(x => x.Restore());


var build = context.CreateTarget("Build") var build = context.CreateTarget("Build")
.SetDescription("Builds all projects in the solution.")
.DependsOn(restore) .DependsOn(restore)
.AddCoreTask(x => x.Build() .AddCoreTask(x => x.Build()
.InformationalVersion(BuildVersion.VersionWithSuffix())); .InformationalVersion(BuildVersion.VersionWithSuffix()));


var tests = context.CreateTarget("Tests") var tests = context.CreateTarget("Tests")
.SetDescription("Runs all Cap tests.")
.ForEach(TestProjectFiles, .ForEach(TestProjectFiles,
(projectFile, target) => (projectFile, target) =>
{ {
@@ -59,17 +62,19 @@ namespace BuildScript
}); });


var pack = context.CreateTarget("Pack") var pack = context.CreateTarget("Pack")
.SetDescription("Creates nuget packages for Cap.")
.ForEach(ProjectFiles, (projectFile, target) => .ForEach(ProjectFiles, (projectFile, target) =>
{ {
target.AddCoreTask(x => x.Pack() target.AddCoreTask(x => x.Pack()
.NoBuild() .NoBuild()
.Project(projectFile) .Project(projectFile)
.IncludeSymbols() .IncludeSymbols()
.When(() => !string.IsNullOrEmpty(BuildVersion.Suffix), t => t.VersionSufix(BuildVersion.Suffix))
.VersionSuffix(BuildVersion.Suffix)
.OutputDirectory(ArtifactsDir)); .OutputDirectory(ArtifactsDir));
}); });


context.CreateTarget("Default") context.CreateTarget("Default")
.SetDescription("Runs all targets.")
.SetAsDefault() .SetAsDefault()
.DependsOn(clean, restore, build, tests, pack); .DependsOn(clean, restore, build, tests, pack);
} }


+ 1
- 1
build/BuildScript.csproj View File

@@ -9,7 +9,7 @@
</ItemGroup> </ItemGroup>


<ItemGroup> <ItemGroup>
<PackageReference Include="FlubuCore" Version="4.3.5" />
<PackageReference Include="FlubuCore" Version="4.3.7" />
</ItemGroup> </ItemGroup>


</Project> </Project>

Loading…
Cancel
Save