-
-
Save dennisroche/084eff333760f2bf473f7dff6746997d to your computer and use it in GitHub Desktop.
Example build.cake script
This file contains 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
// Using Cake (C# Make) http://cakebuild.net | |
#tool "nuget:?package=GitVersion.CommandLine" | |
#tool "nuget:?package=GitReleaseNotes" | |
var target = Argument("target", "Default"); | |
var targetProject = "./src/ProjectA/project.json"; | |
var configuration = Argument("configuration", "Release"); | |
var outputDir = Argument("output", "./artifacts/"); | |
Task("Clean") | |
.Does(() => { | |
if (DirectoryExists(outputDir)) { | |
DeleteDirectory(outputDir, recursive:true); | |
} | |
}); | |
Task("Restore") | |
.Does(() => { | |
DotNetCoreRestore("./src/"); | |
}); | |
GitVersion versionInfo = null; | |
Task("Version") | |
.Does(() => { | |
GitVersion(new GitVersionSettings{ | |
OutputType = GitVersionOutput.BuildServer | |
}); | |
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json }); | |
var projects = System.IO.Directory.GetFiles(System.Environment.CurrentDirectory, | |
"project.json", System.IO.SearchOption.AllDirectories); | |
foreach (var project in projects) { | |
var updatedProjectJson = System.IO.File.ReadAllText(project) | |
.Replace("1.0.0-*", versionInfo.SemVer); | |
System.IO.File.WriteAllText(project, updatedProjectJson); | |
} | |
}); | |
Task("Build") | |
.IsDependentOn("Clean") | |
.IsDependentOn("Version") | |
.IsDependentOn("Restore") | |
.Does(() => { | |
DotNetCoreBuild(targetProject); | |
}); | |
Task("Package") | |
.IsDependentOn("Build") | |
.Does(() => { | |
var settings = new DotNetCorePackSettings | |
{ | |
OutputDirectory = outputDir, | |
NoBuild = true | |
}; | |
DotNetCorePack(targetProject, settings); | |
}); | |
Task("Default") | |
.IsDependentOn("Package"); | |
RunTarget(target); |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<!-- http://docs.nuget.org/consume/nuget-config-file --> | |
<packageSources> | |
<add key="nuget.org" value="https://www.nuget.org/api/v2/" /> | |
</packageSources> | |
<activePackageSource> | |
<add key="nuget.org" value="https://www.nuget.org/api/v2/" /> | |
</activePackageSource> | |
</configuration> |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="Cake" version="0.14.0" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment