nunit-console: NUnit Console cannot run tests with TargetFramework "net5.0"
If it matters, I’m using:
- NUnit Console Runner 3.12.0-beta1
- NUnit: 3.13.0
- NUnit3TestAdapter: 4.0.0-beta.1
When I compile my tests with TargetFramework “netcoreapp3.1”, the console works fine.
When I compile my tests with TargetFramework “net5.0”, the console cannot execute them.
This is the output:
NUnit Console Runner 3.12.0-beta1
Copyright (c) 2020 Charlie Poole, Rob Prouse
Friday, January 8, 2021 2:17:14 PM
Runtime Environment
OS Version: Microsoft Windows 10.0.19042
Runtime: .NET Core 3.1.10
Test Files
.\MyTests.dll
Errors, Failures and Warnings
1) Invalid : MyTests.dll
Unable to load one or more of the requested types.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
----> Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Run Settings
DisposeRunners: True
WorkDirectory: path\to\src\bin\Debug\net5.0
NumberOfTestWorkers: 4
Test Run Summary
Overall result: Failed
Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2021-01-08 17:17:14Z
End time: 2021-01-08 17:17:14Z
Duration: 0.169 seconds
Looking the console output I see the runner is using “Runtime: .NET Core 3.1.10”. I cannot find an option in command line to change this (maybe it is not detecting correctly yet?). I tested adding the parameter --framework=net5.0, but it outputs:
The framework= option is not available on this platform.
My questions:
- Is it expected? The NUnit Console Runner is not ready to .net5 yet?
- If it is not expected, what I’m doing wrong and what I can do to fix it?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 27 (15 by maintainers)
@oysteinkrog You can run using the windows variant of .NET 5 by navigating to
{YOUR_PATH}/.nuget\packages\nunit.consolerunner.netcore\3.12.0-beta2\tools\netcoreapp3.1\any\nunit3-console.runtimeconfigand changing it to"runtimeOptions": { "tfm": "net5.0", "framework": { "name": "Microsoft.WindowsDesktop.App", "version": "5.0.0" } }This should fix the issue you were having.FYI… the GUI now has a .NET 5.0 agent.
As you saw, there are currently two runners, one for .NET Framework and another for .NET Core. I initially thought you might be using the wrong one, but you talked about running the dotnet command, so I figured you were not.
Having two runners is probably not a long term solution, because some folks will want to run projects that include both framework and core test assemblies. However, it’s where we are right now.
If you want to try using a GUI, I invite you to look at my TestCentric GUI, which takes the approach of a single runner with multiple agents. Unfortunately, I haven’t yet published a .NET 5.0 agent.
Both projects are looking at decoupling agents from the engine in the future, so they become pluggable.
If @ChrisMaddock, who wrote the .NET Core runner, jumps in here, you can just ignore me, since I’m focused on other areas. But here’s what seems to be happening.
-fx-versionoption.Hope that’s clear. I’m about 90% sure it’s right 😕 because what you are doing is not exactly what we do in our own tests. We don’t yet have a 5.0 build, so we are running 3.1 tests under 5.0. IOW, YMMV. 😄
The output displayed indicates that the console runner itself targets .net core 3.1. So too does the engine used by the runner. However, it says nothing about the process in which your tests are running.
When we build the runner, we actually run tests under .NET 5.0, if it is installed. However, it’s possible that the beta-1 release is still not able to handle that. I suggest trying the latest
-devpre-release on our myget feed.@ChrisMaddock you probably have a more complete answer for this than I do.