Created
June 23, 2016 16:43
-
-
Save judwhite/b35f31714b29f7d1d5430aa24f36b59f to your computer and use it in GitHub Desktop.
psake: Example cake file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// ARGUMENTS | |
////////////////////////////////////////////////////////////////////// | |
var target = Argument("target", "Default"); | |
var configuration = Argument("configuration", "Release"); | |
////////////////////////////////////////////////////////////////////// | |
// PREPARATION | |
////////////////////////////////////////////////////////////////////// | |
var buildDir = Directory("./src/Example/bin") + Directory(configuration); | |
var solutionFile = "./src/Library.sln"; | |
var targetDir = "./target"; | |
var mergedDll = targetDir + "./Example.Library.Merged.dll"; | |
////////////////////////////////////////////////////////////////////// | |
// TASKS | |
////////////////////////////////////////////////////////////////////// | |
Task("Clean") | |
.Does(() => | |
{ | |
CleanDirectory(buildDir); | |
}); | |
Task("Restore-NuGet-Packages") | |
.IsDependentOn("Clean") | |
.Does(() => | |
{ | |
NuGetRestore(solutionFile); | |
}); | |
Task("Build") | |
.IsDependentOn("Restore-NuGet-Packages") | |
.Does(() => | |
{ | |
MSBuild(solutionFile, settings => settings.SetConfiguration(configuration)); | |
}); | |
Task("Run-Unit-Tests") | |
.IsDependentOn("Build") | |
.Does(() => | |
{ | |
NUnit3("./src/**/bin/" + configuration + "/*.UnitTests.dll", new NUnit3Settings { NoResults = true }); | |
}); | |
Task("Merge-Assemblies") | |
.IsDependentOn("Build") | |
.Does(() => | |
{ | |
var binDir = "./src/Example.Library/bin/" + configuration; | |
var assemblyPaths = new [] { | |
new FilePath(binDir + "/Antlr4.Runtime.dll"), | |
new FilePath(binDir + "/Antlr4.StringTemplate.dll"), | |
new FilePath(binDir + "/Elasticsearch.Net.dll"), | |
new FilePath(binDir + "/Nest.dll"), | |
new FilePath(binDir + "/Newtonsoft.Json.dll"), | |
new FilePath(binDir + "/NLog.dll"), | |
new FilePath(binDir + "/NodaTime.dll") | |
}; | |
var settings = new ILMergeSettings{ArgumentCustomization = args=>args.Append("/closed")}; | |
CreateDirectory(targetDir); | |
ILMerge(mergedDll, binDir + "/Example.Library.dll", assemblyPaths, settings); | |
}); | |
Task("Run-Unit-Tests-Merged") | |
.IsDependentOn("Merge-Assemblies") | |
.Does(() => | |
{ | |
var binDir = "./src/Example.Library.UnitTests/bin/" + configuration; | |
var assemblyPaths = new [] { new FilePath(mergedDll) }; | |
var mergedUnitTestDll = binDir + "./Example.Library.UnitTests.Merged.dll"; | |
ILMerge(mergedUnitTestDll, binDir + "/Example.Library.UnitTests.dll", assemblyPaths); | |
NUnit3(mergedUnitTestDll, new NUnit3Settings { NoResults = true }); | |
}); | |
////////////////////////////////////////////////////////////////////// | |
// TASK TARGETS | |
////////////////////////////////////////////////////////////////////// | |
Task("Default") | |
.IsDependentOn("Run-Unit-Tests-Merged"); | |
////////////////////////////////////////////////////////////////////// | |
// EXECUTION | |
////////////////////////////////////////////////////////////////////// | |
RunTarget(target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment