From 741d246581c4cf47a064eeea1f419d7d20ccf1c3 Mon Sep 17 00:00:00 2001 From: Redth Date: Fri, 30 Oct 2015 15:06:38 -0400 Subject: [PATCH 1/3] Add .cake extension for C# This adds the .cake file extension to the C# language. Here is a search in the wild: https://github.com/search?q=extension%3Acake+NOT+coffee&type=Code Cake (C# Make) is a cross platform build automation system with a C# DSL to do things like compiling code, copy files/folders, running unit tests, compress files and build NuGet packages. You can find out out more about cake here: http://cakebuild.net/ --- lib/linguist/languages.yml | 1 + samples/C#/build.cake | 86 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 samples/C#/build.cake diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 0558ecdc78..bbf9f0c839 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -392,6 +392,7 @@ C#: aliases: - csharp extensions: + - .cake - .cs - .cshtml - .csx diff --git a/samples/C#/build.cake b/samples/C#/build.cake new file mode 100644 index 0000000000..d8075251ed --- /dev/null +++ b/samples/C#/build.cake @@ -0,0 +1,86 @@ +/////////////////////////////////////////////////////////////////////////////// +// ARGUMENTS +/////////////////////////////////////////////////////////////////////////////// + +var target = Argument("target", "Default"); +var configuration = Argument("configuration", "Release"); + +/////////////////////////////////////////////////////////////////////////////// +// GLOBAL VARIABLES +/////////////////////////////////////////////////////////////////////////////// + +var solutions = GetFiles("./**/*.sln"); +var solutionPaths = solutions.Select(solution => solution.GetDirectory()); + +/////////////////////////////////////////////////////////////////////////////// +// SETUP / TEARDOWN +/////////////////////////////////////////////////////////////////////////////// + +Setup(() => +{ + // Executed BEFORE the first task. + Information("Running tasks..."); +}); + +Teardown(() => +{ + // Executed AFTER the last task. + Information("Finished running tasks."); +}); + +/////////////////////////////////////////////////////////////////////////////// +// TASK DEFINITIONS +/////////////////////////////////////////////////////////////////////////////// + +Task("Clean") + .Does(() => +{ + // Clean solution directories. + foreach(var path in solutionPaths) + { + Information("Cleaning {0}", path); + CleanDirectories(path + "/**/bin/" + configuration); + CleanDirectories(path + "/**/obj/" + configuration); + } +}); + +Task("Restore") + .Does(() => +{ + // Restore all NuGet packages. + foreach(var solution in solutions) + { + Information("Restoring {0}...", solution); + NuGetRestore(solution); + } +}); + +Task("Build") + .IsDependentOn("Clean") + .IsDependentOn("Restore") + .Does(() => +{ + // Build all solutions. + foreach(var solution in solutions) + { + Information("Building {0}", solution); + MSBuild(solution, settings => + settings.SetPlatformTarget(PlatformTarget.MSIL) + .WithProperty("TreatWarningsAsErrors","true") + .WithTarget("Build") + .SetConfiguration(configuration)); + } +}); + +/////////////////////////////////////////////////////////////////////////////// +// TARGETS +/////////////////////////////////////////////////////////////////////////////// + +Task("Default") + .IsDependentOn("Build"); + +/////////////////////////////////////////////////////////////////////////////// +// EXECUTION +/////////////////////////////////////////////////////////////////////////////// + +RunTarget(target); \ No newline at end of file From 2fddaaf3d7c5cea53a930713f855db1906698dae Mon Sep 17 00:00:00 2001 From: Redth Date: Sat, 31 Oct 2015 12:45:54 -0400 Subject: [PATCH 2/3] Reordered extensions so the primary .cs is first --- lib/linguist/languages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index bbf9f0c839..6e08e827ff 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -392,8 +392,8 @@ C#: aliases: - csharp extensions: - - .cake - .cs + - .cake - .cshtml - .csx From 473e5db51f8ba214d6c5127dcced89d351aa3240 Mon Sep 17 00:00:00 2001 From: Arfon Smith Date: Thu, 19 Nov 2015 20:24:23 -0600 Subject: [PATCH 3/3] Adding sample for Coffeescript too --- lib/linguist/languages.yml | 1 + samples/CoffeeScript/build.cake | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 samples/CoffeeScript/build.cake diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 02fe488139..b14b371e3b 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -569,6 +569,7 @@ CoffeeScript: extensions: - .coffee - ._coffee + - .cake - .cjsx - .cson - .iced diff --git a/samples/CoffeeScript/build.cake b/samples/CoffeeScript/build.cake new file mode 100644 index 0000000000..b3f7df911a --- /dev/null +++ b/samples/CoffeeScript/build.cake @@ -0,0 +1,17 @@ +fs = require 'fs' + +{print} = require 'sys' +{spawn} = require 'child_process' + +build = (callback) -> + coffee = spawn 'coffee', ['-c', '-o', '.', '.'] + coffee.stderr.on 'data', (data) -> + process.stderr.write data.toString() + coffee.stdout.on 'data', (data) -> + print data.toString() + coffee.on 'exit', (code) -> + callback?() if code is 0 + +task 'build', 'Build from source', -> + build() + \ No newline at end of file