@@ -0,0 +1,2 @@ | |||||
build/BuildScript.csproj |
@@ -15,8 +15,7 @@ mono: none | |||||
# osx_image: xcode8.3 # macOS 10.12 | # osx_image: xcode8.3 # macOS 10.12 | ||||
# Run the build script | # Run the build script | ||||
script: | script: | ||||
- dotnet --info | |||||
- dotnet restore CAP.sln | |||||
- dotnet build CAP.sln | |||||
- dotnet test test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj | |||||
- dotnet tool install --global FlubuCore.GlobalTool --version 4.2.8 | |||||
- flubu build test |
@@ -66,6 +66,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.RabbitMQ.SqlServer", | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.PostgreSql", "samples\Sample.Kafka.PostgreSql\Sample.Kafka.PostgreSql.csproj", "{F1EF1D26-8A6B-403E-85B0-250DF44A4A7C}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Kafka.PostgreSql", "samples\Sample.Kafka.PostgreSql\Sample.Kafka.PostgreSql.csproj", "{F1EF1D26-8A6B-403E-85B0-250DF44A4A7C}" | ||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildScript", "build\BuildScript.csproj", "{F8EF381A-FE83-40B3-A63D-09D83851B0FB}" | |||||
EndProject | |||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
Debug|Any CPU = Debug|Any CPU | Debug|Any CPU = Debug|Any CPU | ||||
@@ -123,6 +125,14 @@ Global | |||||
{58B6E829-C6C8-457C-9DD0-C600650254DF}.Debug|Any CPU.Build.0 = Debug|Any CPU | {58B6E829-C6C8-457C-9DD0-C600650254DF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
{58B6E829-C6C8-457C-9DD0-C600650254DF}.Release|Any CPU.ActiveCfg = Release|Any CPU | {58B6E829-C6C8-457C-9DD0-C600650254DF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
{58B6E829-C6C8-457C-9DD0-C600650254DF}.Release|Any CPU.Build.0 = Release|Any CPU | {58B6E829-C6C8-457C-9DD0-C600650254DF}.Release|Any CPU.Build.0 = Release|Any CPU | ||||
{1E1E959C-3D0E-45C3-ABCA-DAAACE68AAB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{1E1E959C-3D0E-45C3-ABCA-DAAACE68AAB8}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{1E1E959C-3D0E-45C3-ABCA-DAAACE68AAB8}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{1E1E959C-3D0E-45C3-ABCA-DAAACE68AAB8}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{F8EF381A-FE83-40B3-A63D-09D83851B0FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{F8EF381A-FE83-40B3-A63D-09D83851B0FB}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{F8EF381A-FE83-40B3-A63D-09D83851B0FB}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{F8EF381A-FE83-40B3-A63D-09D83851B0FB}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | {56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||
{56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU | {56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
{56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU | {56FB261C-67AF-4715-9A46-4FA4FAB91B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||||
@@ -157,10 +167,13 @@ Global | |||||
{4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F} = {3A6B6931-A123-477A-9469-8B468B5385AF} | {4473DE19-E8D2-4B57-80A8-C8AAA2BFA20F} = {3A6B6931-A123-477A-9469-8B468B5385AF} | ||||
{63B2A464-FBEA-42FB-8EFA-98AFA39FC920} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | {63B2A464-FBEA-42FB-8EFA-98AFA39FC920} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | ||||
{58B6E829-C6C8-457C-9DD0-C600650254DF} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | {58B6E829-C6C8-457C-9DD0-C600650254DF} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | ||||
{1E1E959C-3D0E-45C3-ABCA-DAAACE68AAB8} = {3A6B6931-A123-477A-9469-8B468B5385AF} | |||||
{F8EF381A-FE83-40B3-A63D-09D83851B0FB} = {10C0818D-9160-4B80-BB86-DDE925B64D43} | |||||
{56FB261C-67AF-4715-9A46-4FA4FAB91B2C} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | {56FB261C-67AF-4715-9A46-4FA4FAB91B2C} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4} | ||||
{1B0371D6-36A4-4C78-A727-8ED732FDBA1D} = {3A6B6931-A123-477A-9469-8B468B5385AF} | {1B0371D6-36A4-4C78-A727-8ED732FDBA1D} = {3A6B6931-A123-477A-9469-8B468B5385AF} | ||||
{F6C5C676-AF05-46D5-A45D-442137B31898} = {3A6B6931-A123-477A-9469-8B468B5385AF} | {F6C5C676-AF05-46D5-A45D-442137B31898} = {3A6B6931-A123-477A-9469-8B468B5385AF} | ||||
{F1EF1D26-8A6B-403E-85B0-250DF44A4A7C} = {3A6B6931-A123-477A-9469-8B468B5385AF} | {F1EF1D26-8A6B-403E-85B0-250DF44A4A7C} = {3A6B6931-A123-477A-9469-8B468B5385AF} | ||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
SolutionGuid = {2E70565D-94CF-40B4-BFE1-AC18D5F736AB} | SolutionGuid = {2E70565D-94CF-40B4-BFE1-AC18D5F736AB} | ||||
@@ -6,11 +6,13 @@ environment: | |||||
Cap_MySql_ConnectionStringTemplate: Server=localhost;Database={0};Uid=root;Pwd=Password12!;Allow User Variables=True;SslMode=none | Cap_MySql_ConnectionStringTemplate: Server=localhost;Database={0};Uid=root;Pwd=Password12!;Allow User Variables=True;SslMode=none | ||||
services: | services: | ||||
- mysql | - mysql | ||||
before_build: | |||||
- ps: dotnet tool install --global FlubuCore.GlobalTool --version 4.2.8 | |||||
build_script: | build_script: | ||||
- ps: ./build.ps1 | |||||
- ps: flubu | |||||
test: off | test: off | ||||
artifacts: | artifacts: | ||||
- path: artifacts/packages/*.nupkg | |||||
- path: artifacts/*.nupkg | |||||
deploy: | deploy: | ||||
provider: NuGet | provider: NuGet | ||||
on: | on: | ||||
@@ -18,4 +20,4 @@ deploy: | |||||
api_key: | api_key: | ||||
secure: PZXRBOGLyhYLP7ulHfrh6MnkqB8CstuitgbLcJr3cZkLJLLzPH0ahvuTtmhWxtR2 | secure: PZXRBOGLyhYLP7ulHfrh6MnkqB8CstuitgbLcJr3cZkLJLLzPH0ahvuTtmhWxtR2 | ||||
skip_symbols: true | skip_symbols: true | ||||
artifact: /artifacts\/packages\/.+\.nupkg/ | |||||
artifact: /artifacts\/.+\.nupkg/ |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace BuildScript | |||||
{ | |||||
public partial class BuildScript | |||||
{ | |||||
public string CreateStamp() | |||||
{ | |||||
var seconds = (long)(DateTime.UtcNow - new DateTime(2017, 1, 1)).TotalSeconds; | |||||
return seconds.ToString(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,57 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using System.Xml; | |||||
using FlubuCore.Context; | |||||
using FlubuCore.Scripting.Attributes; | |||||
namespace BuildScript | |||||
{ | |||||
[Reference("System.Xml.XmlDocument, System.Xml, Version=4.0.0.0, Culture=neutral, publicKeyToken=b77a5c561934e089")] | |||||
public partial class BuildScript | |||||
{ | |||||
public BuildVersion FetchBuildVersion(ITaskContext context) | |||||
{ | |||||
var content = System.IO.File.ReadAllText("./build/version.props"); | |||||
XmlDocument doc = new XmlDocument(); | |||||
doc.LoadXml(content); | |||||
var versionMajor = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionMajor").InnerText; | |||||
var versionMinor = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionMinor").InnerText; | |||||
var versionPatch = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionPatch").InnerText; | |||||
var versionQuality = doc.DocumentElement.SelectSingleNode("/Project/PropertyGroup/VersionQuality").InnerText; | |||||
versionQuality = string.IsNullOrWhiteSpace(versionQuality) ? null : versionQuality; | |||||
var suffix = versionQuality; | |||||
bool isCi = false; | |||||
bool isTagged = false; | |||||
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); | |||||
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); | |||||
version.Suffix = suffix; | |||||
return version; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,77 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using FlubuCore.Context; | |||||
using FlubuCore.Scripting; | |||||
using FlubuCore.Scripting.Attributes; | |||||
using GlobExpressions; | |||||
namespace BuildScript | |||||
{ | |||||
[Include("./build/BuildVersion.cs")] | |||||
public partial class BuildScript : DefaultBuildScript | |||||
{ | |||||
private const string ArtifactsDir = "./artifacts"; | |||||
[FromArg("c|configuration")] | |||||
public string Configuration { get; set; } | |||||
protected BuildVersion BuildVersion { get; set; } | |||||
protected List<string> ProjectFiles { get; set; } | |||||
protected List<string> 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 ConfigureTargets(ITaskContext context) | |||||
{ | |||||
var clean = context.CreateTarget("Clean") | |||||
.AddCoreTask(x => x.Clean() | |||||
.AddDirectoryToClean(ArtifactsDir, true)); | |||||
var restore = context.CreateTarget("Restore") | |||||
.DependsOn(clean) | |||||
.AddCoreTask(x => x.Restore()); | |||||
var build = context.CreateTarget("Build") | |||||
.DependsOn(restore) | |||||
.AddCoreTask(x => x.Build() | |||||
.InformationalVersion(BuildVersion.VersionWithSuffix())); | |||||
var tests = context.CreateTarget("Tests") | |||||
.ForEach(TestProjectFiles, | |||||
(projectFile, target) => | |||||
{ | |||||
target.AddCoreTask(x => x.Test() | |||||
.Project(projectFile) | |||||
.NoBuild()); | |||||
}); | |||||
var pack = context.CreateTarget("Pack") | |||||
.ForEach(ProjectFiles, (projectFile, target) => | |||||
{ | |||||
target.AddCoreTask(x => x.Pack() | |||||
.NoBuild() | |||||
.Project(projectFile) | |||||
.IncludeSymbols() | |||||
.VersionSufix(BuildVersion.Suffix) | |||||
.OutputDirectory(ArtifactsDir)); | |||||
}); | |||||
context.CreateTarget("Default") | |||||
.SetAsDefault() | |||||
.DependsOn(clean, restore, build, tests, pack); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,12 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>netstandard2.0</TargetFramework> | |||||
</PropertyGroup> | |||||
<ItemGroup> | |||||
<PackageReference Include="FlubuCore" Version="4.2.1" /> | |||||
<PackageReference Include="Glob" Version="1.1.3" /> | |||||
</ItemGroup> | |||||
</Project> |
@@ -0,0 +1,42 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace BuildScript | |||||
{ | |||||
public class BuildVersion | |||||
{ | |||||
public BuildVersion(int major, int minor, int patch, string quality) | |||||
{ | |||||
Major = major; | |||||
Minor = minor; | |||||
Patch = patch; | |||||
Quality = quality; | |||||
} | |||||
public int Major { get; set; } | |||||
public int Minor { get; set; } | |||||
public int Patch { get; set; } | |||||
public string Quality { get; set; } | |||||
public string Suffix { get; set; } | |||||
public string VersionWithoutQuality() | |||||
{ | |||||
return $"{Major}.{Minor}.{Patch}"; | |||||
} | |||||
public string Version() | |||||
{ | |||||
return VersionWithoutQuality() + (Quality == null ? string.Empty : $"-{Quality}"); | |||||
} | |||||
public string VersionWithSuffix() | |||||
{ | |||||
return Version() + (Suffix == null ? string.Empty : $"-{Suffix}"); | |||||
} | |||||
} | |||||
} |