Skip to content

Commit

Permalink
Added Cake for automatic packaging and publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
maca88 committed Jun 15, 2017
1 parent d2fb230 commit 7f50c0a
Show file tree
Hide file tree
Showing 15 changed files with 463 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,5 @@ ModelManifest.xml
.paket/paket.exe

# FAKE - F# Make
.fake/
.fake/
Tools/**
4 changes: 2 additions & 2 deletions Source/AsyncGenerator.CommandLine/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
4 changes: 2 additions & 2 deletions Source/AsyncGenerator.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
4 changes: 2 additions & 2 deletions Source/AsyncGenerator.Tests/AsyncGenerator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;ASYNC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;ASYNC</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Source/AsyncGenerator.Tests/IfDirective/Input/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using AsyncGenerator.TestCases;

#if DEBUG
#if ASYNC
namespace AsyncGenerator.Tests.IfDirective
{
#if TRACE
Expand All @@ -15,7 +15,7 @@ public class Parent
{
public class TestCase
{
#if DEBUG
#if ASYNC

public void Read()
{
Expand Down
4 changes: 2 additions & 2 deletions Source/AsyncGenerator.Tests/IfDirective/Output/TestCase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using System.Text;
using System.Threading.Tasks;
using AsyncGenerator.TestCases;

#if DEBUG
#if ASYNC
namespace AsyncGenerator.Tests.IfDirective
{
#if TRACE
Expand All @@ -31,7 +31,7 @@ namespace AsyncGenerator.Tests.IfDirective
/// </content>
public partial class TestCase
{
#if DEBUG
#if ASYNC

public Task ReadAsync()
{
Expand Down
2 changes: 2 additions & 0 deletions Source/AsyncGenerator.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using NUnit.Framework;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand Down Expand Up @@ -34,3 +35,4 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly:Parallelizable(ParallelScope.Fixtures)]
1 change: 0 additions & 1 deletion Source/AsyncGenerator.Tests/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<root>
<priority value="INFO" />
<appender-ref ref="Console" />
<appender-ref ref="RollingFile" />
</root>

</log4net>
Expand Down
4 changes: 2 additions & 2 deletions Source/AsyncGenerator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.1.0")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyVersion("0.1.2.0")]
[assembly: AssemblyFileVersion("0.1.2.0")]
4 changes: 4 additions & 0 deletions Tools/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.20.0" />
</packages>
5 changes: 5 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 1.0.{build}
image: Visual Studio 2015
build_script:
- cmd: PowerShell -Version 2.0 .\build.ps1
test: off
146 changes: 146 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.6.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

//////////////////////////////////////////////////////////////////////
// CONSTANTS
//////////////////////////////////////////////////////////////////////

var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/";
var PACKAGE_DIR = PROJECT_DIR + "package/";

//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////

// Define directories.
var buildDirs = new List<string>()
{
Directory("./Source/AsyncGenerator/bin") + Directory(configuration),
Directory("./Source/AsyncGenerator.CommandLine/bin") + Directory(configuration),
Directory("./Source/AsyncGenerator.Configuration.Yaml/bin") + Directory(configuration),
Directory("./Source/AsyncGenerator.Core/bin") + Directory(configuration)
};

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

Task("Clean")
.Does(() =>
{
foreach(var buildDir in buildDirs)
{
CleanDirectory(buildDir);
}
});

Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./Source/AsyncGenerator.sln");
});

Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./Source/AsyncGenerator.sln", settings =>
settings.SetConfiguration(configuration));
}
else
{
// Use XBuild
XBuild("./Source/AsyncGenerator.sln", settings =>
settings.SetConfiguration(configuration));
}
});

Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
NUnit3("./Source/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
NoResults = true
});
});

//////////////////////////////////////////////////////////////////////
// PACKAGE
//////////////////////////////////////////////////////////////////////

Task("Pack-NuGet-Packages")
.IsDependentOn("Build")
.Description("Creates NuGet packages")
.Does(() =>
{
CreateDirectory(PACKAGE_DIR);
NuGetPack("Source/AsyncGenerator.Core/AsyncGenerator.Core.csproj", new NuGetPackSettings()
{
OutputDirectory = PACKAGE_DIR,
Symbols = true,
ArgumentCustomization = args => args
.Append("-Prop Configuration=" + configuration)
});
NuGetPack("Source/AsyncGenerator.Configuration.Yaml/AsyncGenerator.Configuration.Yaml.csproj", new NuGetPackSettings()
{
OutputDirectory = PACKAGE_DIR,
Symbols = true,
ArgumentCustomization = args => args
.Append("-Prop Configuration=" + configuration)
});
NuGetPack("Source/AsyncGenerator/AsyncGenerator.csproj", new NuGetPackSettings()
{
OutputDirectory = PACKAGE_DIR,
Symbols = true,
ArgumentCustomization = args => args
.Append("-Prop Configuration=" + configuration)
});
NuGetPack("Source/AsyncGenerator.CommandLine/AsyncGenerator.CommandLine.csproj", new NuGetPackSettings()
{
OutputDirectory = PACKAGE_DIR,
ArgumentCustomization = args => args
.Append("-Tool")
.Append("-Prop Configuration=" + configuration)
});
});

Task("Publish-NuGet-Packages")
.IsDependentOn("Run-Unit-Tests")
.IsDependentOn("Pack-NuGet-Packages")
.Does(() =>
{
foreach(var package in System.IO.Directory.GetFiles(PACKAGE_DIR, "*.nupkg").Where(o => !o.Contains("symbols")))
{
NuGetPush(package, new NuGetPushSettings()
{
Source = "https://www.nuget.org/api/v2/package"
});
}
});



//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////

Task("Default")
.IsDependentOn("Run-Unit-Tests");

Task("Publish")
.IsDependentOn("Publish-NuGet-Packages");

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////

RunTarget(target);
Loading

0 comments on commit 7f50c0a

Please sign in to comment.