nunit3-vs-adapter: System.ArgumentException: Unknown framework version 7.0

Hello, I’m getting System.ArgumentException: Unknown framework version 7.0 when trying to use nunit on .net framework project:

PS D:\devdiv\vscodecoverage> dotnet --version
7.0.100-preview.4.22252.9
PS D:\devdiv\vscodecoverage> dotnet test .\artifacts\bin\Microsoft.CodeCoverage.Console.Common.Tests\Release\net48\Microsoft.CodeCoverage.Console.Common.Tests.dll
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220414-05 (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 D:\devdiv\vscodecoverage\.\artifacts\bin\Microsoft.CodeCoverage.Console.Common.Tests\Release\net48\Microsoft.CodeCoverage.Console.Common.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 88
   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 275
InnerException: System.ArgumentException: Unknown framework version 7.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.FindAvailableFrameworks()
   at NUnit.Engine.RuntimeFramework.get_AvailableFrameworks()
   at NUnit.Engine.Services.RuntimeFrameworkService..cctor()
No test is available in D:\devdiv\vscodecoverage\.\artifacts\bin\Microsoft.CodeCoverage.Console.Common.Tests\Release\net48\Microsoft.CodeCoverage.Console.Common.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>.

This is probably related to https://github.com/nunit/nunit-console/issues/1176 but I’m using vstest.console and adapter.

I’m using:

    <NUnitVersion>3.13.3</NUnitVersion>
    <NUnitTestAdapterVersion>4.2.1</NUnitTestAdapterVersion>

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 37 (27 by maintainers)

Commits related to this issue

Most upvoted comments

Upgrade NUnit3TestAdapter to 4.3.1 and the tests should work

I think it is better to follow the advice in documentation:😃

The NUnit3TestAdapter is the best place to start.

Nunit is working fine using NUnit3TestAdapter v4.3.0 in net7 and old frameworks.

Sorry to be late for the party. Since I don’t work on the adapter any longer, I don’t usually see issues that arise. Also, I’m on vacation. 😃

The engine does not yet support tests, which target .NET 7, but that does not seem to be the issue here. It is supposed to run .NET 5.0 tests successfully, even if the only version installed is 7.0.

However, in order to run at all, the engine needs to find out what runtimes are installed on the machine. It does that before it even tries to load your tests, by looking at the names of install directories. We have had problems in the past with preview releases creating directories with odd names. This was fixed in 3.15, by ignoring directories, whose names did not have the form of a version number. If you only have a preview release with a non-standard directory name, then the engine will think you have no runtimes capable of handling .NET 5 or .NET 6 as well.

OTOH if you have (for example) .NET 6 installed instead, it should work.

Currently, I test possible engine problems using a sequence like this…

  1. If I think it may be a framework problem, I run the tests using NUnitLite, so the engine isn’t involved.
  2. If they run all right under NUnitLite, I test with the console. The console obviously adds things to the engine, but it is closer to it and many things are simply passed through to the user directly. I can debug in the engine to see what’s happening, up to the point where a separate process is launched.
  3. If the problem is in the agent process, I have to use a pretty tedious debugging approach, by attaching to the agent. This works but takes a lot of time.
  4. Note that I do not mention TestCentric GUI, which I see mentioned in some other threads. That is because the GUI uses the TestCentric engine, which is a different engine from NUnit’s. That’s something to be resolved eventually, but the resolution is complicated because the GUI went a different way during the years when I didn’t work on NUnit at all. So, as a general rule, please don’t try to understand what NUnit is doing by using the GUI.

@OsirisTerje Thanks for the new version and fix. I test NUnit3TestAdapter" Version="4.3.0-alpha-net7.4" , and it and it’s working fine in net45…net48, net5.0, net6.0, net7.0, even with using net7 7.0.100-preview.5.22307.18. 👍

nunit2

Also, It’s working fine using CLI dotnet test

Click to show dotnet test!
 

  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
C:\Program Files\dotnet\sdk\7.0.100-preview.5.22307.18\Sdks\Microsoft.NET.Sdk\targets
\Microsoft.NET.RuntimeIdentifierInference.targets(219,5): message NETSDK1057: You are
 using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users
\mohha\source\repos\MyProject.Test\MyProject.Test\MyProject.Test.csproj]
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net45\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net48\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net472\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net461\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net5.0\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net7.0\MyProject.Test.dll
  MyProject.Test -> C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Deb
ug\net6.0\MyProject.Test.dll
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net7
.0\MyProject.Test.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 33 m
s - MyProject.Test.dll (net7.0)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net6
.0\MyProject.Test.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 27 m
s - MyProject.Test.dll (net6.0)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net5
.0\MyProject.Test.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 29 m
s - MyProject.Test.dll (net5.0)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net4
5\MyProject.Test.dll (.NETFramework,Version=v4.5)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 108 
ms - MyProject.Test.dll (net45)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net4
72\MyProject.Test.dll (.NETFramework,Version=v4.7.2)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 108 
ms - MyProject.Test.dll (net472)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net4
8\MyProject.Test.dll (.NETFramework,Version=v4.8)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 108 
ms - MyProject.Test.dll (net48)
Test run for C:\Users\mohha\source\repos\MyProject.Test\MyProject.Test\bin\Debug\net4
61\MyProject.Test.dll (.NETFramework,Version=v4.6.1)
Microsoft (R) Test Execution Command Line Tool Version 17.3.0-preview-20220523-03 (x6
4)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 105 
ms - MyProject.Test.dll (net461)


@jakubch1 @moh-hassan I found the missing link in the engine, and have uploaded a new adapter package https://www.nuget.org/packages/NUnit3TestAdapter/4.3.0-alpha-net7.4

The Issue project above now works:

image

Please verify this with your solutions.

@CharliePoole I’ll upload a PR to the console/engine project rsn.

@OsirisTerje

  1. This is not the net 7 issue, is it ?

yes, It’s FullFramework issue, .NET45 up to .NET48 The issue is only with NUnit3TestAdapter version v4.2.0 and above. It is fine in lower version NUnit3TestAdapter version v4.1.0.

The error is InnerException: System.ArgumentException: Unknown framework version 7.0 In netcore net5.0, net6.0 it’s Fine with all NUnit3TestAdapter versions.

I used global.json to control dotnet and it has no effect.

I have the next sdk versions installed including net7 preview5

dotnet --list-sdks

2.0.0 [C:\Program Files\dotnet\sdk]
2.1.818 [C:\Program Files\dotnet\sdk]
3.1.420 [C:\Program Files\dotnet\sdk]
5.0.403 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]
6.0.106 [C:\Program Files\dotnet\sdk]
6.0.202 [C:\Program Files\dotnet\sdk]
6.0.203 [C:\Program Files\dotnet\sdk]
6.0.301 [C:\Program Files\dotnet\sdk]
7.0.100-preview.5.22307.18 [C:\Program Files\dotnet\sdk]

The error is the same, either using vs 2022 v 17.2.5 or using dotnet test.

@jakubch1 Version 4.3.0 with .net 7 support is released now

Probably better to take over the info. I’ll do a final update to that post pointing to your copy.