-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathbuild.cake
133 lines (110 loc) · 4.74 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
// Usage: dotnet cake build.cake --target=Local --nugetSourceFeedUrl=https://www.myget.org/F/inrule/api/v3/index.json --inruleVersion=8.0.0
#tool nuget:?package=NuGet.CommandLine&version=6.10.1
//////////////////////////////////////////////////////////////////////
// PARAMETERS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Local");
var nugetSourceFeedUrl = Argument("nugetSourceFeedUrl", EnvironmentVariable("NuGet_Source_Feed_Url") ?? "");
var inruleVersion = Argument("inruleVersion", EnvironmentVariable("InRule_Version") ?? "");
//////////////////////////////////////////////////////////////////////
// GLOBALS
//////////////////////////////////////////////////////////////////////
FilePathCollection _solutionFiles = GetFiles("./**/*.sln");
MSBuildToolVersion _msbuildVersion = MSBuildToolVersion.VS2022;
// Determine NuGet source feeds.
ICollection<string> _nuGetSources;
const string _nuGetOrgUrl = "https://api.nuget.org/v3/index.json";
if (!string.IsNullOrWhiteSpace(nugetSourceFeedUrl))
{
Warning("{0} added as an additional NuGet feed.", nugetSourceFeedUrl);
_nuGetSources = new[] { nugetSourceFeedUrl, _nuGetOrgUrl };
}
else
{
Warning("No additional NuGet feed specified.");
_nuGetSources = new[] { _nuGetOrgUrl };
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
Information($"Cleaning all solutions. {_solutionFiles.Count} found.");
foreach(var solutionFile in _solutionFiles)
{
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
Information("Cleaning " + solutionFile);
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
try
{
MSBuild(solutionFile, settings => settings.WithTarget("Clean").UseToolVersion(_msbuildVersion));
}
catch { }
}
});
Task("Restore")
.Does(() =>
{
foreach(var solutionFile in _solutionFiles)
{
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
Information("Restoring " + solutionFile);
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
NuGetRestore(solutionFile, new NuGetRestoreSettings { Source = _nuGetSources });
}
});
Task("Update")
.Does(() =>
{
NuGetUpdateSettings nuGetUpdateSettings;
if (!string.IsNullOrWhiteSpace(inruleVersion))
{
Warning("Updating to version {0} of InRule.", inruleVersion);
nuGetUpdateSettings = new NuGetUpdateSettings
{
Prerelease = true,
Version = inruleVersion,
Source = _nuGetSources,
};
foreach(var solutionFile in _solutionFiles)
{
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
Information("Updating " + solutionFile);
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
nuGetUpdateSettings.Id = new [] { "InRule.Authoring.SDK" };
NuGetUpdate(solutionFile, nuGetUpdateSettings);
nuGetUpdateSettings.Id = new [] { "InRule.Runtime" };
NuGetUpdate(solutionFile, nuGetUpdateSettings);
nuGetUpdateSettings.Id = new [] { "InRule.Repository" };
NuGetUpdate(solutionFile, nuGetUpdateSettings);
nuGetUpdateSettings.Id = new [] { "InRule.Common" };
NuGetUpdate(solutionFile, nuGetUpdateSettings);
}
}
else
Information("No update requested.");
});
Task("Build")
.Does(() =>
{
foreach(var solutionFile in _solutionFiles)
{
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
Information("Building " + solutionFile);
Information("-+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+- -+-");
MSBuild(solutionFile, settings => settings.WithTarget("Build").UseToolVersion(_msbuildVersion));
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Local")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Update")
.IsDependentOn("Build");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);