2017-04-15 16:42:24 +03:00
|
|
|
#tool nuget:?package=GitVersion.CommandLine
|
|
|
|
#tool nuget:?package=gitlink
|
|
|
|
#tool nuget:?package=vswhere
|
2017-06-11 15:12:07 +03:00
|
|
|
#tool nuget:?package=NUnit.ConsoleRunner
|
2017-06-01 20:35:14 +03:00
|
|
|
#addin nuget:?package=Cake.Incubator
|
|
|
|
#addin nuget:?package=Cake.Git
|
2017-01-19 22:18:02 +03:00
|
|
|
|
|
|
|
var sln = new FilePath("MvvmCross_All.sln");
|
|
|
|
var outputDir = new DirectoryPath("artifacts");
|
2017-01-20 01:42:33 +03:00
|
|
|
var nuspecDir = new DirectoryPath("nuspec");
|
2017-01-19 22:18:02 +03:00
|
|
|
var target = Argument("target", "Default");
|
|
|
|
|
2017-01-22 18:39:32 +03:00
|
|
|
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
|
|
|
|
|
2017-01-19 22:18:02 +03:00
|
|
|
Task("Clean").Does(() =>
|
|
|
|
{
|
|
|
|
CleanDirectories("./**/bin");
|
|
|
|
CleanDirectories("./**/obj");
|
|
|
|
CleanDirectories(outputDir.FullPath);
|
2017-06-11 15:12:07 +03:00
|
|
|
|
|
|
|
EnsureDirectoryExists(outputDir);
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
GitVersion versionInfo = null;
|
|
|
|
Task("Version").Does(() => {
|
2017-04-26 10:35:19 +03:00
|
|
|
versionInfo = GitVersion(new GitVersionSettings {
|
2017-01-19 22:18:02 +03:00
|
|
|
UpdateAssemblyInfo = true,
|
2017-04-26 10:52:50 +03:00
|
|
|
OutputType = GitVersionOutput.Json
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
2017-04-23 22:36:32 +03:00
|
|
|
Information("GitVersion -> {0}", versionInfo.Dump());
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
2017-01-22 18:39:32 +03:00
|
|
|
Task("UpdateAppVeyorBuildNumber")
|
|
|
|
.IsDependentOn("Version")
|
|
|
|
.WithCriteria(() => isRunningOnAppVeyor)
|
|
|
|
.Does(() =>
|
|
|
|
{
|
|
|
|
AppVeyor.UpdateBuildVersion(versionInfo.FullBuildMetaData);
|
|
|
|
});
|
|
|
|
|
2017-04-15 16:42:24 +03:00
|
|
|
FilePath msBuildPath;
|
|
|
|
Task("ResolveBuildTools")
|
|
|
|
.Does(() =>
|
|
|
|
{
|
|
|
|
var vsLatest = VSWhereLatest();
|
|
|
|
msBuildPath = (vsLatest == null)
|
|
|
|
? null
|
|
|
|
: vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("Restore")
|
|
|
|
.IsDependentOn("ResolveBuildTools")
|
|
|
|
.Does(() => {
|
|
|
|
NuGetRestore(sln, new NuGetRestoreSettings {
|
|
|
|
ToolPath = "tools/nuget.exe"
|
|
|
|
});
|
|
|
|
// MSBuild(sln, settings => settings.WithTarget("Restore"));
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
Task("Build")
|
2017-04-15 16:42:24 +03:00
|
|
|
.IsDependentOn("ResolveBuildTools")
|
2017-01-19 22:18:02 +03:00
|
|
|
.IsDependentOn("Clean")
|
2017-01-22 18:39:32 +03:00
|
|
|
.IsDependentOn("UpdateAppVeyorBuildNumber")
|
2017-01-19 22:18:02 +03:00
|
|
|
.IsDependentOn("Restore")
|
|
|
|
.Does(() => {
|
2017-04-15 16:42:24 +03:00
|
|
|
|
|
|
|
var settings = new MSBuildSettings
|
|
|
|
{
|
|
|
|
Configuration = "Release",
|
|
|
|
ToolPath = msBuildPath
|
|
|
|
};
|
|
|
|
|
|
|
|
settings.Properties.Add("DebugSymbols", new List<string> { "True" });
|
|
|
|
settings.Properties.Add("DebugType", new List<string> { "Full" });
|
|
|
|
|
|
|
|
MSBuild(sln, settings);
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
2017-06-11 15:12:07 +03:00
|
|
|
Task("UnitTest")
|
2017-01-19 22:18:02 +03:00
|
|
|
.IsDependentOn("Build")
|
2017-06-11 17:10:07 +03:00
|
|
|
.Does(() =>
|
2017-06-11 15:12:07 +03:00
|
|
|
{
|
2017-06-11 17:10:07 +03:00
|
|
|
var testPaths = new List<string> {
|
|
|
|
new FilePath("./MvvmCross/Test/Test/bin/Release/MvvmCross.Test.dll").FullPath,
|
|
|
|
new FilePath("./MvvmCross/Binding/Test/bin/Release/MvvmCross.Binding.Test.dll").FullPath,
|
|
|
|
new FilePath("./MvvmCross/Platform/Test/bin/Release/MvvmCross.Platform.Test.dll").FullPath,
|
|
|
|
new FilePath("./MvvmCross-Plugins/Color/MvvmCross.Plugins.Color.Test/bin/Release/MvvmCross.Plugins.Color.Test.dll").FullPath,
|
|
|
|
new FilePath("./MvvmCross-Plugins/Messenger/MvvmCross.Plugins.Messenger.Test/bin/Release/MvvmCross.Plugins.Messenger.Test.dll").FullPath,
|
|
|
|
new FilePath("./MvvmCross-Plugins/Network/MvvmCross.Plugins.Network.Test/bin/Release/MvvmCross.Plugins.Network.Test.dll").FullPath
|
|
|
|
};
|
2017-06-11 15:12:07 +03:00
|
|
|
|
2017-06-11 17:10:07 +03:00
|
|
|
NUnit3(testPaths, new NUnit3Settings {
|
2017-06-11 15:12:07 +03:00
|
|
|
Timeout = 30000,
|
|
|
|
OutputFile = new FilePath(outputDir + "/NUnitOutput.txt"),
|
|
|
|
Results = new FilePath(outputDir + "/NUnitTestResult.xml")
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("GitLink")
|
|
|
|
.IsDependentOn("UnitTest")
|
2017-01-20 01:42:33 +03:00
|
|
|
//pdbstr.exe and costura are not xplat currently
|
|
|
|
.WithCriteria(() => IsRunningOnWindows())
|
2017-04-26 02:53:00 +03:00
|
|
|
.WithCriteria(() =>
|
|
|
|
StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "develop") ||
|
|
|
|
IsMasterOrReleases())
|
2017-01-20 01:42:33 +03:00
|
|
|
.Does(() =>
|
|
|
|
{
|
2017-04-23 20:48:55 +03:00
|
|
|
var projectsToIgnore = new string[] {
|
|
|
|
"MasterDetailExample.Core",
|
|
|
|
"MasterDetailExample.Droid",
|
|
|
|
"MasterDetailExample.iOS",
|
|
|
|
"MasterDetailExample.UWP",
|
|
|
|
"PageRendererExample.Core",
|
|
|
|
"PageRendererExample.Droid",
|
|
|
|
"PageRendererExample.iOS",
|
|
|
|
"PageRendererExample.WindowsUWP",
|
|
|
|
"MvvmCross.iOS.Support.ExpandableTableView.Core",
|
|
|
|
"MvvmCross.iOS.Support.ExpandableTableView.iOS",
|
|
|
|
"MvvmCross.iOS.Support.JASidePanelsSample.Core",
|
|
|
|
"MvvmCross.iOS.Support.JASidePanelsSample.iOS",
|
|
|
|
"MvvmCross.iOS.Support.Tabs.Core",
|
|
|
|
"MvvmCross.iOS.Support.Tabs.iOS",
|
|
|
|
"MvvmCross.iOS.Support.XamarinSidebarSample.Core",
|
|
|
|
"MvvmCross.iOS.Support.XamarinSidebarSample.iOS",
|
|
|
|
"mvvmcross.codeanalysis.vsix",
|
|
|
|
"example",
|
|
|
|
"example.android",
|
|
|
|
"example.ios",
|
|
|
|
"example.windowsphone",
|
|
|
|
"example.core",
|
|
|
|
"example.droid",
|
|
|
|
"Example.W81",
|
|
|
|
"Eventhooks.Core",
|
|
|
|
"Eventhooks.Droid",
|
|
|
|
"Eventhooks.iOS",
|
|
|
|
"Eventhooks.Uwp",
|
|
|
|
"Eventhooks.Wpf",
|
|
|
|
"RoutingExample.Core",
|
|
|
|
"RoutingExample.iOS",
|
|
|
|
"RoutingExample.Droid",
|
|
|
|
"MvvmCross.TestProjects.CustomBinding.Core",
|
|
|
|
"MvvmCross.TestProjects.CustomBinding.iOS",
|
|
|
|
"MvvmCross.TestProjects.CustomBinding.Droid",
|
|
|
|
"playground",
|
2017-04-29 16:57:00 +03:00
|
|
|
"playground.core",
|
2017-04-29 16:03:45 +03:00
|
|
|
"playground.ios",
|
2017-06-09 17:04:08 +03:00
|
|
|
"playground.mac",
|
2017-04-29 16:03:45 +03:00
|
|
|
"MvxBindingsExample",
|
|
|
|
"MvxBindingsExample.Android",
|
|
|
|
"MvxBindingsExample.iOS",
|
|
|
|
"MvxBindingsExample.UWP"
|
2017-04-23 20:48:55 +03:00
|
|
|
};
|
|
|
|
|
2017-04-26 21:16:45 +03:00
|
|
|
GitLink("./",
|
2017-01-20 01:42:33 +03:00
|
|
|
new GitLinkSettings {
|
2017-01-21 11:42:15 +03:00
|
|
|
RepositoryUrl = "https://github.com/mvvmcross/mvvmcross",
|
2017-04-26 21:16:45 +03:00
|
|
|
Configuration = "Release",
|
|
|
|
SolutionFileName = "MvvmCross_All.sln",
|
2017-04-23 20:48:55 +03:00
|
|
|
ArgumentCustomization = args => args.Append("-ignore " + string.Join(",", projectsToIgnore))
|
2017-01-20 01:42:33 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Task("Package")
|
|
|
|
.IsDependentOn("GitLink")
|
2017-04-26 02:53:00 +03:00
|
|
|
.WithCriteria(() =>
|
|
|
|
StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "develop") ||
|
|
|
|
IsMasterOrReleases())
|
2017-01-20 01:42:33 +03:00
|
|
|
.Does(() =>
|
|
|
|
{
|
|
|
|
var nugetSettings = new NuGetPackSettings {
|
|
|
|
Authors = new [] { "MvvmCross contributors" },
|
2017-01-21 11:42:15 +03:00
|
|
|
Owners = new [] { "MvvmCross" },
|
2017-04-11 16:17:55 +03:00
|
|
|
IconUrl = new Uri("http://i.imgur.com/Baucn8c.png"),
|
2017-01-20 01:42:33 +03:00
|
|
|
ProjectUrl = new Uri("https://github.com/MvvmCross/MvvmCross"),
|
|
|
|
LicenseUrl = new Uri("https://raw.githubusercontent.com/MvvmCross/MvvmCross/develop/LICENSE"),
|
2017-01-21 11:42:15 +03:00
|
|
|
Copyright = "Copyright (c) MvvmCross",
|
2017-01-20 01:42:33 +03:00
|
|
|
RequireLicenseAcceptance = false,
|
|
|
|
Version = versionInfo.NuGetVersion,
|
|
|
|
Symbols = false,
|
|
|
|
NoPackageAnalysis = true,
|
|
|
|
OutputDirectory = outputDir,
|
2017-01-21 11:42:15 +03:00
|
|
|
Verbosity = NuGetVerbosity.Detailed,
|
|
|
|
BasePath = "./nuspec"
|
2017-01-20 01:42:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
var nuspecs = new List<string> {
|
|
|
|
"MvvmCross.nuspec",
|
|
|
|
"MvvmCross.Binding.nuspec",
|
|
|
|
"MvvmCross.CodeAnalysis.nuspec",
|
|
|
|
"MvvmCross.Console.Platform.nuspec",
|
|
|
|
"MvvmCross.Core.nuspec",
|
|
|
|
"MvvmCross.Droid.FullFragging.nuspec",
|
|
|
|
"MvvmCross.Droid.Shared.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.Core.UI.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.Core.Utils.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.Design.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.Fragment.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V7.AppCompat.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V7.Preference.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V7.RecyclerView.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V14.Preference.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V17.Leanback.nuspec",
|
2017-04-29 19:36:32 +03:00
|
|
|
"MvvmCross.Forms.nuspec",
|
2017-01-20 01:42:33 +03:00
|
|
|
"MvvmCross.iOS.Support.nuspec",
|
|
|
|
"MvvmCross.iOS.Support.XamarinSidebar.nuspec",
|
|
|
|
"MvvmCross.Platform.nuspec",
|
|
|
|
"MvvmCross.Plugin.Accelerometer.nuspec",
|
|
|
|
"MvvmCross.Plugin.All.nuspec",
|
|
|
|
"MvvmCross.Plugin.Color.nuspec",
|
|
|
|
"MvvmCross.Plugin.DownloadCache.nuspec",
|
|
|
|
"MvvmCross.Plugin.Email.nuspec",
|
|
|
|
"MvvmCross.Plugin.FieldBinding.nuspec",
|
|
|
|
"MvvmCross.Plugin.File.nuspec",
|
|
|
|
"MvvmCross.Plugin.Json.nuspec",
|
|
|
|
"MvvmCross.Plugin.JsonLocalization.nuspec",
|
|
|
|
"MvvmCross.Plugin.Location.nuspec",
|
|
|
|
"MvvmCross.Plugin.Location.Fused.nuspec",
|
|
|
|
"MvvmCross.Plugin.Messenger.nuspec",
|
|
|
|
"MvvmCross.Plugin.MethodBinding.nuspec",
|
|
|
|
"MvvmCross.Plugin.Network.nuspec",
|
|
|
|
"MvvmCross.Plugin.PhoneCall.nuspec",
|
|
|
|
"MvvmCross.Plugin.PictureChooser.nuspec",
|
|
|
|
"MvvmCross.Plugin.ResourceLoader.nuspec",
|
|
|
|
"MvvmCross.Plugin.ResxLocalization.nuspec",
|
|
|
|
"MvvmCross.Plugin.Share.nuspec",
|
|
|
|
"MvvmCross.Plugin.Visibility.nuspec",
|
|
|
|
"MvvmCross.Plugin.WebBrowser.nuspec",
|
2017-01-21 11:42:15 +03:00
|
|
|
"MvvmCross.StarterPack.nuspec",
|
|
|
|
"MvvmCross.Tests.nuspec"
|
2017-01-20 01:42:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
foreach(var nuspec in nuspecs)
|
|
|
|
{
|
|
|
|
NuGetPack(nuspecDir + "/" + nuspec, nugetSettings);
|
|
|
|
}
|
2017-01-19 22:18:02 +03:00
|
|
|
});
|
|
|
|
|
2017-01-22 18:39:32 +03:00
|
|
|
Task("PublishPackages")
|
|
|
|
.IsDependentOn("Package")
|
2017-04-23 21:58:54 +03:00
|
|
|
.WithCriteria(() => !BuildSystem.IsLocalBuild)
|
|
|
|
.WithCriteria(() => IsRepository("mvvmcross/mvvmcross"))
|
2017-04-23 23:34:49 +03:00
|
|
|
.WithCriteria(() =>
|
|
|
|
StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "develop") ||
|
2017-04-24 21:17:04 +03:00
|
|
|
IsMasterOrReleases())
|
2017-01-22 18:39:32 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
2017-04-23 23:34:49 +03:00
|
|
|
if (StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "master") && !IsTagged())
|
2017-01-22 18:39:32 +03:00
|
|
|
{
|
|
|
|
Information("Packages will not be published as this release has not been tagged.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolve the API key.
|
2017-04-23 20:48:55 +03:00
|
|
|
var nugetKeySource = GetNugetKeyAndSource();
|
|
|
|
var apiKey = nugetKeySource.Item1;
|
|
|
|
var source = nugetKeySource.Item2;
|
2017-01-22 18:39:32 +03:00
|
|
|
|
|
|
|
var nugetFiles = GetFiles(outputDir + "/*.nupkg");
|
|
|
|
|
|
|
|
foreach(var nugetFile in nugetFiles)
|
|
|
|
{
|
|
|
|
NuGetPush(nugetFile, new NuGetPushSettings {
|
|
|
|
Source = source,
|
|
|
|
ApiKey = apiKey
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-01-19 22:18:02 +03:00
|
|
|
Task("Default")
|
2017-01-22 18:39:32 +03:00
|
|
|
.IsDependentOn("PublishPackages")
|
2017-04-23 22:36:32 +03:00
|
|
|
.Does(() =>
|
2017-04-24 00:05:44 +03:00
|
|
|
{
|
2017-04-23 22:36:32 +03:00
|
|
|
});
|
2017-01-19 22:18:02 +03:00
|
|
|
|
|
|
|
RunTarget(target);
|
2017-04-23 20:48:55 +03:00
|
|
|
|
2017-04-24 21:17:04 +03:00
|
|
|
bool IsMasterOrReleases()
|
|
|
|
{
|
|
|
|
if (StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "master"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (versionInfo.BranchName.Contains("releases/"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-23 20:48:55 +03:00
|
|
|
bool IsRepository(string repoName)
|
|
|
|
{
|
|
|
|
if (isRunningOnAppVeyor)
|
2017-04-23 23:34:49 +03:00
|
|
|
{
|
2017-04-24 00:05:44 +03:00
|
|
|
var buildEnvRepoName = AppVeyor.Environment.Repository.Name;
|
2017-04-23 23:34:49 +03:00
|
|
|
Information("Checking repo name: {0} against build repo name: {1}", repoName, buildEnvRepoName);
|
|
|
|
return StringComparer.OrdinalIgnoreCase.Equals(repoName, buildEnvRepoName);
|
|
|
|
}
|
2017-04-24 00:05:44 +03:00
|
|
|
else
|
|
|
|
{
|
2017-06-01 20:35:14 +03:00
|
|
|
try
|
|
|
|
{
|
|
|
|
var path = MakeAbsolute(sln).GetDirectory().FullPath;
|
|
|
|
using (var repo = new LibGit2Sharp.Repository(path))
|
|
|
|
{
|
|
|
|
var origin = repo.Network.Remotes.FirstOrDefault(
|
|
|
|
r => r.Name.ToLowerInvariant() == "origin");
|
|
|
|
return origin.Url.ToLowerInvariant() ==
|
|
|
|
"https://github.com/" + repoName.ToLowerInvariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
Information("Failed to lookup repository: {0}", ex);
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-24 00:05:44 +03:00
|
|
|
}
|
2017-04-23 20:48:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsTagged()
|
|
|
|
{
|
2017-06-01 20:35:14 +03:00
|
|
|
var path = MakeAbsolute(sln).GetDirectory().FullPath;
|
|
|
|
using (var repo = new LibGit2Sharp.Repository(path))
|
2017-04-23 20:48:55 +03:00
|
|
|
{
|
2017-06-01 20:35:14 +03:00
|
|
|
var head = repo.Head;
|
|
|
|
var headSha = head.Tip.Sha;
|
|
|
|
|
|
|
|
var tag = repo.Tags.FirstOrDefault(t => t.Target.Sha == headSha);
|
|
|
|
if (tag == null)
|
|
|
|
{
|
|
|
|
Information("HEAD is not tagged");
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-23 21:18:32 +03:00
|
|
|
|
2017-06-01 20:35:14 +03:00
|
|
|
Information("HEAD is tagged: {0}", tag.FriendlyName);
|
|
|
|
return true;
|
|
|
|
}
|
2017-04-23 20:48:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Tuple<string, string> GetNugetKeyAndSource()
|
|
|
|
{
|
|
|
|
var apiKeyKey = string.Empty;
|
|
|
|
var sourceKey = string.Empty;
|
|
|
|
if (isRunningOnAppVeyor)
|
|
|
|
{
|
|
|
|
apiKeyKey = "NUGET_APIKEY";
|
|
|
|
sourceKey = "NUGET_SOURCE";
|
|
|
|
}
|
2017-04-24 00:05:44 +03:00
|
|
|
else
|
2017-04-23 20:48:55 +03:00
|
|
|
{
|
2017-04-23 23:34:49 +03:00
|
|
|
if (StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "develop"))
|
2017-04-23 20:48:55 +03:00
|
|
|
{
|
|
|
|
apiKeyKey = "NUGET_APIKEY_DEVELOP";
|
|
|
|
sourceKey = "NUGET_SOURCE_DEVELOP";
|
|
|
|
}
|
2017-04-24 21:17:04 +03:00
|
|
|
else if (IsMasterOrReleases())
|
2017-04-23 20:48:55 +03:00
|
|
|
{
|
|
|
|
apiKeyKey = "NUGET_APIKEY_MASTER";
|
|
|
|
sourceKey = "NUGET_SOURCE_MASTER";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var apiKey = EnvironmentVariable(apiKeyKey);
|
|
|
|
if (string.IsNullOrEmpty(apiKey))
|
|
|
|
throw new Exception(string.Format("The {0} environment variable is not defined.", apiKeyKey));
|
|
|
|
|
|
|
|
var source = EnvironmentVariable(sourceKey);
|
|
|
|
if (string.IsNullOrEmpty(source))
|
|
|
|
throw new Exception(string.Format("The {0} environment variable is not defined.", sourceKey));
|
|
|
|
|
|
|
|
return Tuple.Create(apiKey, source);
|
2017-04-26 10:35:19 +03:00
|
|
|
}
|