From a2c6926d5e3f979a9ca2f8baa3214498eb982124 Mon Sep 17 00:00:00 2001 From: Charlie Poole Date: Wed, 17 Jul 2024 20:58:41 -0700 Subject: [PATCH] Fix errors in dotnet tool package --- build.cake | 35 ++++++++++++----- .../nunit.console-runner.netcore.nuspec | 39 ++++++++++--------- .../nunit3-console/nunit3-console.csproj | 2 + 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/build.cake b/build.cake index 3b04d4ca8..24848675c 100644 --- a/build.cake +++ b/build.cake @@ -262,18 +262,12 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] { source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner-with-extensions.nuspec", checks: new PackageCheck[] { HasFile("LICENSE.txt") }), - NUnitConsoleRunnerNetCorePackage = new NuGetPackage( + NUnitConsoleRunnerNetCorePackage = new DotNetToolPackage( id: "NUnit.ConsoleRunner.NetCore", source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.netcore.nuspec", - checks: new PackageCheck[] { - HasFiles("LICENSE.txt", "NOTICES.txt"), - HasDirectory("tools/net6.0").WithFiles("nunit3-console.exe", "nunit3-console.dll", "nunit-console.nuget.addins").AndFiles(ENGINE_FILES) - }, - symbols: new PackageCheck[] { - HasDirectory("tools/net6.0").WithFile("nunit3-console.pdb").AndFiles(ENGINE_PDB_FILES) - }, + checks: new PackageCheck[] { HasFiles("nunit.exe") }, testRunner: new ConsoleRunnerSelfTester(BuildSettings.NuGetTestDirectory - + $"NUnit.ConsoleRunner.NetCore.{BuildSettings.PackageVersion}/tools/net6.0/nunit3-console.exe"), + + $"NUnit.ConsoleRunner.NetCore.{BuildSettings.PackageVersion}/nunit.exe"), tests: NetCoreRunnerTests), NUnitConsoleRunnerChocolateyPackage = new ChocolateyPackage( @@ -388,6 +382,29 @@ public class ConsoleRunnerSelfTester : TestRunner, IPackageTestRunner } } +////////////////////////////////////////////////////////////////////// +// DOTNET TOOL PACKAGE +////////////////////////////////////////////////////////////////////// + +// TODO: Temporary custom package class to be moved into the recipe + +public class DotNetToolPackage : NuGetPackage +{ + public DotNetToolPackage(string id, string source, string basePath = null, + IPackageTestRunner testRunner = null, TestRunnerSource testRunnerSource = null, + PackageCheck[] checks = null, PackageCheck[] symbols = null, IEnumerable tests = null) + : base(id, source, basePath: basePath, testRunner: testRunner, testRunnerSource: testRunnerSource, + checks: checks, symbols: symbols, tests: tests) { } + + public override void InstallPackage() + { + var arguments = $"tool install {PackageId} --version {BuildSettings.PackageVersion} " + + $"--add-source \"{BuildSettings.PackageDirectory}\" --tool-path \"{PackageTestDirectory}\""; + Console.WriteLine($"Executing dotnet {arguments}"); + _context.StartProcess("dotnet", arguments); + } +} + ////////////////////////////////////////////////////////////////////// // ADDITIONAL TARGETS USED FOR RECOVERY AND DEBUGGING ////////////////////////////////////////////////////////////////////// diff --git a/nuget/runners/nunit.console-runner.netcore.nuspec b/nuget/runners/nunit.console-runner.netcore.nuspec index 35dfac8d4..e297d4524 100644 --- a/nuget/runners/nunit.console-runner.netcore.nuspec +++ b/nuget/runners/nunit.console-runner.netcore.nuspec @@ -21,29 +21,32 @@ https://docs.nunit.org/articles/nunit/release-notes/console-and-engine.html en-US nunit test testing tdd runner - Copyright (c) 2021 Charlie Poole, Rob Prouse + Copyright (c) 2021-2024 Charlie Poole, Rob Prouse + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/NUnitConsole/nunit3-console/nunit3-console.csproj b/src/NUnitConsole/nunit3-console/nunit3-console.csproj index 5b76fa1e9..28d9448f3 100644 --- a/src/NUnitConsole/nunit3-console/nunit3-console.csproj +++ b/src/NUnitConsole/nunit3-console/nunit3-console.csproj @@ -6,6 +6,8 @@ nunit3-console net462;net6.0;net8.0 Major + portable + true