-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
136 lines (110 loc) · 4.26 KB
/
build.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#addin nuget:?package=Cake.Git
#addin nuget:?package=Cake.Utility
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
const string CopyrightText = "Copyright (c) {0}";
var target = Argument("target", "Default");
var configuration = EnvironmentVariable("CONFIGURATION") ?? Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var buildHelper = GetVersionHelper();
if (!buildHelper.IsAppVeyor){
buildHelper.Branch = Argument("branch", GitBranchCurrent(".").FriendlyName);
buildHelper.CommitMessageShort = GitLogTip(".").MessageShort; //https://github.com/WCOMAB/Cake_Git
}
var versionInfo = buildHelper.GetNextVersion("1.0.0");
buildHelper.SetNextVersion(versionInfo);
Information("Build Target:" + target);
var solutionInfo = buildHelper.GetSolutionToBuild();
Information("{4} build of version {0} of {1} from {2} ({3}).", versionInfo.FullVersion, solutionInfo.SolutionFilename, buildHelper.Branch, buildHelper.CommitMessageShort, buildHelper.BuildEnvironmentName);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.WithCriteria(() => buildHelper.IsInteractiveBuild)
.Does(() =>
{
CleanDirectories(GetDirectories("./**/bin/" + configuration));
});
Task("Pack")
.IsDependentOn("Nunit2")
.Does(() =>
{
var nuspecFiles = GetFiles("./**/*.nuspec");
var output = Directory("./Artifacts");
CreateDirectory(output);
foreach (var nuspec in nuspecFiles){
Information(nuspec.FullPath);
string fileToPack = nuspec.ChangeExtension(".csproj").FullPath;
fileToPack = nuspec.FullPath;
NuGetPack(fileToPack, new NuGetPackSettings {
Version = versionInfo.FullVersion,
OutputDirectory = output.Path.FullPath,
IncludeReferencedProjects = true,
Properties = new Dictionary<string, string>() { { "Configuration", configuration } }
});
}
//var settings = new DotNetCorePackSettings
// {
// Configuration = configuration,
// OutputDirectory = "./artifacts/",
// NoBuild = true
//};
//DotNetCorePack("./AddressParser/AddressParser.csproj", settings);
//DotNetCorePack("./AddressParser.sln", settings);
});
Task("Nunit2")
.IsDependentOn("Build")
.Does(() =>
{
//var testAssemblies = GetFiles("./**/bin/"+configuration+"/*.Tests.dll");
//NUnit(testAssemblies, new NUnitSettings { //http://cakebuild.net/api/Cake.Common.Tools.NUnit/NUnitSettings/
//NoLogo = true,
//NoResults = true,
//});
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solutionInfo.SolutionFileAndPath);
NuGetRestore(solutionInfo.SolutionFileAndPath);
});
Task("Build")
.IsDependentOn("Patch-Assembly-Info")
.Does(() =>
{
var dotNetCoreBuildSettings = new DotNetCoreBuildSettings //http://cakebuild.net/api/Cake.Common.Tools.DotNetCore.Build/DotNetCoreBuildSettings/
{
//Framework = "netcoreapp1.0",
Verbose = false,
Configuration = configuration,
ArgumentCustomization = args=>args.Append("/property:Version="+versionInfo.FullVersion+";FileVersion="+versionInfo.RootVersion)
};
DotNetCoreBuild(solutionInfo.SolutionFileAndPath, dotNetCoreBuildSettings);
// Use MSBuild
var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Minimal, //http://cakebuild.net/api/Cake.Core.Diagnostics/Verbosity/
Configuration = configuration,
//ToolVersion = MSBuildToolVersion.VS2015,
//PlatformTarget = PlatformTarget.MSIL
};
});
Task("Patch-Assembly-Info")
.IsDependentOn("Restore-Nuget-Packages")
.WithCriteria(() => buildHelper.IsCiBuildEnvironment)
.Does(() =>
{
buildHelper.PatchAllAssemblyInfo(versionInfo, CopyrightText);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);