Skip to content

Instantly share code, notes, and snippets.

@huanlin
Created April 11, 2018 11:58
Show Gist options
  • Save huanlin/26e80a1a8c8d578921604b09e5dec5f0 to your computer and use it in GitHub Desktop.
Save huanlin/26e80a1a8c8d578921604b09e5dec5f0 to your computer and use it in GitHub Desktop.
Nuke Build Code
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