This repository has been archived by the owner on Jan 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
130 lines (108 loc) · 3.71 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
#tool "nuget:?package=GitVersion.CommandLine"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var pushPackages = Argument("PushPackages", "false") == "true";
bool isPrerelease = false;
GitVersion versionInfo = null;
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
//GitVersion versionInfo = null;
var nugetPackageDir = Directory("./artifacts");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(nugetPackageDir);
CleanDirectories("./src/**/bin/" + configuration);
CleanDirectories("./src/**/obj/" + configuration);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./src/Cofoundry.Plugins.ImageResizing.ImageResizer.sln");
});
Task("Patch-Assembly-Version")
.IsDependentOn("Clean")
.Does(() =>
{
versionInfo = GitVersion(new GitVersionSettings{
UpdateAssemblyInfo = false
});
Information("Building version {0} of Cofoundry.Plugins.ImageResizing.ImageResizer.", versionInfo.InformationalVersion);
isPrerelease = !string.IsNullOrEmpty(versionInfo.PreReleaseNumber);
var file = "./src/SolutionInfo.cs";
CreateAssemblyInfo(file, new AssemblyInfoSettings {
Version = versionInfo.AssemblySemVer,
FileVersion = versionInfo.MajorMinorPatch + ".0",
InformationalVersion = versionInfo.InformationalVersion,
Copyright = "Copyright © Cofoundry.org " + DateTime.Now.Year
});
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("Patch-Assembly-Version")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./src/Cofoundry.Plugins.ImageResizing.ImageResizer.sln", settings => settings.SetConfiguration(configuration));
}
});
Task("Pack")
.IsDependentOn("Build")
.Does(() =>
{
var nugetFilePaths = GetFiles("./src/Cofoundry.*/*.nuspec");
var nuGetPackSettings = new NuGetPackSettings
{
Version = versionInfo.NuGetVersion,
OutputDirectory = nugetPackageDir,
Verbosity = NuGetVerbosity.Detailed,
ArgumentCustomization = args => args.Append("-Prop Configuration=" + configuration)
};
foreach (var path in nugetFilePaths)
{
Information("Packing:" + path);
NuGetPack(path, nuGetPackSettings);
}
});
Task("PushNuGetPackage")
.IsDependentOn("Pack")
.Does(() =>
{
var nugets = GetFiles("./artifacts/*.nupkg");
if (pushPackages)
{
Information("Pushing packages");
if (isPrerelease)
{
NuGetPush(nugets, new NuGetPushSettings {
Source = "https://www.myget.org/F/cofoundry/api/v2/package",
ApiKey = EnvironmentVariable("MYGET_API_KEY")
});
}
else
{
NuGetPush(nugets, new NuGetPushSettings {
Source = "https://nuget.org/",
ApiKey = EnvironmentVariable("NUGET_API_KEY")
});
}
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default").IsDependentOn("PushNuGetPackage");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);