question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.Net Framework tests fails when .Net 8 is present on system

See original GitHub issue

I have a project that targets both .Net 7 and .Net Framework 4.7.2.

I installed the .Net 8 alpha for an unrelated purpose, and unit tests for .Net Framework will no longer run.

Using: NUnit 3.13.3 NUnit3TestAdapter 4.3.1 .Net 7.0.102 and .Net Framework 4.7.2

Projects global.json:

{
	"sdk": {
		"allowPrerelease": false,
		"version": "7.0.100",
		"rollForward": "latestMinor"
	}
}

Installed SDKs


PS C:\r\MyProject> dotnet --list-sdks
3.1.426 [C:\Program Files\dotnet\sdk]
6.0.100-rc.2.21505.57 [C:\Program Files\dotnet\sdk]
6.0.103 [C:\Program Files\dotnet\sdk]
6.0.113 [C:\Program Files\dotnet\sdk]
6.0.308 [C:\Program Files\dotnet\sdk]
6.0.405 [C:\Program Files\dotnet\sdk]
7.0.100-rc.2.22477.23 [C:\Program Files\dotnet\sdk]
7.0.101 [C:\Program Files\dotnet\sdk]
7.0.102 [C:\Program Files\dotnet\sdk]
8.0.100-alpha.1.23059.8 [C:\Program Files\dotnet\sdk]

Requested version is correctly used

PS C:\r\MyProject> dotnet --version
7.0.102

NUnit to run with .Net 8 anyway?

PS C:\r\MyProject> dotnet test MyProject\Tests\bin\Tests.dll
Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Exception System.TypeInitializationException,    Exception thrown executing tests in C:\r\MyProject\Tests\bin\Tests.dll
The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
   at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
   at NUnit.Engine.Services.RuntimeFrameworkService.SelectRuntimeFramework(TestPackage package)
   at NUnit.Engine.Runners.MasterTestRunner.GetEngineRunner()
   at NUnit.Engine.Runners.MasterTestRunner.Explore(TestFilter filter)
   at NUnit.VisualStudio.TestAdapter.NUnitEngine.NUnitEngineAdapter.Explore(TestFilter filter) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnitEngine\NUnitEngineAdapter.cs:line 97
   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, IGrouping`2 testCases, TestFilter filter) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 282
InnerException: System.ArgumentException: Unknown framework version 8.0
Parameter name: version
   at NUnit.Engine.RuntimeFramework.GetClrVersionForFramework(Version frameworkVersion)
   at NUnit.Engine.RuntimeFramework..ctor(RuntimeType runtime, Version version, String profile)
   at NUnit.Engine.RuntimeFramework.GetNetCoreRuntimesFromDirectoryNames(IEnumerable`1 dirNames)
   at NUnit.Engine.RuntimeFramework.FindDotNetCoreFrameworks()
   at NUnit.Engine.RuntimeFramework.get_AvailableFrameworks()
   at NUnit.Engine.Services.RuntimeFrameworkService..cctor()
No test is available in C:\r\MyProject\Tests\bin\Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Additionally, path to test adapters can be specified using /TestAdapterPath command. Example  /TestAdapterPath:<pathToCustomAdapters>.

Expectation: Tests run with the sdk and runtime defined by the project, regardless of which unrelated sdks might be present on the system.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tkvalvikcommented, Feb 24, 2023

Ran the test suites on a mixed .Net 7 and .Net Framework 4.7.2-project.

“Works on my machine”

1reaction
OsirisTerjecommented, Feb 23, 2023

@tkvalvik @madelson Version 4.4.0-beta.1 is out now https://www.nuget.org/packages/NUnit3TestAdapter/4.4.0-beta.1 . It includes support for .net 8. Appreciate it if you have the time to verify it works as it should. Once verification is done, the non-beta will be published.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot .NET Framework targeting errors
This article provides resolutions for MSBuild errors that might occur because of reference issues.
Read more >
Visual Studio unable to run .NET Core tests
My test project's Target framework is .NET Core 2.1, so to run the tests it needed to look in the x64 folder path....
Read more >
.NET core vs .NET framework
Wondering about the difference between .NET Core & .NET Framework? Here's a quick guide on how to pick the right runtime environment for...
Read more >
too particular about .NET Core runtime version
Looking at the Tests output window pane, I see this: Testhost process exited with error: It was not possible to find any compatible...
Read more >
Please stop lying about .NET Standard 2.0 support!
In this post I have a bit of a rant about Microsoft's NuGet packages lying about supporting .NET Standard 2.0 when they kinda...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found