Uno.MvvmCross/build.cake

318 строки
9.0 KiB
Plaintext
Исходник Обычный вид История

#tool nuget:?package=GitVersion.CommandLine
2017-08-15 23:04:47 +03:00
#tool nuget:?package=vswhere
#addin nuget:?package=Cake.Figlet
2018-01-31 23:04:47 +03:00
#addin nuget:?package=Cake.Incubator&version=1.7.1
#addin nuget:?package=Cake.Git&version=0.16.1
2017-12-12 22:54:57 +03:00
#addin nuget:?package=Polly
using Polly;
2017-01-19 22:18:02 +03:00
2018-04-02 15:35:05 +03:00
var solutionName = "MvvmCross";
var repoName = "mvvmcross/mvvmcross";
var sln = new FilePath("./" + solutionName + ".sln");
2018-01-31 23:04:47 +03:00
var outputDir = new DirectoryPath("./artifacts");
var nuspecDir = new DirectoryPath("./nuspec");
2017-01-19 22:18:02 +03:00
var target = Argument("target", "Default");
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
var configuration = Argument("configuration", "Release");
2018-03-14 21:53:05 +03:00
var verbosityArg = Argument("verbosity", "Minimal");
var verbosity = Verbosity.Minimal;
2017-01-19 22:18:02 +03:00
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
GitVersion versionInfo = null;
Setup(context => {
versionInfo = context.GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.Json
});
2017-01-19 22:18:02 +03:00
if (isRunningOnAppVeyor)
{
var buildNumber = AppVeyor.Environment.Build.Number;
AppVeyor.UpdateBuildVersion(versionInfo.InformationalVersion
+ "-" + buildNumber);
}
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();
2018-04-02 15:35:05 +03:00
Information(Figlet(solutionName));
Information("Building version {0}, ({1}, {2}) using version {3} of Cake.",
versionInfo.SemVer,
configuration,
target,
cakeVersion);
Debug("Will push NuGet packages {0}",
ShouldPushNugetPackages(versionInfo.BranchName));
2018-03-14 21:53:05 +03:00
verbosity = (Verbosity) Enum.Parse(typeof(Verbosity), verbosityArg, true);
2017-01-19 22:18:02 +03:00
});
Task("Clean").Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
CleanDirectories(outputDir.FullPath);
EnsureDirectoryExists(outputDir);
});
FilePath msBuildPath;
Task("ResolveBuildTools")
2018-01-16 00:18:44 +03:00
.WithCriteria(() => IsRunningOnWindows())
.Does(() =>
{
var vsLatest = VSWhereLatest();
msBuildPath = (vsLatest == null)
? null
: vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
});
Task("Restore")
.IsDependentOn("ResolveBuildTools")
2018-03-16 10:10:08 +03:00
.Does(() =>
{
var settings = GetDefaultBuildSettings()
.WithTarget("Restore");
MSBuild(sln, settings);
2017-01-19 22:18:02 +03:00
});
Task("PatchBuildProps")
.Does(() =>
{
var buildProp = new FilePath("./Directory.build.props");
XmlPoke(buildProp, "//Project/PropertyGroup/Version", versionInfo.SemVer);
});
2017-01-19 22:18:02 +03:00
Task("Build")
.IsDependentOn("ResolveBuildTools")
.IsDependentOn("Clean")
.IsDependentOn("PatchBuildProps")
.IsDependentOn("Restore")
.Does(() => {
2018-03-16 10:10:08 +03:00
var settings = GetDefaultBuildSettings()
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
.WithProperty("DebugSymbols", "True")
.WithProperty("DebugType", "Embedded")
.WithProperty("Version", versionInfo.SemVer)
.WithProperty("PackageVersion", versionInfo.SemVer)
.WithProperty("InformationalVersion", versionInfo.InformationalVersion)
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
.WithProperty("NoPackageAnalysis", "True");
MSBuild(sln, settings);
2017-01-19 22:18:02 +03:00
});
Task("UnitTest")
.IsDependentOn("Build")
.Does(() =>
{
2018-01-31 23:04:47 +03:00
EnsureDirectoryExists(outputDir + "/Tests/");
var testPaths = GetFiles("./UnitTests/*.UnitTest/*.UnitTest.csproj");
2018-01-31 23:26:48 +03:00
var testsFailed = false;
2018-01-31 23:04:47 +03:00
foreach(var project in testPaths)
2018-01-30 23:59:55 +03:00
{
2018-01-31 23:04:47 +03:00
var projectName = project.GetFilenameWithoutExtension();
var testXml = new FilePath(outputDir + "/Tests/" + projectName + ".xml").MakeAbsolute(Context.Environment);
try
{
DotNetCoreTool(project,
"xunit", "-fxversion 2.0.0 --no-build -parallel none -configuration " +
configuration + " -xml \"" + testXml.FullPath + "\"");
}
catch
{
2018-01-31 23:26:48 +03:00
testsFailed = true;
2018-01-31 23:04:47 +03:00
}
}
if (isRunningOnAppVeyor)
{
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
foreach(var testResult in GetFiles(outputDir + "/Tests/*.xml"))
2018-01-30 23:59:55 +03:00
AppVeyor.UploadTestResults(testResult, AppVeyorTestResultsType.XUnit);
}
2018-01-31 23:26:48 +03:00
if (testsFailed)
throw new Exception("Tests failed :(");
2017-01-19 22:18:02 +03:00
});
Task("PublishPackages")
.WithCriteria(() => !BuildSystem.IsLocalBuild)
2018-04-02 15:35:05 +03:00
.WithCriteria(() => IsRepository(repoName))
.WithCriteria(() => ShouldPushNugetPackages(versionInfo.BranchName))
.Does (() =>
{
// Resolve the API key.
var nugetKeySource = GetNugetKeyAndSource();
var apiKey = nugetKeySource.Item1;
var source = nugetKeySource.Item2;
2018-04-02 15:35:05 +03:00
var nugetFiles = GetFiles(solutionName + "*/**/bin/" + configuration + "/**/*.nupkg");
2017-12-12 22:54:57 +03:00
var policy = Policy
.Handle<Exception>()
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
.WaitAndRetry(5, retryAttempt =>
TimeSpan.FromSeconds(Math.Pow(1.5, retryAttempt)));
2017-12-12 22:54:57 +03:00
foreach(var nugetFile in nugetFiles)
{
2017-12-12 22:54:57 +03:00
policy.Execute(() =>
NuGetPush(nugetFile, new NuGetPushSettings {
Source = source,
ApiKey = apiKey
})
);
}
});
2017-06-19 10:50:28 +03:00
Task("UploadAppVeyorArtifact")
.WithCriteria(() => isRunningOnAppVeyor)
2018-03-16 10:10:08 +03:00
.Does(() =>
{
2017-06-19 10:50:28 +03:00
Information("Artifacts Dir: {0}", outputDir.FullPath);
2017-06-19 10:50:28 +03:00
2017-12-12 23:07:20 +03:00
var uploadSettings = new AppVeyorUploadArtifactsSettings();
2018-04-02 15:35:05 +03:00
var artifacts = GetFiles(solutionName + "*/**/bin/" + configuration + "/**/*.nupkg")
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
+ GetFiles(outputDir.FullPath + "/**/*");
foreach(var file in artifacts) {
Information("Uploading {0}", file.FullPath);
2017-12-12 23:07:20 +03:00
if (file.GetExtension().Contains("nupkg"))
2017-12-12 23:07:20 +03:00
uploadSettings.ArtifactType = AppVeyorUploadArtifactType.NuGetPackage;
else
uploadSettings.ArtifactType = AppVeyorUploadArtifactType.Auto;
AppVeyor.UploadArtifact(file.FullPath, uploadSettings);
}
2017-06-19 10:50:28 +03:00
});
2017-01-19 22:18:02 +03:00
Task("Default")
Update to .NET Standard (#2530) * Move Android support and plugins to new directories * Add new solution file and directory config * Update Android support to sdk style * Remove packages.config from android support * Add new csproj for MvvmCross main project * Add csproj for all projects * Move binding to new folders * Move wpf to its own folder * Move console into its own platform * Move test project into the correct folder * Move platform projects * Move Forms into the right folder * Move code analysis to new folder * Fix some issue's with code in netstandard * Moving files for Accelerometer * Moving files for Plugins - All * Moving files for plugins - Color * Moving files for plugins - Downloadcache * Moving files for plugins - Email * Moving files for plugins - FieldBindings * Moving files for plugins - File * Moving files for plugins - Json * Moving files for plugins - JsonLocalization * Moving files for plugins - Location * Removing Location Fused legacy project * Moving files for plugins - Messenger * Moving files for plugins - MethodBinding * Moving files for plugins - Network * Moving files for plugins - PhoneCall * Moving files for plugins - Resource Loader * Moving files for plugins - ResxLocalization * Moving files for plugins - PictureChooser * Moving files for plugins - Share * Moving files for plugins - Visibility * Moving files for plugins - WebBrowser * Revert "Removing Location Fused legacy project" This reverts commit 9b8b6c96c96bea4537661a30e950a3edb0c35a8e. * Moving Fused location to correct plugin folder * Move ios support into plugin * Fix the uwp version * Remove double binding files * Fixing Android attributes * Fixing Android resources naming * Fixing Forms project * Update build script * Add missing using * Cleanup some dependencies * Fix the android location of plugins * Update dependencies * Remove reference to Microsoft.CSharp * Add CSharp back to main library * Remove MSBuild AndroidResgen stuff, it is handled by MSBuildSDKExtras * Remove Preserve Attribute from Plugins.All * Added PreserveAttribute to Core * Remove checked in tools * Move PreserveAttribute to MvvmCross.Platform namespace * Switch to MvvmCross.Platform.PreserveAttribute * Don't check in Resources.Designer files * Prevent the compiler complaining about duplicate Resource.Designer.cs files * Fix test dll locations * Add NUnitTestAdapter and Test.SDK * NUnit Console Runner does not work with netcoreapp2.0 (dotnet-cli does) * Update gitignore * Added configuration argument * Use InformationalVersion for AppVeyor build * Add version property to build settings * Upload artifacts on PR's too * Squelch warnings about SemVer 2.0
2018-01-15 23:49:39 +03:00
.IsDependentOn("Build")
2018-01-30 23:59:55 +03:00
.IsDependentOn("UnitTest")
.IsDependentOn("PublishPackages")
.IsDependentOn("UploadAppVeyorArtifact")
.Does(() =>
{
});
2017-01-19 22:18:02 +03:00
RunTarget(target);
2018-03-16 10:10:08 +03:00
MSBuildSettings GetDefaultBuildSettings()
{
var settings = new MSBuildSettings
{
Configuration = configuration,
ToolPath = msBuildPath,
Verbosity = verbosity,
ArgumentCustomization = args => args.Append("/m")
};
return settings;
}
bool ShouldPushNugetPackages(string branchName)
{
if (StringComparer.OrdinalIgnoreCase.Equals(branchName, "develop"))
return true;
return IsMasterOrReleases(branchName) && IsTagged().Item1;
}
bool IsMasterOrReleases(string branchName)
{
2018-02-12 13:35:05 +03:00
if (StringComparer.OrdinalIgnoreCase.Equals(branchName, "master"))
return true;
2018-02-12 13:35:05 +03:00
if (branchName.StartsWith("release/", StringComparison.OrdinalIgnoreCase) ||
branchName.StartsWith("releases/", StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
bool IsRepository(string repoName)
{
if (isRunningOnAppVeyor)
{
var buildEnvRepoName = AppVeyor.Environment.Repository.Name;
Information("Checking repo name: {0} against build repo name: {1}", repoName, buildEnvRepoName);
return StringComparer.OrdinalIgnoreCase.Equals(repoName, buildEnvRepoName);
}
else
{
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;
}
}
}
Tuple<bool, string> IsTagged()
{
var path = MakeAbsolute(sln).GetDirectory().FullPath;
using (var repo = new LibGit2Sharp.Repository(path))
{
var head = repo.Head;
var headSha = head.Tip.Sha;
var tag = repo.Tags.FirstOrDefault(t => t.Target.Sha == headSha);
if (tag == null)
{
Debug("HEAD is not tagged");
return Tuple.Create<bool, string>(false, null);
}
Debug("HEAD is tagged: {0}", tag.FriendlyName);
return Tuple.Create<bool, string>(true, tag.FriendlyName);
}
}
Tuple<string, string> GetNugetKeyAndSource()
{
var apiKeyKey = string.Empty;
var sourceKey = string.Empty;
if (isRunningOnAppVeyor)
{
apiKeyKey = "NUGET_APIKEY";
sourceKey = "NUGET_SOURCE";
}
else
{
if (StringComparer.OrdinalIgnoreCase.Equals(versionInfo.BranchName, "develop"))
{
apiKeyKey = "NUGET_APIKEY_DEVELOP";
sourceKey = "NUGET_SOURCE_DEVELOP";
}
else if (IsMasterOrReleases(versionInfo.BranchName))
{
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
}