Skip to content

Commit

Permalink
Merge pull request #1451 from nunit/issue-1446
Browse files Browse the repository at this point in the history
Fix errors in the dotnet tool runner
  • Loading branch information
CharliePoole authored Jul 18, 2024
2 parents 83d154c + a2c6926 commit 5e16ca2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 34 deletions.
45 changes: 29 additions & 16 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ FilePath[] AGENT_PDB_FILES = {
"nunit-agent.pdb", "nunit-agent-x86.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] AGENT_PDB_FILES_NETCORE = {
"nunit-agent.pdb", "nunit.engine.core.pdb", "nunit.engine.api.pdb"};
FilePath[] CONSOLE_FILES = {
"nunit3-console.exe", "nunit3-console.exe.config" };
FilePath[] CONSOLE_FILES_NETCORE = {
"nunit3-console.exe", "nunit3-console.dll" };

//////////////////////////////////////////////////////////////////////
// INDIVIDUAL PACKAGE DEFINITIONS
Expand All @@ -241,7 +237,7 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
source: BuildSettings.NuGetDirectory + "runners/nunit.console-runner.nuspec",
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt"),
HasDirectory("tools").WithFiles(CONSOLE_FILES).AndFiles(ENGINE_FILES).AndFile("nunit.console.nuget.addins"),
HasDirectory("tools").WithFiles("nunit3-console.exe", "nunit3-console.exe.config", "nunit.console.nuget.addins").AndFiles(ENGINE_FILES),
HasDirectory("tools/agents/net462").WithFiles(AGENT_FILES).AndFile("nunit.console.nuget.agent.addins"),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.console.nuget.agent.addins"),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.console.nuget.agent.addins"),
Expand All @@ -266,25 +262,19 @@ 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(CONSOLE_FILES_NETCORE).AndFiles(ENGINE_CORE_FILES).AndFile("nunit.console.nuget.addins")
},
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(
id: "nunit-console-runner",
source: BuildSettings.ChocolateyDirectory + "nunit-console-runner.nuspec",
checks: new PackageCheck[] {
HasDirectory("tools").WithFiles("LICENSE.txt", "NOTICES.txt", "VERIFICATION.txt").AndFiles(CONSOLE_FILES).AndFiles(ENGINE_FILES).AndFile("nunit.console.choco.addins"),
HasDirectory("tools").WithFiles("LICENSE.txt", "NOTICES.txt", "VERIFICATION.txt", "nunit3-console.exe", "nunit3-console.exe.config", "nunit.console.choco.addins").AndFiles(ENGINE_FILES),
HasDirectory("tools/agents/net462").WithFiles(AGENT_FILES).AndFile("nunit.console.choco.agent.addins"),
HasDirectory("tools/agents/netcoreapp3.1").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.console.choco.agent.addins"),
HasDirectory("tools/agents/net6.0").WithFiles(AGENT_FILES_NETCORE).AndFile("nunit.console.choco.agent.addins"),
Expand All @@ -300,7 +290,7 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
source: BuildSettings.ZipImageDirectory,
checks: new PackageCheck[] {
HasFiles("LICENSE.txt", "NOTICES.txt", "CHANGES.txt"),
HasDirectory("bin/net462").WithFiles(CONSOLE_FILES).AndFiles(ENGINE_FILES).AndFile("nunit3-console.pdb").AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/net462").WithFiles("nunit3-console.exe", "nunit3-console.exe.config", "nunit3-console.pdb").AndFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/netstandard2.0").WithFiles(ENGINE_FILES).AndFiles(ENGINE_PDB_FILES),
HasDirectory("bin/netcoreapp3.1").WithFiles(ENGINE_CORE_FILES).AndFiles(ENGINE_CORE_PDB_FILES),
HasDirectory("bin/agents/net462").WithFiles(AGENT_FILES).AndFiles(AGENT_PDB_FILES),
Expand Down Expand Up @@ -392,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<PackageTest> 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
//////////////////////////////////////////////////////////////////////
Expand Down
39 changes: 21 additions & 18 deletions nuget/runners/nunit.console-runner.netcore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@
<releaseNotes>https://docs.nunit.org/articles/nunit/release-notes/console-and-engine.html</releaseNotes>
<language>en-US</language>
<tags>nunit test testing tdd runner</tags>
<copyright>Copyright (c) 2021 Charlie Poole, Rob Prouse</copyright>
<copyright>Copyright (c) 2021-2024 Charlie Poole, Rob Prouse</copyright>
<packageTypes>
<packageType name="DotnetTool" />
</packageTypes>
</metadata>
<files>
<file src="../../LICENSE.txt" />
<file src="../../NOTICES.txt" />

<file src="net6.0/nunit3-console.exe" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.pdb" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.dll" target="tools/net6.0/" />
<file src="net6.0/nunit3-console.dll.config" target="tools/net6.0" />
<file src="net6.0/nunit3-console.deps.json" target="tools/net6.0" />
<file src="net6.0/nunit3-console.runtimeconfig.json" target="tools/net6.0" />
<file src="net6.0/nunit.engine.core.dll" target="tools/net6.0" />
<file src="net6.0/nunit.engine.core.pdb" target="tools/net6.0" />
<file src="net6.0/nunit.engine.dll" target="tools/net6.0" />
<file src="net6.0/nunit.engine.pdb" target="tools/net6.0" />
<file src="net6.0/nunit.engine.api.dll" target="tools/net6.0" />
<file src="net6.0/nunit.engine.api.pdb" target="tools/net6.0" />
<file src="net6.0/nunit.engine.api.xml" target="tools/net6.0" />
<file src="net6.0/testcentric.engine.metadata.dll" target="tools/net6.0" />
<file src="net6.0/Microsoft.Extensions.DependencyModel.dll" target="tools/net6.0" />
<file src="../../nuget/runners/nunit.console.nuget.addins" target="tools/net6.0"/>
<file src="../../nuget/runners/DotnetToolSettings.xml" target="tools/net6.0"/>
<file src="net6.0/nunit3-console.exe" target="tools/net6.0/any" />
<file src="net6.0/nunit3-console.pdb" target="tools/net6.0/any" />
<file src="net6.0/nunit3-console.dll" target="tools/net6.0/any" />
<file src="net6.0/nunit3-console.dll.config" target="tools/net6.0/any" />
<file src="net6.0/nunit3-console.deps.json" target="tools/net6.0/any" />
<file src="net6.0/nunit3-console.runtimeconfig.json" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.core.dll" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.core.pdb" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.dll" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.pdb" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.api.dll" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.api.pdb" target="tools/net6.0/any" />
<file src="net6.0/nunit.engine.api.xml" target="tools/net6.0/any" />
<file src="net6.0/testcentric.engine.metadata.dll" target="tools/net6.0/any" />
<file src="net6.0/Microsoft.Extensions.DependencyModel.dll" target="tools/net6.0/any" />
<file src="../../nuget/runners/nunit.console.nuget.addins" target="tools/net6.0/any"/>
<file src="../../nuget/runners/DotnetToolSettings.xml" target="tools/net6.0/any"/>

<file src="../../nunit_256.png" target="images"/>
</files>
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitConsole/nunit3-console/nunit3-console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<AssemblyName>nunit3-console</AssemblyName>
<TargetFrameworks>net462;net6.0;net8.0</TargetFrameworks>
<RollForward>Major</RollForward>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 5e16ca2

Please sign in to comment.