Skip to content

Improvements to Console Runner under .NET 8.0 - #1891

Merged
CharliePoole merged 6 commits into
mainfrom
issue-1101
Sep 8, 2026
Merged

CharliePoole merged 6 commits into
mainfrom
issue-1101

Conversation

@CharliePoole

Copy link
Copy Markdown
Member

Partial fix of #1101
Fixes #946

@CharliePoole
CharliePoole marked this pull request as draft September 5, 2026 18:43
@CharliePoole
CharliePoole marked this pull request as ready for review September 7, 2026 20:48
@CharliePoole

Copy link
Copy Markdown
Member Author

As it stands, this PR is a first cut at running agents under the NetCore build of the console runner.

Current limitations...

  1. The runner still runs under .NET 8.0. Conversin to use .NET 10.0 is coming.
  2. There is only one agent that currently works under the NetCore console... the .NET 10 agent. Other agents must be converted so that he launcher may load under .NET.
  3. I haven't been able to successfully bundle agents with the runner, so they must be installed separately. For the CI build, this is done in package-tests.cake.
  4. Currently, the runner only works on Windows.

@manfred-brands manfred-brands left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I few small remarks, but mostly it is removing conditional compilation.

#else
// ReflectionOnlyLoad isn't available on .NET Core / .NET 5+. Load the assembly into the
// default context for inspection instead, and skip assemblies without a physical location.
var dependency = Assembly.Load(dependencyName);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks... I'll use that.

Comment thread src/NUnitEngine/nunit.engine/Services/ExtensionService.cs Outdated
Comment thread src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs Outdated
Comment thread src/NUnitEngine/nunit.engine/Runtime.cs Outdated
Comment thread src/NUnitEngine/nunit.engine/Runtime.cs
Comment thread src/NUnitEngine/nunit.engine/Runtime.cs
@CharliePoole

Copy link
Copy Markdown
Member Author

For the moment, I'm leaving classes Runtime + RuntimeFramework unchanged. They use a a non-standard id for each runtime, which is also used as the argument to the console --framework= option, i.e. --framework=net-4.6.2 or --framework= netcore-8.-0`.

Issue #1890 suggests replacing that nomenclature with a TFM. You commented on it and I was waiting to see if anyone else had comments before doing it. I'll do a PR for that issue and replace RuntimeFramework with a new class that is entirely based on FrameworkName and TFM.

I'll apply your other suggestions and merge this. Once I have all four agents working under the .NET 8.0 runner, I'll be able to activate all the package tests for it and start to deal with the limitations I listed.

@CharliePoole

Copy link
Copy Markdown
Member Author

@manfred-brands A question for you...

Have you built a dotnet tool containing package dependencies? I can't seem to make it work. When the package is installed, the dependencies are not automatically pulled into the install directory, where they need to be in order to be located by the extension service.

Right now, my package tests are passing by explicitly loading the .NET 10 pluggable agent. But that won't help users who install the runner and find it doesn't work because there are no agents.

@manfred-brands

Copy link
Copy Markdown
Member

Have you built a dotnet tool containing package dependencies?

I pack using.csproj properties instead of a manual .nuspec file.

Are those dependencies tools themselves?
NuGet only installs libs with your tool.

By default, adding a NuGet package as a dependency to a .NET tool project only bundles library (.dll) dependencies. If those dependencies are tools themselves, they won't automatically execute or register in the path

The suggested approach adding a dotnet tool manifest to your package (.config/dotnet-tools.json) which contains the tool dependencies.

The .NET CLI will read the manifest and instantly download and register all the tools.

However those will likely all be in their own subdirectory.

@CharliePoole

Copy link
Copy Markdown
Member Author

I'm packing via the csproj for the netcore runner. The standard runner is using a nuspec because I wasn't able to make it work any other way.

NuGet only installs libs with your tool.

That got me thinking. All of our extensions have traditionaly held their code under a "tools" directory, even though none of them are dotnet tools or even executables. The pluggable agents contain an executable, of course, but the "extension" part is actually the launcher, which runs that executable.

The extension service even uses a file pattern that includes "tools" to locate installed extensions.

The suggested approach adding a dotnet tool manifest to your package (.config/dotnet-tools.json) which contains the tool dependencies.

By default, adding a NuGet package as a dependency to a .NET tool project only bundles library (.dll) dependencies. If those dependencies are tools themselves, they won't automatically execute or register in the path

However those will likely all be in their own subdirectory.

Fortunately, that's exactly what I want, provided I can find the subdirectory!

@CharliePoole
CharliePoole merged commit 9521a81 into main Sep 8, 2026
3 checks passed
@CharliePoole
CharliePoole deleted the issue-1101 branch September 8, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow test engine to be created inside a running test on .NET Core

2 participants