diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 0558ecdc..bbf9f0c8 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 00000000..d8075251 --- /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