Created
April 11, 2018 11:58
Nuke Build Code
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 System; | |
using System.Linq; | |
using Nuke.Common; | |
using Nuke.Common.Git; | |
using Nuke.Common.Tools.GitVersion; | |
using Nuke.Core; | |
using static Nuke.Common.Tools.DotNet.DotNetTasks; | |
using static Nuke.Core.IO.FileSystemTasks; | |
using static Nuke.Core.IO.PathConstruction; | |
using static Nuke.Core.EnvironmentInfo; | |
class Build : NukeBuild | |
{ | |
// Console application entry. Also defines the default target. | |
public static int Main () => Execute<Build>(x => x.Compile); | |
// Auto-injection fields: | |
// [GitVersion] readonly GitVersion GitVersion; | |
// Semantic versioning. Must have 'GitVersion.CommandLine' referenced. | |
// [GitRepository] readonly GitRepository GitRepository; | |
// Parses origin, branch name and head from git config. | |
// [Parameter] readonly string MyGetApiKey; | |
// Returns command-line arguments and environment variables. | |
Target Clean => _ => _ | |
.OnlyWhen(() => false) // Disabled for safety. | |
.Executes(() => | |
{ | |
DeleteDirectories(GlobDirectories(SourceDirectory, "**/bin", "**/obj")); | |
EnsureCleanDirectory(OutputDirectory); | |
}); | |
Target Restore => _ => _ | |
.DependsOn(Clean) | |
.Executes(() => | |
{ | |
DotNetRestore(s => DefaultDotNetRestore); | |
}); | |
Target Compile => _ => _ | |
.DependsOn(Restore) | |
.Executes(() => | |
{ | |
DotNetBuild(s => DefaultDotNetBuild); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment