Skip to content

Instantly share code, notes, and snippets.

@jlouros

jlouros/build.cake

Last active Jul 14, 2019
Embed
What would you like to do?
Cake build sample file
// arguments
string target = Argument("target", "Default");
string configuration = Argument("configuration", "Release");
// define directories.
ConvertableFilePath mainSln = File("./src/Example.sln");
ConvertableDirectoryPath buildDir = Directory("./src/Example/bin") + Directory(configuration);
// tasks
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(mainSln);
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild(mainSln, settings => settings.SetConfiguration(configuration));
}
else
{
// Use XBuild
XBuild(mainSln, settings => settings.SetConfiguration(configuration));
}
});
// task targets
Task("Default")
.IsDependentOn("Build");
// execution
RunTarget(target);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment