Integrate chocolatey package in build script

This commit is contained in:
Charlie Poole 2017-07-27 10:40:33 +01:00
Родитель 08ad09036a
Коммит ab69f88464
5 изменённых файлов: 166 добавлений и 57 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -174,6 +174,7 @@ deploy
lib
test-results
package
output
images
MockAssemblyResult.xml
PortabilityAnalysis*.html

3
CHANGES.txt Normal file
Просмотреть файл

@ -0,0 +1,3 @@
NUnit V2 Result Writer Extension 3.5 - October 6, 2016
The first independent release of the nunit-v2-result-writer extension.

6
VERIFICATION.txt Normal file
Просмотреть файл

@ -0,0 +1,6 @@
VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.
This package is published by the NUnit Project itself. The binaries are
identical to those in the NUnit.Extension.NUnitV2ReportWriter nuget package.

Просмотреть файл

@ -1,27 +1,52 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.1
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
//////////////////////////////////////////////////////////////////////
// PROJECT-SPECIFIC
//////////////////////////////////////////////////////////////////////
var SOLUTION_FILE = "nunit-v2-result-writer.sln";
var NUSPEC_FILE = "nunit-v2-result-writer.nuspec";
var UNIT_TEST_ASSEMBLY = "nunit-v2-result-writer.tests.dll";
//////////////////////////////////////////////////////////////////////
// When copying the script to support a different extension, the
// main changes needed should be in this section.
var SOLUTION_FILE = "nunit-v2-result-writer.sln";
var UNIT_TEST_ASSEMBLY = "nunit-v2-result-writer.tests.dll";
var GITHUB_SITE = "https://github.com/nunit/nunit-v2-result-writer";
var WIKI_PAGE = "https://github.com/nunit/docs/wiki/Console-Command-Line";
var NUGET_ID = "NUnit.Extension.NUnitV2ResultWriter";
var CHOCO_ID = "nunit-extension-nunit-v2-result-writer";
var VERSION = "3.6.0";
// Metadata used in the nuget and chocolatey packages
var TITLE = "NUnit 3 - NUnit V2 Result Writer Extension";
var AUTHORS = new [] { "Charlie Poole" };
var OWNERS = new [] { "Charlie Poole" };
var DESCRIPTION = "This extension allows NUnit to create result files in the V2 format, which is used by many CI servers.";
var SUMMARY = "NUnit Engine extension for writing test result files in NUnit V2 format.";
var COPYRIGHT = "Copyright (c) 2016 Charlie Poole";
var RELEASE_NOTES = new [] { "See https://raw.githubusercontent.com/nunit/nunit-project-loader/master/CHANGES.txt" };
var TAGS = new [] { "nunit", "test", "testing", "tdd", "runner" };
////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
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);
//////////////////////////////////////////////////////////////////////
// SET PACKAGE VERSION
//////////////////////////////////////////////////////////////////////
var version = "3.6.0";
var dbgSuffix = configuration == "Debug" ? "-dbg" : "";
var packageVersion = version + dbgSuffix;
var packageVersion = VERSION + dbgSuffix;
if (BuildSystem.IsRunningOnAppVeyor)
{
@ -39,7 +64,7 @@ if (BuildSystem.IsRunningOnAppVeyor)
if (branch == "master" && !isPullRequest)
{
packageVersion = version + "-dev-" + buildNumber + dbgSuffix;
packageVersion = VERSION + "-dev-" + buildNumber + dbgSuffix;
}
else
{
@ -56,7 +81,7 @@ if (BuildSystem.IsRunningOnAppVeyor)
suffix = suffix.Replace(".", "");
packageVersion = version + suffix;
packageVersion = VERSION + suffix;
}
}
@ -69,13 +94,21 @@ if (BuildSystem.IsRunningOnAppVeyor)
// Directories
var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/";
var PACKAGE_DIR = PROJECT_DIR + "package/";
var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/";
var BIN_SRC = BIN_DIR; // Source of binaries used in packaging
var OUTPUT_DIR = PROJECT_DIR + "output/";
// File PATHS
var SOLUTION_PATH = PROJECT_DIR + SOLUTION_FILE;
var NUSPEC_PATH = PROJECT_DIR + NUSPEC_FILE;
var UNIT_TEST_PATH = BIN_DIR + UNIT_TEST_ASSEMBLY;
// Adjust BIN_SRC if --binaries option was given
if (binaries != null)
{
BIN_SRC = binaries;
if (!System.IO.Path.IsPathRooted(binaries))
{
BIN_SRC = PROJECT_DIR + binaries;
if (!BIN_SRC.EndsWith("/"))
BIN_SRC += "/";
}
}
// Package sources for nuget restore
var PACKAGE_SOURCE = new string[]
@ -102,7 +135,7 @@ Task("Clean")
Task("NuGetRestore")
.Does(() =>
{
NuGetRestore(SOLUTION_PATH, new NuGetRestoreSettings()
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings()
{
Source = PACKAGE_SOURCE
});
@ -114,13 +147,29 @@ Task("NuGetRestore")
Task("Build")
.IsDependentOn("NuGetRestore")
.Does(() =>
{
DotNetBuild(SOLUTION_PATH, settings => settings
.WithTarget("Build")
.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Minimal)
);
.Does(() =>
{
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)
.SetMSBuildPlatform(MSBuildPlatform.Automatic)
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false)
.SetPlatformTarget(PlatformTarget.MSIL)
);
}
else
{
XBuild(SOLUTION_FILE, new XBuildSettings()
.WithTarget("Build")
.WithProperty("Configuration", configuration)
.SetVerbosity(Verbosity.Minimal)
);
}
});
//////////////////////////////////////////////////////////////////////
@ -131,25 +180,91 @@ Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
NUnit3(UNIT_TEST_PATH);
NUnit3(BIN_DIR + UNIT_TEST_ASSEMBLY);
});
//////////////////////////////////////////////////////////////////////
// PACKAGE
//////////////////////////////////////////////////////////////////////
Task("Package")
.IsDependentOn("Build")
// 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(() =>
{
CreateDirectory(PACKAGE_DIR);
CreateDirectory(OUTPUT_DIR);
NuGetPack(NUSPEC_PATH, new NuGetPackSettings()
{
Version = packageVersion,
BasePath = BIN_DIR,
OutputDirectory = PACKAGE_DIR
});
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,
Files = new [] {
new NuSpecContent { Source = PROJECT_DIR + "LICENSE.txt" },
new NuSpecContent { Source = PROJECT_DIR + "CHANGES.txt" },
new NuSpecContent { Source = BIN_SRC + "nunit-v2-result-writer.dll", Target = "tools" }
}
});
});
Task("RePackageChocolatey")
.Does(() =>
{
CreateDirectory(OUTPUT_DIR);
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 = BIN_SRC + "nunit-v2-result-writer.dll", Target = "tools" }
}
});
});
//////////////////////////////////////////////////////////////////////
@ -160,6 +275,14 @@ Task("Rebuild")
.IsDependentOn("Clean")
.IsDependentOn("Build");
Task("Package")
.IsDependentOn("Build")
.IsDependentOn("RePackage");
Task("RePackage")
.IsDependentOn("RePackageNuGet")
.IsDependentOn("RePackageChocolatey");
Task("Appveyor")
.IsDependentOn("Build")
.IsDependentOn("Test")

Просмотреть файл

@ -1,24 +0,0 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>NUnit.Extension.NUnitV2ResultWriter</id>
<title>NUnit 3 - NUnit V2 Result Writer Extension</title>
<version>$version$</version>
<authors>Charlie Poole</authors>
<owners>Charlie Poole</owners>
<licenseUrl>http://nunit.org/nuget/nunit3-license.txt</licenseUrl>
<projectUrl>http://nunit.org</projectUrl>
<iconUrl>http://nunit.org/nuget/nunitv3_32x32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>NUnit Engine extension for writing test result files in NUnit V2 format.</summary>
<description>This extension allows NUnit to create result files in the V2 format, which is used by many CI servers.</description>
<releaseNotes></releaseNotes>
<language>en-US</language>
<tags>nunit test testing tdd runner</tags>
<copyright>Copyright (c) 2016 Charlie Poole</copyright>
</metadata>
<files>
<file src="../../LICENSE.txt" />
<file src="nunit-v2-result-writer.dll" target="tools"/>
</files>
</package>