diff --git a/build.cake b/build.cake index 9a74aa4..a18f27b 100644 --- a/build.cake +++ b/build.cake @@ -6,22 +6,7 @@ #tool nuget:?package=NUnit.ConsoleRunner&version=3.18.0-dev00037 #tool nuget:?package=NUnit.ConsoleRunner.NetCore&version=3.18.0-dev00037 -//////////////////////////////////////////////////////////////////// -// CONSTANTS -////////////////////////////////////////////////////////////////////// - -const string SOLUTION_FILE = "nunit-project-loader.sln"; -const string NUGET_ID = "NUnit.Extension.NUnitProjectLoader"; -const string CHOCO_ID = "nunit-extension-nunit-project-loader"; -const string GITHUB_OWNER = "nunit"; -const string GITHUB_REPO = "nunit-project-loader"; -const string DEFAULT_CONFIGURATION = "Release"; -// Make sure that all the following console versions are installed using #tool -// For the net core runner, prefix version here with "NetCore" e.g.: "NetCore.3.7.1" -static readonly string[] CONSOLE_VERSIONS_FOR_PACKAGE_TESTS = new string[] { "3.17.0", "3.15.5", "3.18.0-dev00037" }; -const string CONSOLE_VERSION_FOR_UNIT_TESTS = "3.17.0"; - -// Load scripts after defining constants +// Load scripts #load cake/parameters.cake ////////////////////////////////////////////////////////////////////// @@ -71,6 +56,8 @@ Task("Clean") CleanDirectory(parameters.OutputDirectory); Information("Cleaning " + parameters.PackageDirectory); CleanDirectory(parameters.PackageDirectory); + Information("Deleting log files"); + DeleteFiles(parameters.ProjectDirectory + "*.log"); }); ////////////////////////////////////////////////////////////////////// @@ -133,6 +120,8 @@ Task("TestNet462") { string runner = parameters.ToolsDirectory + $"NUnit.ConsoleRunner.{CONSOLE_VERSION_FOR_UNIT_TESTS}/tools/nunit3-console.exe"; StartProcess(runner, parameters.OutputDirectory + "net462/nunit-project-loader.tests.dll"); + // We will have empty logs so long as we test against 3.15.5 and 3.17.0 + DeleteEmptyLogFiles(parameters.ProjectDirectory); }); Task("TestNet60") @@ -173,7 +162,7 @@ Task("VerifyNuGetPackage") .Does((parameters) => { Check.That(parameters.NuGetInstallDirectory, - HasFiles("CHANGES.md", "LICENSE.txt"), + HasFiles("CHANGES.md", "LICENSE.txt", "nunit_256.png"), HasDirectory("tools/net20").WithFiles("nunit-project-loader.dll", "nunit.engine.api.dll")); Information("Verification was successful!"); }); @@ -183,6 +172,9 @@ Task("TestNuGetPackage") .Does((parameters) => { new NuGetPackageTester(parameters).RunPackageTests(PackageTests); + + // We will have empty logs so long as we test against 3.15.5 and 3.17.0 + DeleteEmptyLogFiles(parameters.ProjectDirectory); }); Task("BuildChocolateyPackage") @@ -224,6 +216,9 @@ Task("TestChocolateyPackage") .Does((parameters) => { new ChocolateyPackageTester(parameters).RunPackageTests(PackageTests); + + // We will have empty logs so long as we test against 3.15.5 and 3.17.0 + DeleteEmptyLogFiles(parameters.ProjectDirectory); }); PackageTest[] PackageTests = new PackageTest[] diff --git a/cake/constants.cake b/cake/constants.cake new file mode 100644 index 0000000..51e79cb --- /dev/null +++ b/cake/constants.cake @@ -0,0 +1,15 @@ +//////////////////////////////////////////////////////////////////// +// CONSTANTS +////////////////////////////////////////////////////////////////////// + +const string SOLUTION_FILE = "nunit-project-loader.sln"; +const string NUGET_ID = "NUnit.Extension.NUnitProjectLoader"; +const string CHOCO_ID = "nunit-extension-nunit-project-loader"; +const string GITHUB_OWNER = "nunit"; +const string GITHUB_REPO = "nunit-project-loader"; +const string DEFAULT_CONFIGURATION = "Release"; +// Make sure that all the following console versions are installed using #tool +// For the net core runner, prefix version here with "NetCore" e.g.: "NetCore.3.7.1" +static readonly string[] CONSOLE_VERSIONS_FOR_PACKAGE_TESTS = new string[] { "3.17.0", "3.15.5", "3.18.0-dev00037" }; +const string CONSOLE_VERSION_FOR_UNIT_TESTS = "3.17.0"; + diff --git a/cake/packaging.cake b/cake/packaging.cake index 4f1581f..0c29136 100644 --- a/cake/packaging.cake +++ b/cake/packaging.cake @@ -30,6 +30,7 @@ public void BuildNuGetPackage(BuildParameters parameters) var content = new List(); content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "LICENSE.txt" }); content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "CHANGES.md" }); + content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "nunit_256.png" }); content.Add(new NuSpecContent { Source = parameters.ProjectDirectory + "nunit-project-loader.addins", Target = "tools" }); content.Add(new NuSpecContent { Source = parameters.OutputDirectory + "net20/nunit-project-loader.dll", Target = "tools/net20" }); content.Add(new NuSpecContent { Source = parameters.OutputDirectory + "net20/nunit.engine.api.dll", Target = "tools/net20" }); @@ -47,15 +48,12 @@ public void BuildNuGetPackage(BuildParameters parameters) Description = DESCRIPTION, Summary = SUMMARY, ProjectUrl = PROJECT_URL, - IconUrl = ICON_URL, - //Icon = "nunit.ico", // Waiting for Cake release + Icon = "nunit_256.png", License = new NuSpecLicense() { Type = "expression", Value = "MIT" }, - //LicenseUrl = LICENSE_URL, RequireLicenseAcceptance = false, Copyright = COPYRIGHT, ReleaseNotes = RELEASE_NOTES, Tags = TAGS, - //Language = "en-US", OutputDirectory = parameters.PackageDirectory, KeepTemporaryNuSpecFile = false, Files = content diff --git a/cake/parameters.cake b/cake/parameters.cake index 50a7b14..03af409 100644 --- a/cake/parameters.cake +++ b/cake/parameters.cake @@ -1,4 +1,5 @@ -#load "./versioning.cake" +#load "./constants.cake" +#load "./versioning.cake" #load "./packaging.cake" #load "./package-checks.cake" #load "./package-tests.cake" diff --git a/cake/utilities.cake b/cake/utilities.cake index e3da86b..75959fd 100644 --- a/cake/utilities.cake +++ b/cake/utilities.cake @@ -2,6 +2,9 @@ // GLOBALLY ACCESSIBLE UTILITY METHODS ////////////////////////////////////////////////////////////////////// +// These stand-alone utility methods are only visible from within the +// code for defined Tasks. + public void DeleteObjectDirectories(BuildParameters parameters) { string pattern = parameters.SourceDirectory + "**/obj/"; @@ -28,3 +31,12 @@ private void CheckPackageExists(FilePath package) throw new InvalidOperationException( $"Package not found: {package.GetFilename()}.\nCode may have changed since package was last built."); } + +private void DeleteEmptyLogFiles(string directory) +{ + DirectoryInfo info = new DirectoryInfo(directory); + + foreach (var file in info.GetFiles("*.log")) + if (file.Length == 0) + System.IO.File.Delete(file.FullName); +} diff --git a/nunit-project-loader.sln b/nunit-project-loader.sln index 110c28a..7eaf733 100644 --- a/nunit-project-loader.sln +++ b/nunit-project-loader.sln @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "cake", "cake", "{1E689680-AB9D-497E-8FC3-B541A9A24EEC}" ProjectSection(SolutionItems) = preProject + cake\constants.cake = cake\constants.cake cake\local-targets.cake = cake\local-targets.cake cake\package-checks.cake = cake\package-checks.cake cake\package-tests.cake = cake\package-tests.cake diff --git a/nunit_256.png b/nunit_256.png new file mode 100644 index 0000000..ad14c16 Binary files /dev/null and b/nunit_256.png differ