2017-04-15 16:42:24 +03:00
|
|
|
#tool nuget:?package=GitVersion.CommandLine
|
|
|
|
#tool nuget:?package=gitlink
|
|
|
|
#tool nuget:?package=vswhere
|
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-04-23 20:48:55 +03:00
|
|
|
var isRunningOnVSTS = TFBuild.IsRunningOnVSTS;
|
2017-01-22 18:39:32 +03:00
|
|
|
|
2017-01-19 22:18:02 +03:00
|
|
|
Task("Clean").Does(() =>
|
|
|
|
{
|
|
|
|
CleanDirectories("./**/bin");
|
|
|
|
CleanDirectories("./**/obj");
|
|
|
|
CleanDirectories(outputDir.FullPath);
|
|
|
|
});
|
|
|
|
|
|
|
|
GitVersion versionInfo = null;
|
|
|
|
Task("Version").Does(() => {
|
|
|
|
GitVersion(new GitVersionSettings {
|
|
|
|
UpdateAssemblyInfo = true,
|
|
|
|
OutputType = GitVersionOutput.BuildServer
|
|
|
|
});
|
|
|
|
|
|
|
|
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
|
|
|
|
Information("VI:\t{0}", versionInfo.FullSemVer);
|
|
|
|
});
|
|
|
|
|
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-01-20 01:42:33 +03:00
|
|
|
Task("GitLink")
|
2017-01-19 22:18:02 +03:00
|
|
|
.IsDependentOn("Build")
|
2017-01-20 01:42:33 +03:00
|
|
|
//pdbstr.exe and costura are not xplat currently
|
|
|
|
.WithCriteria(() => IsRunningOnWindows())
|
|
|
|
.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",
|
|
|
|
"playground.ios"
|
|
|
|
};
|
|
|
|
|
2017-01-20 01:42:33 +03:00
|
|
|
GitLink(sln.GetDirectory(),
|
|
|
|
new GitLinkSettings {
|
2017-01-21 11:42:15 +03:00
|
|
|
RepositoryUrl = "https://github.com/mvvmcross/mvvmcross",
|
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")
|
|
|
|
.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.V4.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V7.AppCompat.nuspec",
|
|
|
|
"MvvmCross.Droid.Support.V7.Fragging.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",
|
|
|
|
"MvvmCross.Forms.Presenter.nuspec",
|
|
|
|
"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"))
|
|
|
|
.WithCriteria(() => versionInfo.BranchName == "master" || versionInfo.BranchName == "develop")
|
2017-01-22 18:39:32 +03:00
|
|
|
.Does (() =>
|
|
|
|
{
|
2017-04-23 21:58:54 +03:00
|
|
|
if (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 21:58:54 +03:00
|
|
|
.Does(() => { });
|
2017-01-19 22:18:02 +03:00
|
|
|
|
|
|
|
RunTarget(target);
|
2017-04-23 20:48:55 +03:00
|
|
|
|
|
|
|
bool IsRepository(string repoName)
|
|
|
|
{
|
2017-04-23 21:18:32 +03:00
|
|
|
var buildEnvRepoName = string.Empty;
|
|
|
|
|
2017-04-23 20:48:55 +03:00
|
|
|
if (isRunningOnAppVeyor)
|
2017-04-23 21:18:32 +03:00
|
|
|
buildEnvRepoName = AppVeyor.Environment.Repository.Name;
|
|
|
|
|
|
|
|
Information(string.Format("Checking repo name: {0} against build repo name: {1}", repoName, buildEnvRepoName));
|
2017-04-23 20:48:55 +03:00
|
|
|
|
2017-04-23 21:58:54 +03:00
|
|
|
// repo name on VSTS is empty :(
|
|
|
|
if (isRunningOnVSTS) return true;
|
|
|
|
|
|
|
|
return StringComparer.OrdinalIgnoreCase.Equals(repoName, buildEnvRepoName);
|
2017-04-23 20:48:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsTagged()
|
|
|
|
{
|
2017-04-23 21:18:32 +03:00
|
|
|
var toReturn = false;
|
2017-04-23 20:48:55 +03:00
|
|
|
int commitsSinceTag = -1;
|
|
|
|
if (int.TryParse(versionInfo.CommitsSinceVersionSource, out commitsSinceTag))
|
|
|
|
{
|
|
|
|
// if tag is current commit this will be 0
|
2017-04-23 21:18:32 +03:00
|
|
|
if (commitsSinceTag == 0)
|
|
|
|
toReturn = true;
|
2017-04-23 20:48:55 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 21:18:32 +03:00
|
|
|
Information(string.Format("Commits since tag {0}, is tagged: {1}", commitsSinceTag, toReturn));
|
|
|
|
|
|
|
|
return toReturn;
|
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";
|
|
|
|
}
|
|
|
|
else if (isRunningOnVSTS)
|
|
|
|
{
|
2017-04-23 21:58:54 +03:00
|
|
|
if (versionInfo.BranchName == "develop")
|
2017-04-23 20:48:55 +03:00
|
|
|
{
|
|
|
|
apiKeyKey = "NUGET_APIKEY_DEVELOP";
|
|
|
|
sourceKey = "NUGET_SOURCE_DEVELOP";
|
|
|
|
}
|
2017-04-23 21:58:54 +03:00
|
|
|
else if (versionInfo.BranchName == "master")
|
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);
|
|
|
|
}
|