2018-08-05 14:28:05 +00:00
|
|
|
#addin nuget:?package=Cake.Npm
|
|
|
|
#addin nuget:?package=SharpZipLib
|
|
|
|
#addin nuget:?package=Cake.Compression
|
2018-12-30 12:29:44 +00:00
|
|
|
#addin "Cake.FileHelpers"
|
2017-01-08 10:03:04 +00:00
|
|
|
|
|
|
|
// Build variables
|
|
|
|
var outputFolder = "./_output";
|
|
|
|
var outputFolderMono = outputFolder + "_mono";
|
|
|
|
var outputFolderOsx = outputFolder + "_osx";
|
|
|
|
var outputFolderOsxApp = outputFolderOsx + "_app";
|
|
|
|
var testPackageFolder = "./_tests";
|
|
|
|
var testSearchPattern = "*.Test/bin/x86/Release";
|
|
|
|
var sourceFolder = "./src";
|
|
|
|
var solutionFile = sourceFolder + "/NzbDrone.sln";
|
|
|
|
var updateFolder = outputFolder + "/NzbDrone.Update";
|
|
|
|
var updateFolderMono = outputFolderMono + "/NzbDrone.Update";
|
|
|
|
|
|
|
|
// Artifact variables
|
|
|
|
var artifactsFolder = "./_artifacts";
|
|
|
|
var artifactsFolderWindows = artifactsFolder + "/windows";
|
|
|
|
var artifactsFolderLinux = artifactsFolder + "/linux";
|
|
|
|
var artifactsFolderOsx = artifactsFolder + "/osx";
|
|
|
|
var artifactsFolderOsxApp = artifactsFolder + "/osx-app";
|
|
|
|
|
|
|
|
// Utility methods
|
|
|
|
public void RemoveEmptyFolders(string startLocation) {
|
|
|
|
foreach (var directory in System.IO.Directory.GetDirectories(startLocation))
|
|
|
|
{
|
|
|
|
RemoveEmptyFolders(directory);
|
|
|
|
|
2018-08-05 14:28:05 +00:00
|
|
|
if (System.IO.Directory.GetFiles(directory).Length == 0 &&
|
2017-01-08 10:03:04 +00:00
|
|
|
System.IO.Directory.GetDirectories(directory).Length == 0)
|
|
|
|
{
|
|
|
|
DeleteDirectory(directory, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CleanFolder(string path, bool keepConfigFiles) {
|
|
|
|
DeleteFiles(path + "/**/*.transform");
|
|
|
|
|
|
|
|
if (!keepConfigFiles) {
|
|
|
|
DeleteFiles(path + "/**/*.dll.config");
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteFiles(path + "/**/FluentValidation.resources.dll");
|
|
|
|
DeleteFiles(path + "/**/App.config");
|
|
|
|
|
|
|
|
DeleteFiles(path + "/**/*.less");
|
|
|
|
|
|
|
|
DeleteFiles(path + "/**/*.vshost.exe");
|
|
|
|
|
|
|
|
DeleteFiles(path + "/**/*.dylib");
|
|
|
|
|
|
|
|
RemoveEmptyFolders(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void CreateMdbs(string path) {
|
|
|
|
foreach (var file in System.IO.Directory.EnumerateFiles(path, "*.pdb", System.IO.SearchOption.AllDirectories)) {
|
|
|
|
var actualFile = file.Substring(0, file.Length - 4);
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-01-08 10:03:04 +00:00
|
|
|
if (FileExists(actualFile + ".exe")) {
|
|
|
|
StartProcess("./tools/pdb2mdb/pdb2mdb.exe", new ProcessSettings()
|
|
|
|
.WithArguments(args => args.Append(actualFile + ".exe")));
|
|
|
|
}
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-01-08 10:03:04 +00:00
|
|
|
if (FileExists(actualFile + ".dll")) {
|
|
|
|
StartProcess("./tools/pdb2mdb/pdb2mdb.exe", new ProcessSettings()
|
|
|
|
.WithArguments(args => args.Append(actualFile + ".dll")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build Tasks
|
|
|
|
Task("Compile").Does(() => {
|
|
|
|
// Build
|
|
|
|
if (DirectoryExists(outputFolder)) {
|
|
|
|
DeleteDirectory(outputFolder, true);
|
|
|
|
}
|
|
|
|
|
2018-08-05 14:28:05 +00:00
|
|
|
MSBuild(solutionFile, config =>
|
|
|
|
config.UseToolVersion(MSBuildToolVersion.VS2017)
|
2017-01-08 10:03:04 +00:00
|
|
|
.WithTarget("Clean")
|
|
|
|
.SetVerbosity(Verbosity.Minimal));
|
|
|
|
|
|
|
|
NuGetRestore(solutionFile);
|
|
|
|
|
2018-08-05 14:28:05 +00:00
|
|
|
MSBuild(solutionFile, config =>
|
|
|
|
config.UseToolVersion(MSBuildToolVersion.VS2017)
|
2017-01-08 10:03:04 +00:00
|
|
|
.SetPlatformTarget(PlatformTarget.x86)
|
|
|
|
.SetConfiguration("Release")
|
|
|
|
.WithProperty("AllowedReferenceRelatedFileExtensions", new string[] { ".pdb" })
|
|
|
|
.WithTarget("Build")
|
|
|
|
.SetVerbosity(Verbosity.Minimal));
|
|
|
|
|
|
|
|
CleanFolder(outputFolder, false);
|
|
|
|
|
|
|
|
// Add JsonNet
|
|
|
|
DeleteFiles(outputFolder + "/Newtonsoft.Json.*");
|
|
|
|
CopyFiles(sourceFolder + "/packages/Newtonsoft.Json.*/lib/net35/*.dll", outputFolder);
|
|
|
|
CopyFiles(sourceFolder + "/packages/Newtonsoft.Json.*/lib/net35/*.dll", updateFolder);
|
|
|
|
|
|
|
|
// Remove Mono stuff
|
|
|
|
DeleteFile(outputFolder + "/Mono.Posix.dll");
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("Gulp").Does(() => {
|
2017-05-09 17:49:30 +00:00
|
|
|
NpmInstall(new NpmInstallSettings {
|
|
|
|
LogLevel = NpmLogLevel.Silent,
|
|
|
|
WorkingDirectory = "./",
|
|
|
|
Production = true
|
|
|
|
});
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-05-09 17:49:30 +00:00
|
|
|
NpmRunScript("build");
|
2017-01-08 10:03:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Task("PackageMono").Does(() => {
|
|
|
|
// Start mono package
|
|
|
|
if (DirectoryExists(outputFolderMono)) {
|
|
|
|
DeleteDirectory(outputFolderMono, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyDirectory(outputFolder, outputFolderMono);
|
|
|
|
|
|
|
|
// Create MDBs
|
|
|
|
CreateMdbs(outputFolderMono);
|
|
|
|
|
|
|
|
// Remove PDBs
|
|
|
|
DeleteFiles(outputFolderMono + "/**/*.pdb");
|
|
|
|
|
|
|
|
// Remove service helpers
|
|
|
|
DeleteFiles(outputFolderMono + "/ServiceUninstall.*");
|
|
|
|
DeleteFiles(outputFolderMono + "/ServiceInstall.*");
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-01-08 10:03:04 +00:00
|
|
|
// Remove native windows binaries
|
|
|
|
DeleteFiles(outputFolderMono + "/sqlite3.*");
|
|
|
|
DeleteFiles(outputFolderMono + "/MediaInfo.*");
|
|
|
|
|
|
|
|
// Adding NzbDrone.Core.dll.config (for dllmap)
|
|
|
|
CopyFile(sourceFolder + "/NzbDrone.Core/NzbDrone.Core.dll.config", outputFolderMono + "/NzbDrone.Core.dll.config");
|
|
|
|
|
|
|
|
// Adding CurlSharp.dll.config (for dllmap)
|
|
|
|
CopyFile(sourceFolder + "/NzbDrone.Common/CurlSharp.dll.config", outputFolderMono + "/CurlSharp.dll.config");
|
|
|
|
|
|
|
|
// Renaming Radarr.Console.exe to Radarr.exe
|
|
|
|
DeleteFiles(outputFolderMono + "/Radarr.exe*");
|
|
|
|
MoveFile(outputFolderMono + "/Radarr.Console.exe", outputFolderMono + "/Radarr.exe");
|
|
|
|
MoveFile(outputFolderMono + "/Radarr.Console.exe.config", outputFolderMono + "/Radarr.exe.config");
|
|
|
|
MoveFile(outputFolderMono + "/Radarr.Console.exe.mdb", outputFolderMono + "/Radarr.exe.mdb");
|
|
|
|
|
|
|
|
// Remove NzbDrone.Windows.*
|
|
|
|
DeleteFiles(outputFolderMono + "/NzbDrone.Windows.*");
|
|
|
|
|
|
|
|
// Adding NzbDrone.Mono to updatePackage
|
|
|
|
CopyFiles(outputFolderMono + "/NzbDrone.Mono.*", updateFolderMono);
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("PackageOsx").Does(() => {
|
|
|
|
// Start osx package
|
|
|
|
if (DirectoryExists(outputFolderOsx)) {
|
|
|
|
DeleteDirectory(outputFolderOsx, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyDirectory(outputFolderMono, outputFolderOsx);
|
|
|
|
|
|
|
|
// Adding sqlite dylibs
|
|
|
|
CopyFiles(sourceFolder + "/Libraries/Sqlite/*.dylib", outputFolderOsx);
|
|
|
|
|
|
|
|
// Adding MediaInfo dylib
|
|
|
|
CopyFiles(sourceFolder + "/Libraries/MediaInfo/*.dylib", outputFolderOsx);
|
|
|
|
|
2017-05-17 09:20:32 +00:00
|
|
|
// Chmod as executable
|
|
|
|
StartProcess(@"C:\cygwin64\bin\chmod.exe", new ProcessSettings()
|
|
|
|
.WithArguments(args => args
|
|
|
|
.Append("+x")
|
|
|
|
.Append(outputFolderOsx + "/Radarr")));
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-05-17 23:08:13 +00:00
|
|
|
// Adding Startup script
|
|
|
|
CopyFile("./osx/Radarr", outputFolderOsx + "/Radarr");
|
2017-01-08 10:03:04 +00:00
|
|
|
});
|
|
|
|
|
2018-12-30 12:29:44 +00:00
|
|
|
Task("PackageOsxApp").Does((ctx) => {
|
2017-01-08 10:03:04 +00:00
|
|
|
// Start osx app package
|
|
|
|
if (DirectoryExists(outputFolderOsxApp)) {
|
|
|
|
DeleteDirectory(outputFolderOsxApp, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateDirectory(outputFolderOsxApp);
|
|
|
|
|
|
|
|
// Copy osx package files
|
|
|
|
CopyDirectory("./osx/Radarr.app", outputFolderOsxApp + "/Radarr.app");
|
|
|
|
CopyDirectory(outputFolderOsx, outputFolderOsxApp + "/Radarr.app/Contents/MacOS");
|
2018-12-30 12:29:44 +00:00
|
|
|
|
|
|
|
// Edit version of osx app
|
|
|
|
ctx.ReplaceTextInFiles(outputFolderOsxApp + "/Radarr.app/Contents/Info.plist", "2.0", ctx.EnvironmentVariable("APPVEYOR_BUILD_VERSION") ?? "unknown");
|
2017-01-08 10:03:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Task("PackageTests").Does(() => {
|
|
|
|
// Start tests package
|
|
|
|
if (DirectoryExists(testPackageFolder)) {
|
|
|
|
DeleteDirectory(testPackageFolder, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateDirectory(testPackageFolder);
|
|
|
|
|
|
|
|
// Copy tests
|
|
|
|
CopyFiles(sourceFolder + "/" + testSearchPattern + "/*", testPackageFolder);
|
|
|
|
foreach (var directory in System.IO.Directory.GetDirectories(sourceFolder, "*.Test")) {
|
|
|
|
var releaseDirectory = directory + "/bin/x86/Release";
|
|
|
|
if (DirectoryExists(releaseDirectory)) {
|
|
|
|
foreach (var releaseSubDirectory in System.IO.Directory.GetDirectories(releaseDirectory)) {
|
|
|
|
Information(System.IO.Path.GetDirectoryName(releaseSubDirectory));
|
|
|
|
CopyDirectory(releaseSubDirectory, testPackageFolder + "/" + System.IO.Path.GetFileName(releaseSubDirectory));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install NUnit.ConsoleRunner
|
|
|
|
NuGetInstall("NUnit.ConsoleRunner", new NuGetInstallSettings {
|
|
|
|
Version = "3.2.0",
|
|
|
|
OutputDirectory = testPackageFolder
|
|
|
|
});
|
|
|
|
|
|
|
|
// Copy dlls
|
|
|
|
CopyFiles(outputFolder + "/*.dll", testPackageFolder);
|
2018-08-05 14:28:05 +00:00
|
|
|
|
2017-01-08 10:03:04 +00:00
|
|
|
// Copy scripts
|
|
|
|
CopyFiles("./*.sh", testPackageFolder);
|
|
|
|
|
|
|
|
// Create MDBs for tests
|
|
|
|
CreateMdbs(testPackageFolder);
|
|
|
|
|
|
|
|
// Remove config
|
|
|
|
DeleteFiles(testPackageFolder + "/*.log.config");
|
|
|
|
|
|
|
|
// Clean
|
|
|
|
CleanFolder(testPackageFolder, true);
|
|
|
|
|
|
|
|
// Adding NzbDrone.Core.dll.config (for dllmap)
|
|
|
|
CopyFile(sourceFolder + "/NzbDrone.Core/NzbDrone.Core.dll.config", testPackageFolder + "/NzbDrone.Core.dll.config");
|
|
|
|
|
|
|
|
// Adding CurlSharp.dll.config (for dllmap)
|
|
|
|
CopyFile(sourceFolder + "/NzbDrone.Common/CurlSharp.dll.config", testPackageFolder + "/CurlSharp.dll.config");
|
|
|
|
|
|
|
|
// Adding CurlSharp libraries
|
|
|
|
CopyFiles(sourceFolder + "/ExternalModules/CurlSharp/libs/i386/*", testPackageFolder);
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("CleanupWindowsPackage").Does(() => {
|
|
|
|
// Remove mono
|
|
|
|
DeleteFiles(outputFolder + "/NzbDrone.Mono.*");
|
|
|
|
|
|
|
|
// Adding NzbDrone.Windows to updatePackage
|
|
|
|
CopyFiles(outputFolder + "/NzbDrone.Windows.*", updateFolder);
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("Build")
|
|
|
|
.IsDependentOn("Compile")
|
|
|
|
.IsDependentOn("Gulp")
|
|
|
|
.IsDependentOn("PackageMono")
|
|
|
|
.IsDependentOn("PackageOsx")
|
|
|
|
.IsDependentOn("PackageOsxApp")
|
|
|
|
.IsDependentOn("PackageTests")
|
|
|
|
.IsDependentOn("CleanupWindowsPackage");
|
|
|
|
|
|
|
|
// Build Artifacts
|
|
|
|
Task("CleanArtifacts").Does(() => {
|
|
|
|
if (DirectoryExists(artifactsFolder)) {
|
|
|
|
DeleteDirectory(artifactsFolder, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateDirectory(artifactsFolder);
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("ArtifactsWindows").Does(() => {
|
|
|
|
CopyDirectory(outputFolder, artifactsFolderWindows + "/Radarr");
|
|
|
|
});
|
|
|
|
|
2017-04-10 12:30:55 +00:00
|
|
|
Task("ArtifactsWindowsInstaller").Does(() => {
|
|
|
|
InnoSetup("./setup/nzbdrone.iss", new InnoSetupSettings {
|
2017-05-17 09:20:32 +00:00
|
|
|
OutputDirectory = artifactsFolder,
|
2017-04-10 13:18:11 +00:00
|
|
|
ToolPath = "./setup/inno/ISCC.exe"
|
2017-05-17 09:20:32 +00:00
|
|
|
});
|
2017-04-10 12:30:55 +00:00
|
|
|
});
|
|
|
|
|
2017-01-08 10:03:04 +00:00
|
|
|
Task("ArtifactsLinux").Does(() => {
|
|
|
|
CopyDirectory(outputFolderMono, artifactsFolderLinux + "/Radarr");
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("ArtifactsOsx").Does(() => {
|
|
|
|
CopyDirectory(outputFolderOsx, artifactsFolderOsx + "/Radarr");
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("ArtifactsOsxApp").Does(() => {
|
|
|
|
CopyDirectory(outputFolderOsxApp, artifactsFolderOsxApp);
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("CompressArtifacts").Does(() => {
|
|
|
|
var prefix = "";
|
|
|
|
|
|
|
|
if (AppVeyor.IsRunningOnAppVeyor) {
|
2017-03-06 21:23:25 +00:00
|
|
|
prefix += AppVeyor.Environment.Repository.Branch.Replace("/", "-") + ".";
|
2017-01-08 10:03:04 +00:00
|
|
|
prefix += AppVeyor.Environment.Build.Version + ".";
|
|
|
|
}
|
|
|
|
|
|
|
|
Zip(artifactsFolderWindows, artifactsFolder + "/Radarr." + prefix + "windows.zip");
|
|
|
|
GZipCompress(artifactsFolderLinux, artifactsFolder + "/Radarr." + prefix + "linux.tar.gz");
|
|
|
|
GZipCompress(artifactsFolderOsx, artifactsFolder + "/Radarr." + prefix + "osx.tar.gz");
|
|
|
|
Zip(artifactsFolderOsxApp, artifactsFolder + "/Radarr." + prefix + "osx-app.zip");
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("Artifacts")
|
|
|
|
.IsDependentOn("CleanArtifacts")
|
|
|
|
.IsDependentOn("ArtifactsWindows")
|
2017-04-10 12:30:55 +00:00
|
|
|
.IsDependentOn("ArtifactsWindowsInstaller")
|
2017-01-08 10:03:04 +00:00
|
|
|
.IsDependentOn("ArtifactsLinux")
|
|
|
|
.IsDependentOn("ArtifactsOsx")
|
|
|
|
.IsDependentOn("ArtifactsOsxApp")
|
|
|
|
.IsDependentOn("CompressArtifacts");
|
|
|
|
|
|
|
|
// Run
|
|
|
|
RunTarget("Build");
|
2017-03-06 21:23:25 +00:00
|
|
|
RunTarget("Artifacts");
|