First pass at separate cake files and use of GitVersion
This commit is contained in:
Родитель
2a1599d4a9
Коммит
8f7ecaa9e8
|
@ -0,0 +1,13 @@
|
|||
next-version: 3.9.0
|
||||
mode: ContinuousDelivery
|
||||
legacy-semver-padding: 5
|
||||
build-metadata-padding: 5
|
||||
commits-since-version-source-padding: 5
|
||||
branches:
|
||||
master:
|
||||
regex: ^main$
|
||||
tag: dev
|
||||
release:
|
||||
tag: pre
|
||||
pull-request:
|
||||
tag: pr
|
380
build.cake
380
build.cake
|
@ -1,148 +1,60 @@
|
|||
#tool nuget:?package=GitVersion.CommandLine&version=5.0.0
|
||||
#tool nuget:?package=NUnit.ConsoleRunner&version=3.11.1
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// PROJECT-SPECIFIC
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// When copying the script to support a different extension, the
|
||||
// main changes needed should be in this section.
|
||||
|
||||
var SOLUTION_FILE = "nunit.v2.driver.sln";
|
||||
var UNIT_TEST_ASSEMBLY = "nunit.v2.driver.tests.dll";
|
||||
var INTEGRATION_TEST_ASSEMBLY = "v2-tests/v2-test-assembly.dll";
|
||||
var GITHUB_SITE = "https://github.com/nunit/nunit-v2-framework-driver";
|
||||
var WIKI_PAGE = "https://github.com/nunit/docs/wiki/Console-Command-Line";
|
||||
var NUGET_ID = "NUnit.Extension.NUnitV2Driver";
|
||||
var CHOCO_ID = "nunit-extension-nunit-v2-driver";
|
||||
var VERSION = "3.8.0";
|
||||
|
||||
// Metadata used in the nuget and chocolatey packages
|
||||
var TITLE = "NUnit 3 - NUnit V2 Framework Driver Extension";
|
||||
var AUTHORS = new [] { "Charlie Poole" };
|
||||
var OWNERS = new [] { "Charlie Poole" };
|
||||
var DESCRIPTION = "This extension allows NUnit to load and run tests compiled against earlier versions of the NUnit framework. Versions 2.0 through 2.7 are supported.";
|
||||
var SUMMARY = "NUnit Engine extension allowing execution of tests using NUnit 2.x.";
|
||||
var COPYRIGHT = "Copyright (c) 2014-2019 Charlie Poole";
|
||||
var RELEASE_NOTES = new [] { "See https://raw.githubusercontent.com/nunit/nunit-v2-framework-driver/main/CHANGES.txt" };
|
||||
var TAGS = new [] { "nunit", "test", "testing", "tdd", "runner" };
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ARGUMENTS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// NOTE: These two constants are set here because constants.cake
|
||||
// isn't loaded until after the arguments are parsed.
|
||||
//
|
||||
// Since GitVersion is only used when running under
|
||||
// Windows, the default version should be updated to the
|
||||
// next version after each release.
|
||||
const string DEFAULT_VERSION = "3.9.0";
|
||||
const string DEFAULT_CONFIGURATION = "Release";
|
||||
|
||||
var target = Argument("target", "Default");
|
||||
var configuration = Argument("configuration", "Debug");
|
||||
|
||||
// Special (optional) arguments for the script. You pass these
|
||||
// through the Cake bootscrap script via the -ScriptArgs argument
|
||||
// for example:
|
||||
// ./build.ps1 -t RePackageNuget -ScriptArgs --nugetVersion="3.9.9"
|
||||
// ./build.ps1 -t RePackageNuget -ScriptArgs '--binaries="rel3.9.9" --nugetVersion="3.9.9"'
|
||||
var nugetVersion = Argument("nugetVersion", (string)null);
|
||||
var chocoVersion = Argument("chocoVersion", (string)null);
|
||||
var binaries = Argument("binaries", (string)null);
|
||||
// Load additional cake files here since some of them
|
||||
// depend on the arguments provided.
|
||||
#load cake/parameters.cake
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SET PACKAGE VERSION
|
||||
// SETUP AND TEARDOWN
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
var dbgSuffix = configuration == "Debug" ? "-dbg" : "";
|
||||
var packageVersion = VERSION + dbgSuffix;
|
||||
|
||||
if (BuildSystem.IsRunningOnAppVeyor)
|
||||
Setup<BuildParameters>((context) =>
|
||||
{
|
||||
var tag = AppVeyor.Environment.Repository.Tag;
|
||||
var parameters = BuildParameters.Create(context);
|
||||
|
||||
if (tag.IsTag)
|
||||
{
|
||||
packageVersion = tag.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildNumber = AppVeyor.Environment.Build.Number.ToString("00000");
|
||||
var branch = AppVeyor.Environment.Repository.Branch;
|
||||
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
|
||||
if (BuildSystem.IsRunningOnAppVeyor)
|
||||
AppVeyor.UpdateBuildVersion(parameters.PackageVersion + "-" + AppVeyor.Environment.Build.Number);
|
||||
|
||||
if (branch == "main" && !isPullRequest)
|
||||
{
|
||||
packageVersion = VERSION + "-dev-" + buildNumber + dbgSuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
var suffix = "-ci-" + buildNumber + dbgSuffix;
|
||||
Information("Building {0} version {1} of NUnit Project Loader.", parameters.Configuration, parameters.PackageVersion);
|
||||
|
||||
if (isPullRequest)
|
||||
suffix += "-pr-" + AppVeyor.Environment.PullRequest.Number;
|
||||
else
|
||||
suffix += "-" + branch;
|
||||
|
||||
// Nuget limits "special version part" to 20 chars. Add one for the hyphen.
|
||||
if (suffix.Length > 21)
|
||||
suffix = suffix.Substring(0, 21);
|
||||
|
||||
suffix = suffix.Replace(".", "");
|
||||
|
||||
packageVersion = VERSION + suffix;
|
||||
}
|
||||
}
|
||||
|
||||
AppVeyor.UpdateBuildVersion(packageVersion);
|
||||
}
|
||||
|
||||
Teardown(context =>
|
||||
{
|
||||
// Make sure we don't leave a test extension installed
|
||||
ClearDriverExtensions();
|
||||
return parameters;
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// DEFINE RUN CONSTANTS
|
||||
// DUMP SETTINGS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Directories
|
||||
var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/";
|
||||
var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/";
|
||||
var BIN_SRC = BIN_DIR; // Source of binaries used in packaging
|
||||
var OUTPUT_DIR = PROJECT_DIR + "output/";
|
||||
var TOOLS_DIR = PROJECT_DIR + "tools/";
|
||||
|
||||
// Console Runner
|
||||
var CONSOLE_EXE = TOOLS_DIR + "NUnit.ConsoleRunner/tools/nunit3-console.exe";
|
||||
|
||||
// Packages
|
||||
var NUGET_PACKAGE_NAME = NUGET_ID + "." + VERSION + ".nupkg";
|
||||
var CHOCO_PACKAGE_NAME = CHOCO_ID + "." + VERSION + ".nupkg";
|
||||
var NUGET_PACKAGE = OUTPUT_DIR + NUGET_PACKAGE_NAME;
|
||||
var CHOCO_PACKAGE = OUTPUT_DIR + CHOCO_PACKAGE_NAME;
|
||||
|
||||
// Adjust BIN_SRC if --binaries option was given
|
||||
if (binaries != null)
|
||||
{
|
||||
BIN_SRC = binaries;
|
||||
if (!System.IO.Path.IsPathRooted(binaries))
|
||||
Task("DumpSettings")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
BIN_SRC = PROJECT_DIR + binaries;
|
||||
if (!BIN_SRC.EndsWith("/"))
|
||||
BIN_SRC += "/";
|
||||
}
|
||||
}
|
||||
|
||||
// Package sources for nuget restore
|
||||
var PACKAGE_SOURCE = new string[]
|
||||
{
|
||||
"https://www.nuget.org/api/v2",
|
||||
"https://www.myget.org/F/nunit/api/v2"
|
||||
};
|
||||
parameters.DumpSettings();
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CLEAN
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task("Clean")
|
||||
.Does(() =>
|
||||
{
|
||||
CleanDirectory(BIN_DIR);
|
||||
});
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
CleanDirectory(parameters.OutputDirectory);
|
||||
});
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -151,12 +63,12 @@ Task("Clean")
|
|||
|
||||
Task("NuGetRestore")
|
||||
.Does(() =>
|
||||
{
|
||||
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings()
|
||||
{
|
||||
Source = PACKAGE_SOURCE
|
||||
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings()
|
||||
{
|
||||
Source = PACKAGE_SOURCES
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BUILD
|
||||
|
@ -164,15 +76,12 @@ Task("NuGetRestore")
|
|||
|
||||
Task("Build")
|
||||
.IsDependentOn("NuGetRestore")
|
||||
.Does(() =>
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
if (binaries != null)
|
||||
throw new Exception("The --binaries option may only be specified when re-packaging an existing build.");
|
||||
|
||||
if(IsRunningOnWindows())
|
||||
{
|
||||
MSBuild(SOLUTION_FILE, new MSBuildSettings()
|
||||
.SetConfiguration(configuration)
|
||||
.SetConfiguration(parameters.Configuration)
|
||||
.SetMSBuildPlatform(MSBuildPlatform.Automatic)
|
||||
.SetVerbosity(Verbosity.Minimal)
|
||||
.SetNodeReuse(false)
|
||||
|
@ -183,7 +92,7 @@ Task("Build")
|
|||
{
|
||||
XBuild(SOLUTION_FILE, new XBuildSettings()
|
||||
.WithTarget("Build")
|
||||
.WithProperty("Configuration", configuration)
|
||||
.WithProperty("Configuration", parameters.Configuration)
|
||||
.SetVerbosity(Verbosity.Minimal)
|
||||
);
|
||||
}
|
||||
|
@ -195,183 +104,101 @@ Task("Build")
|
|||
|
||||
Task("Test")
|
||||
.IsDependentOn("Build")
|
||||
.Does(() =>
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
NUnit3(BIN_DIR + UNIT_TEST_ASSEMBLY);
|
||||
NUnit3(parameters.OutputDirectory + UNIT_TEST_ASSEMBLY);
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// PACKAGE
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Additional package metadata
|
||||
var PROJECT_URL = new Uri("http://nunit.org");
|
||||
var ICON_URL = new Uri("https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png");
|
||||
var LICENSE_URL = new Uri("http://nunit.org/nuget/nunit3-license.txt");
|
||||
var PROJECT_SOURCE_URL = new Uri( GITHUB_SITE );
|
||||
var PACKAGE_SOURCE_URL = new Uri( GITHUB_SITE );
|
||||
var BUG_TRACKER_URL = new Uri(GITHUB_SITE + "/issues");
|
||||
var DOCS_URL = new Uri(WIKI_PAGE);
|
||||
var MAILING_LIST_URL = new Uri("https://groups.google.com/forum/#!forum/nunit-discuss");
|
||||
|
||||
Task("RePackageNuGet")
|
||||
.Does(() =>
|
||||
Task("BuildNuGetPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
CreateDirectory(OUTPUT_DIR);
|
||||
CreateDirectory(parameters.PackageDirectory);
|
||||
|
||||
NuGetPack(
|
||||
new NuGetPackSettings()
|
||||
{
|
||||
Id = NUGET_ID,
|
||||
Version = nugetVersion ?? packageVersion,
|
||||
Title = TITLE,
|
||||
Authors = AUTHORS,
|
||||
Owners = OWNERS,
|
||||
Description = DESCRIPTION,
|
||||
Summary = SUMMARY,
|
||||
ProjectUrl = PROJECT_URL,
|
||||
IconUrl = ICON_URL,
|
||||
LicenseUrl = LICENSE_URL,
|
||||
RequireLicenseAcceptance = false,
|
||||
Copyright = COPYRIGHT,
|
||||
ReleaseNotes = RELEASE_NOTES,
|
||||
Tags = TAGS,
|
||||
//Language = "en-US",
|
||||
OutputDirectory = OUTPUT_DIR,
|
||||
Repository = new NuGetRepository {
|
||||
Type = "git",
|
||||
Url = GITHUB_SITE
|
||||
},
|
||||
Files = new [] {
|
||||
new NuSpecContent { Source = PROJECT_DIR + "LICENSE.txt" },
|
||||
new NuSpecContent { Source = PROJECT_DIR + "CHANGES.txt" },
|
||||
new NuSpecContent { Source = PROJECT_DIR + "nunit.v2.driver.addins", Target = "tools" },
|
||||
new NuSpecContent { Source = BIN_SRC + "nunit.v2.driver.dll", Target = "tools" },
|
||||
new NuSpecContent { Source = BIN_SRC + "nunit.core.dll", Target = "tools" },
|
||||
new NuSpecContent { Source = BIN_SRC + "nunit.core.interfaces.dll", Target = "tools" }
|
||||
}
|
||||
});
|
||||
BuildNuGetPackage(parameters);
|
||||
});
|
||||
|
||||
Task("RePackageChocolatey")
|
||||
.Does(() =>
|
||||
Task("InstallNuGetPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
CreateDirectory(OUTPUT_DIR);
|
||||
// Ensure we aren't inadvertently using the chocolatey install
|
||||
if (DirectoryExists(parameters.ChocolateyInstallDirectory))
|
||||
DeleteDirectory(parameters.ChocolateyInstallDirectory, new DeleteDirectorySettings() { Recursive = true });
|
||||
|
||||
ChocolateyPack(
|
||||
new ChocolateyPackSettings()
|
||||
{
|
||||
Id = CHOCO_ID,
|
||||
Version = chocoVersion ?? packageVersion,
|
||||
Title = TITLE,
|
||||
Authors = AUTHORS,
|
||||
Owners = OWNERS,
|
||||
Description = DESCRIPTION,
|
||||
Summary = SUMMARY,
|
||||
ProjectUrl = PROJECT_URL,
|
||||
IconUrl = ICON_URL,
|
||||
LicenseUrl = LICENSE_URL,
|
||||
RequireLicenseAcceptance = false,
|
||||
Copyright = COPYRIGHT,
|
||||
ProjectSourceUrl = PROJECT_SOURCE_URL,
|
||||
DocsUrl= DOCS_URL,
|
||||
BugTrackerUrl = BUG_TRACKER_URL,
|
||||
PackageSourceUrl = PACKAGE_SOURCE_URL,
|
||||
MailingListUrl = MAILING_LIST_URL,
|
||||
ReleaseNotes = RELEASE_NOTES,
|
||||
Tags = TAGS,
|
||||
//Language = "en-US",
|
||||
OutputDirectory = OUTPUT_DIR,
|
||||
Files = new [] {
|
||||
new ChocolateyNuSpecContent { Source = PROJECT_DIR + "LICENSE.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = PROJECT_DIR + "CHANGES.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = PROJECT_DIR + "VERIFICATION.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = PROJECT_DIR + "nunit.v2.driver.addins", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = BIN_SRC + "nunit.v2.driver.dll", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = BIN_SRC + "nunit.core.dll", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = BIN_SRC + "nunit.core.interfaces.dll", Target = "tools" }
|
||||
}
|
||||
});
|
||||
CleanDirectory(parameters.NuGetInstallDirectory);
|
||||
Unzip(parameters.NuGetPackage, parameters.NuGetInstallDirectory);
|
||||
|
||||
Information($"Unzipped {parameters.NuGetPackageName} to { parameters.NuGetInstallDirectory}");
|
||||
});
|
||||
|
||||
Task("TestNuGetPackage")
|
||||
.IsDependentOn("InstallNuGetPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
NUnit3(parameters.OutputDirectory + INTEGRATION_TEST_ASSEMBLY);
|
||||
});
|
||||
|
||||
Task("BuildChocolateyPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
CreateDirectory(parameters.PackageDirectory);
|
||||
|
||||
BuildChocolateyPackage(parameters);
|
||||
});
|
||||
|
||||
Task("InstallChocolateyPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
// Ensure we aren't inadvertently using the nuget install
|
||||
if (DirectoryExists(parameters.NuGetInstallDirectory))
|
||||
DeleteDirectory(parameters.NuGetInstallDirectory, new DeleteDirectorySettings() { Recursive = true });
|
||||
|
||||
CleanDirectory(parameters.ChocolateyInstallDirectory);
|
||||
Unzip(parameters.ChocolateyPackage, parameters.ChocolateyInstallDirectory);
|
||||
|
||||
Information($"Unzipped {parameters.ChocolateyPackageName} to { parameters.ChocolateyInstallDirectory}");
|
||||
});
|
||||
|
||||
Task("TestChocolateyPackage")
|
||||
.IsDependentOn("InstallChocolateyPackage")
|
||||
.Does<BuildParameters>((parameters) =>
|
||||
{
|
||||
// We are using nuget packages for the runner, so add an extra
|
||||
// addins file to allow detecting chocolatey packages
|
||||
string runnerDir = parameters.ToolsDirectory + "NUnit.ConsoleRunner.3.11.1/tools";
|
||||
using (var writer = new StreamWriter(runnerDir + "/choco.engine.addins"))
|
||||
writer.WriteLine("../../nunit-extension-*/tools/");
|
||||
|
||||
NUnit3(parameters.OutputDirectory + INTEGRATION_TEST_ASSEMBLY);
|
||||
});
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// PACKAGE TESTS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task("TestNuGetPackage")
|
||||
.IsDependentOn("RePackageNuGet")
|
||||
.Does(() =>
|
||||
{
|
||||
RunPackageTests(NUGET_ID);
|
||||
});
|
||||
|
||||
Task("TestChocolateyPackage")
|
||||
.IsDependentOn("RePackageChocolatey")
|
||||
.Does(() =>
|
||||
{
|
||||
RunPackageTests(CHOCO_ID);
|
||||
});
|
||||
|
||||
private void RunPackageTests(string packageId)
|
||||
private void RunPackageTests(BuildParameters parameters, string packageId)
|
||||
{
|
||||
InstallPackage(packageId);
|
||||
|
||||
NUnit3(BIN_DIR + INTEGRATION_TEST_ASSEMBLY);
|
||||
}
|
||||
|
||||
private void InstallPackage(string packageId)
|
||||
{
|
||||
ClearDriverExtensions();
|
||||
|
||||
NuGetInstall(packageId, new NuGetInstallSettings()
|
||||
{
|
||||
Source = new [] { OUTPUT_DIR },
|
||||
OutputDirectory = TOOLS_DIR
|
||||
});
|
||||
|
||||
// Our copy of NUnit3-console is looking for nuget extensions,
|
||||
// rather than the chocolatey-formatted version. We fake it
|
||||
// by treating the package as a nuget extension, installing
|
||||
// it and then renaming the directory. For simplicity, we do
|
||||
// the mmove for both package types.
|
||||
|
||||
MoveDirectory(TOOLS_DIR + packageId + "." + VERSION, TOOLS_DIR + NUGET_ID );
|
||||
}
|
||||
|
||||
// Remove all driver extensions, both nuget and chocolatey, so that we are
|
||||
// sure that we are testing the extension we want to test.
|
||||
private void ClearDriverExtensions()
|
||||
{
|
||||
// Delay in case a prior test run is holding open assemblies we want to delete
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
|
||||
var driverExtensionDirectories = GetDirectories(TOOLS_DIR + NUGET_ID + "*");
|
||||
driverExtensionDirectories.Add(GetDirectories(TOOLS_DIR + CHOCO_ID + "*"));
|
||||
DeleteDirectories(driverExtensionDirectories, new DeleteDirectorySettings()
|
||||
{
|
||||
Recursive = true
|
||||
});
|
||||
NUnit3(parameters.OutputDirectory + INTEGRATION_TEST_ASSEMBLY);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// TASK TARGETS
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Task("Rebuild")
|
||||
.IsDependentOn("Clean")
|
||||
.IsDependentOn("Build");
|
||||
|
||||
Task("Package")
|
||||
.IsDependentOn("Build")
|
||||
.IsDependentOn("RePackage");
|
||||
.IsDependentOn("PackageNuGet")
|
||||
.IsDependentOn("PackageChocolatey");
|
||||
|
||||
Task("RePackage")
|
||||
.IsDependentOn("RePackageNuGet")
|
||||
.IsDependentOn("RePackageChocolatey");
|
||||
Task("PackageNuGet")
|
||||
.IsDependentOn("BuildNuGetPackage")
|
||||
.IsDependentOn("TestNuGetPackage");
|
||||
|
||||
Task("TestPackages")
|
||||
.IsDependentOn("Package")
|
||||
.IsDependentOn("TestNuGetPackage")
|
||||
Task("PackageChocolatey")
|
||||
.IsDependentOn("BuildChocolateyPackage")
|
||||
.IsDependentOn("TestChocolateyPackage");
|
||||
|
||||
Task("Appveyor")
|
||||
|
@ -383,11 +210,10 @@ Task("Travis")
|
|||
.IsDependentOn("Build")
|
||||
.IsDependentOn("Test");
|
||||
|
||||
Task("All")
|
||||
Task("Full")
|
||||
.IsDependentOn("Build")
|
||||
.IsDependentOn("Test")
|
||||
.IsDependentOn("Package")
|
||||
.IsDependentOn("TestPackages");
|
||||
.IsDependentOn("Package");
|
||||
|
||||
Task("Default")
|
||||
.IsDependentOn("Build");
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
// This file contains both constants and static readonly values, which
|
||||
// are used as constants. The latter must not depend in any way on the
|
||||
// contents of other cake files, which are loaded after this one.
|
||||
|
||||
// Files
|
||||
const string SOLUTION_FILE = "nunit.v2.driver.sln";
|
||||
const string UNIT_TEST_ASSEMBLY = "nunit.v2.driver.tests.dll";
|
||||
const string INTEGRATION_TEST_ASSEMBLY = "v2-tests/v2-test-assembly.dll";
|
||||
|
||||
// Directories
|
||||
var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/";
|
||||
var OUTPUT_DIR = PROJECT_DIR + "output/";
|
||||
var TOOLS_DIR = PROJECT_DIR + "tools/";
|
||||
|
||||
// Console Runner
|
||||
var CONSOLE_EXE = TOOLS_DIR + "NUnit.ConsoleRunner/tools/nunit3-console.exe";
|
||||
|
||||
// Packaging
|
||||
const string NUGET_ID = "NUnit.Extension.NUnitV2Driver";
|
||||
const string CHOCO_ID = "nunit-extension-nunit-v2-driver";
|
||||
//const string GITHUB_SITE = "https://github.com/nunit/nunit-v2-framework-driver";
|
||||
//const string WIKI_PAGE = "https://github.com/nunit/docs/wiki/Console-Command-Line";
|
||||
var NUGET_PACKAGE_NAME = NUGET_ID + "." + DEFAULT_VERSION + ".nupkg";
|
||||
var CHOCO_PACKAGE_NAME = CHOCO_ID + "." + DEFAULT_VERSION + ".nupkg";
|
||||
var NUGET_PACKAGE = OUTPUT_DIR + NUGET_PACKAGE_NAME;
|
||||
var CHOCO_PACKAGE = OUTPUT_DIR + CHOCO_PACKAGE_NAME;
|
||||
|
||||
// Package sources for nuget restore
|
||||
static readonly string[] PACKAGE_SOURCES = new string[]
|
||||
{
|
||||
"https://www.nuget.org/api/v2",
|
||||
"https://www.myget.org/F/nunit/api/v2"
|
||||
};
|
||||
|
||||
// We don't support running tests built with .net core yet
|
||||
// var TEST_TARGET_FRAMEWORKS = TARGET_FRAMEWORKS
|
||||
var TEST_TARGET_FRAMEWORKS = new[] { "net20" };
|
||||
|
||||
// URLs for uploading packages
|
||||
private const string MYGET_PUSH_URL = "https://www.myget.org/F/nunit/api/v2";
|
||||
private const string NUGET_PUSH_URL = "https://api.nuget.org/v3/index.json";
|
||||
private const string CHOCO_PUSH_URL = "https://push.chocolatey.org/";
|
||||
|
||||
// Environment Variable names holding API keys
|
||||
private const string MYGET_API_KEY = "MYGET_API_KEY";
|
||||
private const string NUGET_API_KEY = "NUGET_API_KEY";
|
||||
private const string CHOCO_API_KEY = "CHOCO_API_KEY";
|
||||
|
||||
// Environment Variable names holding GitHub identity of user
|
||||
private const string GITHUB_OWNER = "NUnit";
|
||||
private const string GITHUB_REPO = "nunit-project-loader";
|
||||
// Access token is used by GitReleaseManager
|
||||
private const string GITHUB_ACCESS_TOKEN = "GITHUB_ACCESS_TOKEN";
|
||||
|
||||
// Pre-release labels that we publish
|
||||
private static readonly string[] LABELS_WE_PUBLISH_ON_MYGET = { "dev", "pre" };
|
||||
private static readonly string[] LABELS_WE_PUBLISH_ON_NUGET = { "alpha", "beta", "rc" };
|
||||
private static readonly string[] LABELS_WE_PUBLISH_ON_CHOCOLATEY = { "alpha", "beta", "rc" };
|
||||
private static readonly string[] LABELS_WE_RELEASE_ON_GITHUB = { "alpha", "beta", "rc" };
|
|
@ -0,0 +1,125 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// PACKAGE METADATA
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const string TITLE = "NUnit 3 - NUnit V2 Framework Driver Extension";
|
||||
static readonly string[] AUTHORS = new[] { "Charlie Poole" };
|
||||
static readonly string[] OWNERS = new[] { "Charlie Poole" };
|
||||
const string DESCRIPTION = "This extension allows NUnit to load and run tests compiled against earlier versions of the NUnit framework. Versions 2.0 through 2.7 are supported.";
|
||||
const string SUMMARY = "NUnit Engine extension allowing execution of tests using NUnit 2.x.";
|
||||
const string COPYRIGHT = "Copyright (c) 2014-2019 Charlie Poole";
|
||||
static readonly string[] RELEASE_NOTES = new[] { "See https://raw.githubusercontent.com/nunit/nunit-v2-framework-driver/main/CHANGES.txt" };
|
||||
static readonly string[] TAGS = new[] { "nunit", "test", "testing", "tdd", "runner" };
|
||||
static readonly Uri PROJECT_URL = new Uri("http://nunit.org");
|
||||
static readonly Uri ICON_URL = new Uri("https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png");
|
||||
static readonly Uri LICENSE_URL = new Uri("http://nunit.org/nuget/nunit3-license.txt");
|
||||
static readonly Uri PROJECT_SOURCE_URL = new Uri(GITHUB_SITE);
|
||||
static readonly Uri PACKAGE_SOURCE_URL = new Uri(GITHUB_SITE);
|
||||
static readonly Uri BUG_TRACKER_URL = new Uri(GITHUB_SITE + "/issues");
|
||||
static readonly Uri DOCS_URL = new Uri(WIKI_PAGE);
|
||||
static readonly Uri MAILING_LIST_URL = new Uri("https://groups.google.com/forum/#!forum/nunit-discuss");
|
||||
|
||||
const string GITHUB_SITE = "https://github.com/nunit/nunit-v2-result-writer";
|
||||
const string WIKI_PAGE = "https://github.com/nunit/docs/wiki/Console-Command-Line";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BUILD NUGET PACKAGE
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void BuildNuGetPackage(BuildParameters parameters)
|
||||
{
|
||||
NuGetPack(
|
||||
new NuGetPackSettings()
|
||||
{
|
||||
Id = NUGET_ID,
|
||||
Version = parameters.PackageVersion,
|
||||
Title = TITLE,
|
||||
Authors = AUTHORS,
|
||||
Owners = OWNERS,
|
||||
Description = DESCRIPTION,
|
||||
Summary = SUMMARY,
|
||||
ProjectUrl = PROJECT_URL,
|
||||
IconUrl = ICON_URL,
|
||||
LicenseUrl = LICENSE_URL,
|
||||
RequireLicenseAcceptance = false,
|
||||
Copyright = COPYRIGHT,
|
||||
ReleaseNotes = RELEASE_NOTES,
|
||||
Tags = TAGS,
|
||||
//Language = "en-US",
|
||||
OutputDirectory = parameters.PackageDirectory,
|
||||
Repository = new NuGetRepository
|
||||
{
|
||||
Type = "git",
|
||||
Url = GITHUB_SITE
|
||||
},
|
||||
Files = new[] {
|
||||
new NuSpecContent { Source = parameters.ProjectDirectory + "LICENSE.txt" },
|
||||
new NuSpecContent { Source = parameters.ProjectDirectory + "CHANGES.txt" },
|
||||
new NuSpecContent { Source = parameters.ProjectDirectory + "nunit.v2.driver.addins", Target = "tools" },
|
||||
new NuSpecContent { Source = parameters.OutputDirectory + "nunit.v2.driver.dll", Target = "tools" },
|
||||
new NuSpecContent { Source = parameters.OutputDirectory + "nunit.core.dll", Target = "tools" },
|
||||
new NuSpecContent { Source = parameters.OutputDirectory + "nunit.core.interfaces.dll", Target = "tools" }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// BUILD CHOCOLATEY PACKAGE
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void BuildChocolateyPackage(BuildParameters parameters)
|
||||
{
|
||||
ChocolateyPack(
|
||||
new ChocolateyPackSettings()
|
||||
{
|
||||
Id = CHOCO_ID,
|
||||
Version = parameters.PackageVersion,
|
||||
Title = TITLE,
|
||||
Authors = AUTHORS,
|
||||
Owners = OWNERS,
|
||||
Description = DESCRIPTION,
|
||||
Summary = SUMMARY,
|
||||
ProjectUrl = PROJECT_URL,
|
||||
IconUrl = ICON_URL,
|
||||
LicenseUrl = LICENSE_URL,
|
||||
RequireLicenseAcceptance = false,
|
||||
Copyright = COPYRIGHT,
|
||||
ProjectSourceUrl = PROJECT_SOURCE_URL,
|
||||
DocsUrl = DOCS_URL,
|
||||
BugTrackerUrl = BUG_TRACKER_URL,
|
||||
PackageSourceUrl = PACKAGE_SOURCE_URL,
|
||||
MailingListUrl = MAILING_LIST_URL,
|
||||
ReleaseNotes = RELEASE_NOTES,
|
||||
Tags = TAGS,
|
||||
//Language = "en-US",
|
||||
OutputDirectory = parameters.PackageDirectory,
|
||||
Files = new[] {
|
||||
new ChocolateyNuSpecContent { Source = parameters.ProjectDirectory + "LICENSE.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.ProjectDirectory + "CHANGES.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.ProjectDirectory + "VERIFICATION.txt", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.ProjectDirectory + "nunit.v2.driver.addins", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.OutputDirectory + "nunit.v2.driver.dll", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.OutputDirectory + "nunit.core.dll", Target = "tools" },
|
||||
new ChocolateyNuSpecContent { Source = parameters.OutputDirectory + "nunit.core.interfaces.dll", Target = "tools" }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void PushNuGetPackage(FilePath package, string apiKey, string url)
|
||||
{
|
||||
CheckPackageExists(package);
|
||||
NuGetPush(package, new NuGetPushSettings() { ApiKey = apiKey, Source = url });
|
||||
}
|
||||
|
||||
private void PushChocolateyPackage(FilePath package, string apiKey, string url)
|
||||
{
|
||||
CheckPackageExists(package);
|
||||
ChocolateyPush(package, new ChocolateyPushSettings() { ApiKey = apiKey, Source = url });
|
||||
}
|
||||
|
||||
private void CheckPackageExists(FilePath package)
|
||||
{
|
||||
if (!FileExists(package))
|
||||
throw new InvalidOperationException(
|
||||
$"Package not found: {package.GetFilename()}.\nCode may have changed since package was last built.");
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
#load "./constants.cake"
|
||||
#load "./versioning.cake"
|
||||
#load "./packaging.cake"
|
||||
//#load "./package-checks.cake"
|
||||
//#load "./package-tests.cake"
|
||||
//#load "./test-results.cake"
|
||||
//#load "./test-reports.cake"
|
||||
|
||||
using System;
|
||||
|
||||
public class BuildParameters
|
||||
{
|
||||
private ISetupContext _context;
|
||||
private BuildSystem _buildSystem;
|
||||
|
||||
public static BuildParameters Create(ISetupContext context)
|
||||
{
|
||||
var parameters = new BuildParameters(context);
|
||||
parameters.Validate();
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private BuildParameters(ISetupContext context)
|
||||
{
|
||||
_context = context;
|
||||
_buildSystem = context.BuildSystem();
|
||||
|
||||
Target = _context.TargetTask.Name;
|
||||
TasksToExecute = _context.TasksToExecute.Select(t => t.Name);
|
||||
|
||||
ProjectDirectory = _context.Environment.WorkingDirectory.FullPath + "/";
|
||||
|
||||
Configuration = _context.Argument("configuration", DEFAULT_CONFIGURATION);
|
||||
|
||||
MyGetApiKey = _context.EnvironmentVariable(MYGET_API_KEY);
|
||||
NuGetApiKey = _context.EnvironmentVariable(NUGET_API_KEY);
|
||||
ChocolateyApiKey = _context.EnvironmentVariable(CHOCO_API_KEY);
|
||||
GitHubAccessToken = _context.EnvironmentVariable(GITHUB_ACCESS_TOKEN);
|
||||
|
||||
BuildVersion = new BuildVersion(context, this);
|
||||
}
|
||||
|
||||
public string Target { get; }
|
||||
public IEnumerable<string> TasksToExecute { get; }
|
||||
|
||||
public ICakeContext Context => _context;
|
||||
|
||||
public string Configuration { get; }
|
||||
|
||||
public BuildVersion BuildVersion { get; }
|
||||
public string PackageVersion => BuildVersion.PackageVersion;
|
||||
public string AssemblyVersion => BuildVersion.AssemblyVersion;
|
||||
public string AssemblyFileVersion => BuildVersion.AssemblyFileVersion;
|
||||
public string AssemblyInformationalVersion => BuildVersion.AssemblyInformationalVersion;
|
||||
|
||||
public int PackageTestLevel { get; }
|
||||
|
||||
public bool IsLocalBuild => _buildSystem.IsLocalBuild;
|
||||
public bool IsRunningOnUnix => _context.IsRunningOnUnix();
|
||||
public bool IsRunningOnWindows => _context.IsRunningOnWindows();
|
||||
public bool IsRunningOnAppVeyor => _buildSystem.AppVeyor.IsRunningOnAppVeyor;
|
||||
|
||||
public string ProjectDirectory { get; }
|
||||
public string OutputDirectory => ProjectDirectory + "bin/" + Configuration + "/";
|
||||
public string Net20OutputDirectory => OutputDirectory + "net20/";
|
||||
public string NetCore21OutputDirectory => OutputDirectory + "netcoreapp2.1/";
|
||||
public string PackageDirectory => ProjectDirectory + "output/";
|
||||
public string ToolsDirectory => ProjectDirectory + "tools/";
|
||||
public string NuGetInstallDirectory => ToolsDirectory + NUGET_ID + "/";
|
||||
public string ChocolateyInstallDirectory => ToolsDirectory + CHOCO_ID + "/";
|
||||
|
||||
public string NuGetPackageName => NUGET_ID + "." + PackageVersion + ".nupkg";
|
||||
public string ChocolateyPackageName => CHOCO_ID + "." + PackageVersion + ".nupkg";
|
||||
|
||||
public string NuGetPackage => PackageDirectory + NuGetPackageName;
|
||||
public string ChocolateyPackage => PackageDirectory + ChocolateyPackageName;
|
||||
|
||||
public string MyGetPushUrl => MYGET_PUSH_URL;
|
||||
public string NuGetPushUrl => NUGET_PUSH_URL;
|
||||
public string ChocolateyPushUrl => CHOCO_PUSH_URL;
|
||||
|
||||
public string MyGetApiKey { get; }
|
||||
public string NuGetApiKey { get; }
|
||||
public string ChocolateyApiKey { get; }
|
||||
public string GitHubAccessToken { get; }
|
||||
|
||||
public string BranchName => BuildVersion.BranchName;
|
||||
public bool IsReleaseBranch => BuildVersion.IsReleaseBranch;
|
||||
|
||||
public bool IsPreRelease => BuildVersion.IsPreRelease;
|
||||
public bool ShouldPublishToMyGet =>
|
||||
!IsPreRelease || LABELS_WE_PUBLISH_ON_MYGET.Contains(BuildVersion.PreReleaseLabel);
|
||||
public bool ShouldPublishToNuGet =>
|
||||
!IsPreRelease || LABELS_WE_PUBLISH_ON_NUGET.Contains(BuildVersion.PreReleaseLabel);
|
||||
public bool ShouldPublishToChocolatey =>
|
||||
!IsPreRelease || LABELS_WE_PUBLISH_ON_CHOCOLATEY.Contains(BuildVersion.PreReleaseLabel);
|
||||
public bool IsProductionRelease =>
|
||||
!IsPreRelease || LABELS_WE_RELEASE_ON_GITHUB.Contains(BuildVersion.PreReleaseLabel);
|
||||
|
||||
public string GetPathToConsoleRunner(string version)
|
||||
{
|
||||
return ToolsDirectory + "NUnit.ConsoleRunner." + version + "/tools/nunit3-console.exe";
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
var validationErrors = new List<string>();
|
||||
|
||||
if (TasksToExecute.Contains("PublishPackages"))
|
||||
{
|
||||
if (ShouldPublishToMyGet && string.IsNullOrEmpty(MyGetApiKey))
|
||||
validationErrors.Add("MyGet ApiKey was not set.");
|
||||
if (ShouldPublishToNuGet && string.IsNullOrEmpty(NuGetApiKey))
|
||||
validationErrors.Add("NuGet ApiKey was not set.");
|
||||
if (ShouldPublishToChocolatey && string.IsNullOrEmpty(ChocolateyApiKey))
|
||||
validationErrors.Add("Chocolatey ApiKey was not set.");
|
||||
}
|
||||
|
||||
if (TasksToExecute.Contains("CreateDraftRelease") && (IsReleaseBranch || IsProductionRelease))
|
||||
{
|
||||
if (string.IsNullOrEmpty(GitHubAccessToken))
|
||||
validationErrors.Add("GitHub Access Token was not set.");
|
||||
}
|
||||
|
||||
if (validationErrors.Count > 0)
|
||||
{
|
||||
DumpSettings();
|
||||
|
||||
var msg = new StringBuilder("Parameter validation failed! See settings above.\n\nErrors found:\n");
|
||||
foreach (var error in validationErrors)
|
||||
msg.AppendLine(" " + error);
|
||||
|
||||
throw new InvalidOperationException(msg.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void DumpSettings()
|
||||
{
|
||||
Console.WriteLine("\nTASKS");
|
||||
Console.WriteLine("Target: " + Target);
|
||||
Console.WriteLine("TasksToExecute: " + string.Join(", ", TasksToExecute));
|
||||
|
||||
Console.WriteLine("\nENVIRONMENT");
|
||||
Console.WriteLine("IsLocalBuild: " + IsLocalBuild);
|
||||
Console.WriteLine("IsRunningOnWindows: " + IsRunningOnWindows);
|
||||
Console.WriteLine("IsRunningOnUnix: " + IsRunningOnUnix);
|
||||
Console.WriteLine("IsRunningOnAppVeyor: " + IsRunningOnAppVeyor);
|
||||
|
||||
Console.WriteLine("\nVERSIONING");
|
||||
Console.WriteLine("PackageVersion: " + PackageVersion);
|
||||
Console.WriteLine("AssemblyVersion: " + AssemblyVersion);
|
||||
Console.WriteLine("AssemblyFileVersion: " + AssemblyFileVersion);
|
||||
Console.WriteLine("AssemblyInformationalVersion: " + AssemblyInformationalVersion);
|
||||
Console.WriteLine("SemVer: " + BuildVersion.SemVer);
|
||||
Console.WriteLine("IsPreRelease: " + BuildVersion.IsPreRelease);
|
||||
Console.WriteLine("PreReleaseLabel: " + BuildVersion.PreReleaseLabel);
|
||||
Console.WriteLine("PreReleaseSuffix: " + BuildVersion.PreReleaseSuffix);
|
||||
|
||||
Console.WriteLine("\nDIRECTORIES");
|
||||
Console.WriteLine("Project: " + ProjectDirectory);
|
||||
Console.WriteLine("Output: " + OutputDirectory);
|
||||
//Console.WriteLine("Source: " + SourceDirectory);
|
||||
//Console.WriteLine("NuGet: " + NuGetDirectory);
|
||||
//Console.WriteLine("Choco: " + ChocoDirectory);
|
||||
Console.WriteLine("Package: " + PackageDirectory);
|
||||
//Console.WriteLine("ZipImage: " + ZipImageDirectory);
|
||||
//Console.WriteLine("ZipTest: " + ZipTestDirectory);
|
||||
//Console.WriteLine("NuGetTest: " + NuGetTestDirectory);
|
||||
//Console.WriteLine("ChocoTest: " + ChocolateyTestDirectory);
|
||||
|
||||
Console.WriteLine("\nBUILD");
|
||||
//Console.WriteLine("Build With: " + (UsingXBuild ? "XBuild" : "MSBuild"));
|
||||
Console.WriteLine("Configuration: " + Configuration);
|
||||
//Console.WriteLine("Engine Runtimes: " + string.Join(", ", SupportedEngineRuntimes));
|
||||
//Console.WriteLine("Core Runtimes: " + string.Join(", ", SupportedCoreRuntimes));
|
||||
//Console.WriteLine("Agent Runtimes: " + string.Join(", ", SupportedAgentRuntimes));
|
||||
|
||||
Console.WriteLine("\nPACKAGING");
|
||||
Console.WriteLine("MyGetPushUrl: " + MyGetPushUrl);
|
||||
Console.WriteLine("NuGetPushUrl: " + NuGetPushUrl);
|
||||
Console.WriteLine("ChocolateyPushUrl: " + ChocolateyPushUrl);
|
||||
Console.WriteLine("MyGetApiKey: " + (!string.IsNullOrEmpty(MyGetApiKey) ? "AVAILABLE" : "NOT AVAILABLE"));
|
||||
Console.WriteLine("NuGetApiKey: " + (!string.IsNullOrEmpty(NuGetApiKey) ? "AVAILABLE" : "NOT AVAILABLE"));
|
||||
Console.WriteLine("ChocolateyApiKey: " + (!string.IsNullOrEmpty(ChocolateyApiKey) ? "AVAILABLE" : "NOT AVAILABLE"));
|
||||
|
||||
Console.WriteLine("\nPUBLISHING");
|
||||
Console.WriteLine("ShouldPublishToMyGet: " + ShouldPublishToMyGet);
|
||||
Console.WriteLine("ShouldPublishToNuGet: " + ShouldPublishToNuGet);
|
||||
Console.WriteLine("ShouldPublishToChocolatey: " + ShouldPublishToChocolatey);
|
||||
|
||||
Console.WriteLine("\nRELEASING");
|
||||
Console.WriteLine("BranchName: " + BranchName);
|
||||
Console.WriteLine("IsReleaseBranch: " + IsReleaseBranch);
|
||||
Console.WriteLine("IsProductionRelease: " + IsProductionRelease);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
public class BuildVersion
|
||||
{
|
||||
private ISetupContext _context;
|
||||
private BuildParameters _parameters;
|
||||
private GitVersion _gitVersion;
|
||||
|
||||
// NOTE: This is complicated because (1) the user may have specified
|
||||
// the package version on the command-line and (2) GitVersion may
|
||||
// or may not be available. We'll work on solving (2) by getting
|
||||
// GitVersion to run for us on Linux, but (1) will alwas remain.
|
||||
//
|
||||
// We simplify things a by figuring out the full package version and
|
||||
// then parsing it to provide information that is used in the build.
|
||||
public BuildVersion(ISetupContext context, BuildParameters parameters)
|
||||
{
|
||||
_context = context;
|
||||
_parameters = parameters;
|
||||
_gitVersion = context.GitVersion();
|
||||
|
||||
BranchName = _gitVersion.BranchName;
|
||||
IsReleaseBranch = BranchName.StartsWith("release-");
|
||||
|
||||
// TODO: Get GitVersion to work on Linux
|
||||
string packageVersion = context.HasArgument("version")
|
||||
? context.Argument("version", DEFAULT_VERSION)
|
||||
: CalculatePackageVersion();
|
||||
|
||||
int dash = packageVersion.IndexOf('-');
|
||||
IsPreRelease = dash > 0;
|
||||
|
||||
string versionPart = packageVersion;
|
||||
string suffix = "";
|
||||
string label = "";
|
||||
|
||||
if (IsPreRelease)
|
||||
{
|
||||
versionPart = packageVersion.Substring(0, dash);
|
||||
suffix = packageVersion.Substring(dash+1);
|
||||
foreach (char c in suffix)
|
||||
{
|
||||
if (!char.IsLetter(c))
|
||||
break;
|
||||
label += c;
|
||||
}
|
||||
}
|
||||
|
||||
Version version = new Version(versionPart);
|
||||
SemVer = version.ToString(3);
|
||||
PreReleaseLabel = label;
|
||||
PreReleaseSuffix = suffix;
|
||||
|
||||
PackageVersion = packageVersion;
|
||||
AssemblyVersion = SemVer + ".0";
|
||||
AssemblyFileVersion = SemVer;
|
||||
AssemblyInformationalVersion = packageVersion;
|
||||
}
|
||||
|
||||
public string BranchName { get; }
|
||||
public bool IsReleaseBranch { get; }
|
||||
|
||||
public string PackageVersion { get; }
|
||||
public string AssemblyVersion { get; }
|
||||
public string AssemblyFileVersion { get; }
|
||||
public string AssemblyInformationalVersion { get; }
|
||||
|
||||
public string SemVer { get; }
|
||||
public bool IsPreRelease { get; }
|
||||
public string PreReleaseLabel { get; }
|
||||
public string PreReleaseSuffix { get; }
|
||||
|
||||
private string CalculatePackageVersion()
|
||||
{
|
||||
string label = _gitVersion.PreReleaseLabel;
|
||||
|
||||
// Non pre-release is easy
|
||||
if (string.IsNullOrEmpty(label))
|
||||
return _gitVersion.MajorMinorPatch;
|
||||
|
||||
string branchName = _gitVersion.BranchName;
|
||||
// We don't currently use this pattern, but check in case we do later.
|
||||
if (branchName.StartsWith ("feature/"))
|
||||
branchName = branchName.Substring(8);
|
||||
|
||||
// Arbitrary branch names are ci builds
|
||||
if (label == branchName)
|
||||
label = "ci";
|
||||
|
||||
string suffix = "-" + label + _gitVersion.CommitsSinceVersionSourcePadded;
|
||||
|
||||
switch(label)
|
||||
{
|
||||
case "ci":
|
||||
branchName = Regex.Replace(branchName, "[^0-9A-Za-z-]+", "-");
|
||||
suffix += "-" + branchName;
|
||||
// Nuget limits "special version part" to 20 chars. Add one for the hyphen.
|
||||
if (suffix.Length > 21)
|
||||
suffix = suffix.Substring(0, 21);
|
||||
return _gitVersion.MajorMinorPatch + suffix;
|
||||
|
||||
case "dev":
|
||||
case "pre":
|
||||
return _gitVersion.MajorMinorPatch + suffix;
|
||||
|
||||
case "pr":
|
||||
return _gitVersion.LegacySemVerPadded;
|
||||
|
||||
case "rc":
|
||||
case "alpha":
|
||||
case "beta":
|
||||
default:
|
||||
return _gitVersion.LegacySemVer;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.852
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31205.134
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.v2.driver", "src\extension\nunit.v2.driver.csproj", "{379058E2-E834-4CC7-B5CD-AC8DFCF82AEA}"
|
||||
EndProject
|
||||
|
@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
build.ps1 = build.ps1
|
||||
build.sh = build.sh
|
||||
CHANGES.txt = CHANGES.txt
|
||||
GitVersion.yml = GitVersion.yml
|
||||
LICENSE.txt = LICENSE.txt
|
||||
nunit.v2.driver.nuspec = nunit.v2.driver.nuspec
|
||||
README.md = README.md
|
||||
|
@ -23,6 +24,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "v2-test-assembly", "src\v2-
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.v2.driver.tests", "src\nunit.v2.driver.tests\nunit.v2.driver.tests.csproj", "{10659B84-B1DA-4768-9AB7-CDA3EB58EFD4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{0E1320F6-992A-48FA-871B-5FD018BD8BE8}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
cake\constants.cake = cake\constants.cake
|
||||
cake\packaging.cake = cake\packaging.cake
|
||||
cake\parameters.cake = cake\parameters.cake
|
||||
cake\versioning.cake = cake\versioning.cake
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -45,6 +54,9 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{0E1320F6-992A-48FA-871B-5FD018BD8BE8} = {90F23995-721F-40CB-9D64-28FF5FD98250}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E3CE9F5F-EF5F-48B1-B211-42FFCB09BC65}
|
||||
EndGlobalSection
|
||||
|
|
Загрузка…
Ссылка в новой задаче