Browse Source

update build script (#480)

master
Marko Zorec 4 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:
- 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:
- mysql
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:
- ps: flubu
test: off


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

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Xml;
using FlubuCore.Context;
using FlubuCore.Scripting.Attributes;
@@ -10,7 +11,7 @@ namespace BuildScript
{
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();
doc.LoadXml(content);
@@ -28,22 +29,20 @@ namespace BuildScript
if (!context.BuildSystems().IsLocalBuild)
{
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;
}
}


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

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

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")]
public partial class BuildScript : DefaultBuildScript
{
private const string ArtifactsDir = "./artifacts";
protected string ArtifactsDir => RootDirectory.CombineWith("artifacts");

[FromArg("c|configuration")]
public string Configuration { get; set; }
@@ -29,27 +29,30 @@ namespace BuildScript
protected override void BeforeBuildExecution(ITaskContext 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)
{
var clean = context.CreateTarget("Clean")
.SetDescription("")
.SetDescription("Cleans the output of all projects in the solution.")
.AddCoreTask(x => x.Clean()
.AddDirectoryToClean(ArtifactsDir, true));

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

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

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

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

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


+ 1
- 1
build/BuildScript.csproj View File

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

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

</Project>

Loading…
Cancel
Save