-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
129 lines (116 loc) · 5.18 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
#addin nuget:?package=Newtonsoft.Json&version=9.0.1
#addin "Cake.FileHelpers"
#addin "Cake.Npm"
#reference "BuildSupport/Connect.CakeUtils.dll"
using Connect.CakeUtils;
using Connect.CakeUtils.Compression;
using Connect.CakeUtils.Manifest;
///////////////////////////////////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var packageJson = Context.FileReadText(".\\package.json");
var project = Newtonsoft.Json.JsonConvert.DeserializeObject<Project>(packageJson);
var slnFile ="./Connect.DocBrowser.sln";
var buildSettings = new MSBuildSettings()
.SetConfiguration(configuration)
.UseToolVersion(MSBuildToolVersion.VS2015)
.WithProperty("OutDir", new System.IO.DirectoryInfo(project.dnn.pathsAndFiles.pathToAssemblies).FullName);
var devDnnPath = "D:\\Webroot\\DNNAPI\\";
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("CleanDev")
.Does(() => {
switch (project.dnn.projectType) {
case "":
var moduleFolder = devDnnPath + "DesktopModules\\" + project.dnn.folder.Replace("/", "\\");
try
{
System.IO.Directory.Delete(moduleFolder, true);
}
catch (System.Exception)
{
}
System.IO.Directory.CreateDirectory(moduleFolder);
break;
}
});
Task("CopyDev")
.IsDependentOn("CleanDev")
.Does(() => {
switch (project.dnn.projectType) {
case "":
var moduleFolder = devDnnPath + "DesktopModules\\" + project.dnn.folder.Replace("/", "\\");
foreach (var file in Utilities.GetFilesByPatterns(Context, project.dnn.pathsAndFiles.devFolder, project.dnn.pathsAndFiles.releaseFiles, Utilities.ExcludeFunction(project))) {
Console.WriteLine("Copying {1}", DateTime.Now, file.FullPath);
var dest = new System.IO.FileInfo(moduleFolder + "\\" + file.FullPath.Substring(new System.IO.DirectoryInfo(project.dnn.pathsAndFiles.devFolder).FullName.Length));
dest.Directory.Create();
System.IO.File.Copy(file.FullPath, dest.FullName, true);
}
break;
}
});
Task("AssemblyInfo")
.Does(() => {
var settings = new GlobberSettings();
settings.Predicate = Utilities.ExcludeFunction(project);
var files = GetFiles("./**/AssemblyInfo.cs", settings);
foreach(var file in files)
{
Information("Updating Assembly: {0}", file);
Utilities.UpdateAssemblyInfo(project, file.FullPath);
}
});
Task("Build")
.IsDependentOn("AssemblyInfo")
.Does(() => {
CleanDirectory(project.dnn.pathsAndFiles.pathToAssemblies);
NuGetRestore(slnFile);
MSBuild(slnFile, buildSettings);
NpmRunScript("build");
});
Task("PackageInstall")
.IsDependentOn("Build")
.Does(() => {
var files = Utilities.GetFilesByPatterns(Context, project.dnn.pathsAndFiles.devFolder, project.dnn.pathsAndFiles.releaseFiles, Utilities.ExcludeFunction(project));
var resZip = ZipToBytes(project.dnn.pathsAndFiles.devFolder, files);
Information("Zipped resources file");
var packageName = project.dnn.pathsAndFiles.zipName + "_" + project.version + "_Install.zip";
var packagePath = project.dnn.pathsAndFiles.packagesPath + "/" + packageName;
AddBinaryFileToZip(packagePath, resZip, "resources.zip", false);
files = Utilities.GetFilesByPatterns(Context, new string[] {
project.dnn.pathsAndFiles.pathToAssemblies + "/*.dll"
});
AddFilesToZip(packagePath, project.dnn.pathsAndFiles.pathToAssemblies, project.dnn.pathsAndFiles.packageAssembliesFolder, files, true);
files = Utilities.GetFilesByPatterns(Context, new string[] {
project.dnn.pathsAndFiles.pathToScripts + "/*.SqlDataProvider"
});
AddFilesToZip(packagePath, project.dnn.pathsAndFiles.pathToScripts, project.dnn.pathsAndFiles.packageScriptsFolder, files, true);
files = Utilities.GetFilesByPatterns(Context, new string[] {
project.dnn.pathsAndFiles.pathToSupplementaryFiles + "/License.txt"
});
AddFilesToZip(packagePath, project.dnn.pathsAndFiles.pathToSupplementaryFiles, files, true);
var releaseNotes = Connect.CakeUtils.Markdown.ToHtml(project.dnn.pathsAndFiles.pathToSupplementaryFiles + "/ReleaseNotes.md");
if (releaseNotes != "") {
AddTextFileToZip(packagePath, releaseNotes, "ReleaseNotes.txt", true);
} else {
files = Utilities.GetFilesByPatterns(Context, new string[] {
project.dnn.pathsAndFiles.pathToSupplementaryFiles + "/ReleaseNotes.txt"
});
AddFilesToZip(packagePath, project.dnn.pathsAndFiles.pathToSupplementaryFiles, files, true);
}
var m = new Manifest(project);
AddXmlFileToZip(packagePath, m, project.dnn.name + ".dnn", true);
});
Task("Watch")
.IsDependentOn("CopyDev")
.Does(()=>{
var w = new Watcher(Context, project, new System.IO.DirectoryInfo(project.dnn.pathsAndFiles.devFolder).FullName, devDnnPath);
});
Task("Default")
.IsDependentOn("Watch")
.Does(() => {
});
RunTarget(target);