Skip to content

Commit

Permalink
Merge pull request #9 from nunit/issue-8
Browse files Browse the repository at this point in the history
Integrate creation of chocolatey packages
  • Loading branch information
CharliePoole authored Jul 25, 2017
2 parents d8e5d0f + 8baf816 commit 3be0745
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ deploy
lib
test-results
package
output
images
MockAssemblyResult.xml
PortabilityAnalysis*.html
Expand Down
6 changes: 6 additions & 0 deletions VERIFICATION.txt
Original file line number Diff line number Diff line change
@@ -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.NUnitProjectLoader nuget package.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build_script:
test: off

artifacts:
- path: package\*.nupkg
- path: output\*.nupkg
181 changes: 150 additions & 31 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,27 +1,50 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.1
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0

//////////////////////////////////////////////////////////////////////
// PROJECT-SPECIFIC
//////////////////////////////////////////////////////////////////////

// When copying the script to support a different extension, the
// main changes needed should be in this section.

var SOLUTION_FILE = "nunit-project-loader.sln";
var NUSPEC_FILE = "nunit-project-loader.nuspec";
var UNIT_TEST_ASSEMBLY = "nunit-project-loader.tests.dll";
var GITHUB_SITE = "https://github.com/nunit/nunit-project-loader";
var WIKI_PAGE = "https://github.com/nunit/docs/wiki/Console-Command-Line";
var VERSION = "3.6.0";

// Metadata used in the nuget and chocolatey packages
var TITLE = "NUnit 3 - NUnit Project Loader Extension";
var AUTHORS = new [] { "Charlie Poole" };
var OWNERS = new [] { "Charlie Poole" };
var DESCRIPTION = "This extension allows NUnit to recognize and load NUnit projects, file type .nunit.";
var SUMMARY = "NUnit Engine extension for loading NUnit projects.";
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
// 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)
{
Expand All @@ -39,7 +62,7 @@ if (BuildSystem.IsRunningOnAppVeyor)

if (branch == "master" && !isPullRequest)
{
packageVersion = version + "-dev-" + buildNumber + dbgSuffix;
packageVersion = VERSION + "-dev-" + buildNumber + dbgSuffix;
}
else
{
Expand All @@ -54,9 +77,9 @@ if (BuildSystem.IsRunningOnAppVeyor)
if (suffix.Length > 21)
suffix = suffix.Substring(0, 21);

suffix = suffix.Replace(".", "");
suffix = suffix.Replace(".", "");

packageVersion = version + suffix;
packageVersion = VERSION + suffix;
}
}

Expand All @@ -69,13 +92,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[]
Expand All @@ -102,7 +133,7 @@ Task("Clean")
Task("NuGetRestore")
.Does(() =>
{
NuGetRestore(SOLUTION_PATH, new NuGetRestoreSettings()
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings()
{
Source = PACKAGE_SOURCE
});
Expand All @@ -116,11 +147,27 @@ Task("Build")
.IsDependentOn("NuGetRestore")
.Does(() =>
{
DotNetBuild(SOLUTION_PATH, settings => settings
.WithTarget("Build")
.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Minimal)
);
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)
);
}
});

//////////////////////////////////////////////////////////////////////
Expand All @@ -131,25 +178,89 @@ 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);
NuGetPack(NUSPEC_PATH, new NuGetPackSettings()
{
Version = packageVersion,
BasePath = BIN_DIR,
OutputDirectory = PACKAGE_DIR
});
CreateDirectory(OUTPUT_DIR);
NuGetPack(
new NuGetPackSettings()
{
Id = "NUnit.Extension.NUnitProjectLoader",
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 = BIN_SRC + "nunit-project-loader.dll", Target = "tools" }
}
});
});

Task("RePackageChocolatey")
.Does(() =>
{
CreateDirectory(OUTPUT_DIR);
ChocolateyPack(
new ChocolateyPackSettings()
{
Id = "nunit-extension-nunit-project-loader",
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 + "VERIFICATION.txt", Target = "tools" },
new ChocolateyNuSpecContent { Source = BIN_SRC + "nunit-project-loader.dll", Target = "tools" }
}
});
});

//////////////////////////////////////////////////////////////////////
Expand All @@ -160,6 +271,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")
Expand Down
24 changes: 0 additions & 24 deletions nunit-project-loader.nuspec

This file was deleted.

2 changes: 1 addition & 1 deletion src/extension/nunit-project-loader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.Engine.Api.3.5.0-dev-03221\lib\nunit.engine.api.dll</HintPath>
<HintPath>..\..\packages\NUnit.Engine.Api.3.7.0\lib\nunit.engine.api.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/extension/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.Engine.Api" version="3.5.0-dev-03221" targetFramework="net20" />
<package id="NUnit.Engine.Api" version="3.7.0" targetFramework="net20" />
</packages>
8 changes: 4 additions & 4 deletions src/tests/nunit-project-loader.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.Engine.Api.3.5.0-dev-03221\lib\nunit.engine.api.dll</HintPath>
<HintPath>..\..\packages\NUnit.Engine.Api.3.7.0\lib\nunit.engine.api.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.5.0\lib\net20\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.7.1\lib\net20\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NUnit.System.Linq, Version=0.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.5.0\lib\net20\NUnit.System.Linq.dll</HintPath>
<HintPath>..\..\packages\NUnit.3.7.1\lib\net20\NUnit.System.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
4 changes: 2 additions & 2 deletions src/tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.5.0" targetFramework="net20" />
<package id="NUnit.Engine.Api" version="3.5.0-dev-03221" targetFramework="net20" />
<package id="NUnit" version="3.7.1" targetFramework="net20" />
<package id="NUnit.Engine.Api" version="3.7.0" targetFramework="net20" />
</packages>
2 changes: 1 addition & 1 deletion tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.15.2" />
<package id="Cake" version="0.20.0" />
</packages>

0 comments on commit 3be0745

Please sign in to comment.