forked from serenity-is/Serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.cake
194 lines (162 loc) · 7.16 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
var target = Argument("target", "NuGet");
var configuration = Argument("configuration", "Release");
string serenityVersion = null;
var nuspecParams = new Dictionary<string, string> {
{ "authors", "Volkan Ceylan" },
{ "owners", "Volkan Ceylan" },
{ "language", "en-US" },
{ "iconUrl", "https://raw.github.com/volkanceylan/Serenity/master/Tools/Images/serenity-logo-128.png" },
{ "licenceUrl", "https://raw.github.com/volkanceylan/Serenity/master/LICENSE.md" },
{ "projectUrl", "http://github.com/volkanceylan/Serenity" },
{ "copyright", "Copyright (c) Volkan Ceylan" },
{ "tags", "Serenity" },
{ "framework", "net45" }
};
var nugetPackages = new List<string>();
Func<string, System.Xml.XmlDocument> loadXml = path =>
{
var xml = new System.Xml.XmlDocument();
xml.LoadXml(System.IO.File.ReadAllText(path));
return xml;
};
Func<string, string, string> getPackageVersion = (project, package) =>
{
var node = loadXml(@".\" + project + @"\packages.config").SelectSingleNode("//package[@id='" + package + "']/@version");
if (node == null || node.Value == null)
throw new InvalidOperationException("Couldn't find version for " + package + " in project " + project);
return node.Value;
};
Action<string> minimizeJs = filename => {
StartProcess("./Tools/Node/uglifyjs.cmd", new ProcessSettings
{
Arguments = filename +
" -o " + System.IO.Path.ChangeExtension(filename, "min.js") +
" --comments --mangle"
});
};
Action runGitLink = () => {
StartProcess("./Tools/GitLink/GitLink.exe", new ProcessSettings
{
Arguments = System.IO.Path.GetFullPath(@".\") + " -u https://github.com/volkanceylan/serenity"
});
};
Task("Clean")
.Does(() =>
{
CleanDirectories("./Bin");
CreateDirectory("./Bin");
CreateDirectory("./Bin/Packages");
CreateDirectory("./Bin/Temp");
CleanDirectories("./Serenity.*/**/bin/" + configuration);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(context =>
{
NuGetRestore("./Serenity.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(context =>
{
MSBuild("./Serenity.sln", s => {
s.SetConfiguration(configuration);
});
var vi = System.Diagnostics.FileVersionInfo.GetVersionInfo("./Serenity.Core/bin/" + configuration + "/Serenity.Core.dll");
serenityVersion = vi.FileMajorPart + "." + vi.FileMinorPart + "." + vi.FileBuildPart;
});
Task("Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
XUnit2("./Serenity.Test*/**/bin/" + configuration + "/*.Test.dll");
});
Task("Copy-Files")
.IsDependentOn("Unit-Tests")
.Does(() =>
{
});
Task("Pack")
.IsDependentOn("Copy-Files")
.Does(() =>
{
if ((target ?? "").ToLowerInvariant() == "nuget-push")
runGitLink();
});
Task("NuGet")
.IsDependentOn("Pack")
.Does(() =>
{
nuspecParams["configuration"] = configuration;
nuspecParams["jsonNetVersion"] = getPackageVersion("Serenity.Core", "Newtonsoft.Json");
nuspecParams["couchbaseNetClientVersion"] = getPackageVersion("Serenity.Caching.Couchbase", "CouchbaseNetClient");
nuspecParams["stackExchangeRedisVersion"] = getPackageVersion("Serenity.Caching.Redis", "StackExchange.Redis");
nuspecParams["microsoftAspNetMvcVersion"] = getPackageVersion("Serenity.Web", "Microsoft.AspNet.Mvc");
nuspecParams["microsoftAspNetRazorVersion"] = getPackageVersion("Serenity.Web", "Microsoft.AspNet.Razor");
nuspecParams["microsoftAspNetWebPagesVersion"] = getPackageVersion("Serenity.Web", "Microsoft.AspNet.WebPages");
nuspecParams["microsoftWebInfrastructureVersion"] = getPackageVersion("Serenity.Web", "Microsoft.Web.Infrastructure");
nuspecParams["saltarelleCompilerVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.Compiler");
nuspecParams["saltarellejQueryVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.jQuery");
nuspecParams["saltarellejQueryUIVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.jQuery.UI");
nuspecParams["saltarelleLinqVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.Linq");
nuspecParams["saltarelleRuntimeVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.Runtime");
nuspecParams["saltarelleWebVersion"] = getPackageVersion("Serenity.Script.Imports", "Saltarelle.Web");
nuspecParams["scriptFramework"] = loadXml(@".\Serenity.Script.Imports\packages.config").SelectSingleNode("//package[@id='Saltarelle.Runtime']/@targetFramework").Value;
Action<string, string> myPack = (s, id) => {
var nuspec = System.IO.File.ReadAllText("./" + s + "/" + (id ?? s) + ".nuspec");
nuspec = nuspec.Replace("${version}", serenityVersion);
nuspec = nuspec.Replace("${id}", (id ?? s));
foreach (var p in nuspecParams)
nuspec = nuspec.Replace("${" + p.Key + "}", p.Value);
var assembly = "./" + s + "/bin/" + configuration + "/" + s + ".dll";
if (!System.IO.File.Exists(assembly))
assembly = "./" + s + "/bin/" + configuration + "/" + s + ".exe";
if (System.IO.File.Exists(assembly))
{
var vi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly);
nuspec = nuspec.Replace("${title}", vi.FileDescription);
nuspec = nuspec.Replace("${description}", vi.Comments);
}
System.IO.File.WriteAllText("./Bin/Temp/" + s + ".temp.nuspec", nuspec);
NuGetPack("./Bin/Temp/" + s + ".temp.nuspec", new NuGetPackSettings {
BasePath = "./" + s + "/bin/" + configuration,
OutputDirectory = "./Bin/Packages",
NoPackageAnalysis = true
});
nugetPackages.Add("./Bin/Packages/" + (id ?? s) + "." + serenityVersion + ".nupkg");
};
myPack("Serenity.Core", null);
myPack("Serenity.Caching.Couchbase", null);
myPack("Serenity.Caching.Redis", null);
myPack("Serenity.Data", null);
myPack("Serenity.Data.Entity", null);
myPack("Serenity.Services", null);
myPack("Serenity.Testing", null);
myPack("Serenity.Script.UI", "Serenity.Script");
myPack("Serenity.Web", null);
myPack("Serenity.CodeGenerator", null);
if (System.IO.Directory.Exists(@"C:\Sandbox\MyNugetFeed"))
{
foreach (var package in nugetPackages)
System.IO.File.Copy(package, @"C:\Sandbox\MyNugetFeed\" + System.IO.Path.GetFileName(package), true);
foreach (var package in System.IO.Directory.GetFiles(
System.IO.Path.Combine(System.Environment.GetFolderPath(
System.Environment.SpecialFolder.LocalApplicationData), @"nuget\cache"), "Seren*.nupkg"))
System.IO.File.Delete(package);
}
});
Task("NuGet-Push")
.IsDependentOn("NuGet")
.Does(() =>
{
foreach (var package in nugetPackages)
{
NuGetPush(package, new NuGetPushSettings {
});
}
});
Task("VSIX")
.Does(() =>
{
});
RunTarget(target);