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
- Refactor project files, update test libs for current vs2022 support - Fix bug where constants were squashed in .csproj by prefixing with '$(DefineConstants);' - Use simpler SDK format for Tests proje... — committed to arcutright/osu-diffcalc by arcutright 2 years ago
- Update IronPythonTest.csproj Fix "System.ArgumentException: Unknown framework version 7.0" in step Test (net462) Reference: https://github.com/nunit/nunit3-vs-adapter/issues/987 — committed to scott-xu/ironpython3 by scott-xu 2 years ago
- Update IronPythonTest.csproj (#1603) * Update IronPythonTest.csproj Fix "System.ArgumentException: Unknown framework version 7.0" in step Test (net462) Reference: https://github.com/nunit/nunit3-... — committed to IronLanguages/ironpython3 by scott-xu 2 years ago
- To fix this issue https://github.com/nunit/nunit3-vs-adapter/issues/987 — committed to OctopusDeploy/Halibut by nathanwoctopusdeploy a year ago
- Tests: update NUnit3TestAdapter This should fix issues like https://github.com/nunit/nunit3-vs-adapter/issues/987 — committed to JetBrains/rd by ForNeVeR 7 months ago
- Tests: update NUnit3TestAdapter This should fix issues like https://github.com/nunit/nunit3-vs-adapter/issues/987 — committed to JetBrains/rd by ForNeVeR 7 months ago
Upgrade NUnit3TestAdapter to 4.3.1 and the tests should work
I think it is better to follow the advice in documentation:😃
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…
@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 net77.0.100-preview.5.22307.18. 👍Also, It’s working fine using CLI
dotnet testClick to show dotnet test!
@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:
Please verify this with your solutions.
@CharliePoole I’ll upload a PR to the console/engine project rsn.
@OsirisTerje
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.0In 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
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.