Created
April 1, 2016 09:09
-
-
Save laurentkempe/9a8ca42c0a2f0698abc0d1516cedcd78 to your computer and use it in GitHub Desktop.
build.cake sample
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 | |
////////////////////////////////////////////////////////////////////// | |
// Define directories. | |
var buildDir = Directory("./src/Example/bin") + Directory(configuration); | |
////////////////////////////////////////////////////////////////////// | |
// TASKS | |
////////////////////////////////////////////////////////////////////// | |
Task("Clean") | |
.Does(() => | |
{ | |
CleanDirectory(buildDir); | |
}); | |
Task("Restore-NuGet-Packages") | |
.IsDependentOn("Clean") | |
.Does(() => | |
{ | |
NuGetRestore("./src/Example.sln"); | |
}); | |
Task("Build") | |
.IsDependentOn("Restore-NuGet-Packages") | |
.Does(() => | |
{ | |
if(IsRunningOnWindows()) | |
{ | |
// Use MSBuild | |
MSBuild("./src/Example.sln", settings => | |
settings.SetConfiguration(configuration)); | |
} | |
else | |
{ | |
// Use XBuild | |
XBuild("./src/Example.sln", settings => | |
settings.SetConfiguration(configuration)); | |
} | |
}); | |
Task("Run-Unit-Tests") | |
.IsDependentOn("Build") | |
.Does(() => | |
{ | |
NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings { | |
NoResults = true | |
}); | |
}); | |
////////////////////////////////////////////////////////////////////// | |
// TASK TARGETS | |
////////////////////////////////////////////////////////////////////// | |
Task("Default") | |
.IsDependentOn("Run-Unit-Tests"); | |
////////////////////////////////////////////////////////////////////// | |
// EXECUTION | |
////////////////////////////////////////////////////////////////////// | |
RunTarget(target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment