Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUnit Adapter Fails to Load Test DLL When Target Windows Version in TFM Exceeds Host OS Version #1244

Open
simona-chiosa opened this issue Feb 27, 2025 · 0 comments

Comments

@simona-chiosa
Copy link

Hi,

I have encountered the following problem while working with the NUnit3TestAdapter in a .NET 8 desktop application.

Issue Summary

The NUnit Adapter fails to load test DLLs when the Windows version specified in the Target Framework Moniker (TFM) is higher than the host operating system version. This prevents test discovery and execution on older Windows environments.

Environment

  • .NET 8 desktop application using WinRT APIs
  • Target OS in TFM: Windows 10 version 1903 (10.0.18362)
  • NUnit 4.3.2
  • NUnit.Console 3.19.2
  • NUnit3TestAdapter 5.0.0
  • NunitXml.TestLogger 6.0.0
  • Microsoft.NET.Test.Sdk 17.13.0
  • Host OS: Windows Server 2019 (10.0.17763)

Steps to Reproduce

  1. Create a .NET 8 desktop application project targeting a specific Windows version:
    <TargetFramework>net8.0-windows10.0.18362.0</TargetFramework>
  2. Create an NUnit test project with the same TFM.
  3. Run the unit tests using dotnet test on a Windows OS environment with version lower than specified in the TFM. (e.g., Windows Server 2019 - 10.0.17763)

Expected Behavior

  • The test project DLL file is loaded and unit tests are discovered and executed normally.

Actual Behavior

  • The test project DLL fails to load, and consequently, the unit tests are not discovered.
    Output logs:
    NUnit Adapter 5.0.0.0: Test execution started Running all tests in C:\path\to\Common.Test.dll NUnit failed to load C:\path\to\Common.Test.dll NUnit Adapter 5.0.0.0: Test execution complete No test is available in C:\path\to\Common.Test.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Workarounds

I identified the following workarounds/solutions:

  1. Remove the specific Windows OS version from the TFM:
    <TargetFramework>net8.0-windows</TargetFramework>
  2. Change the TFM to match the build environment OS version:
    <TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
  3. Use xUnit instead of NUnit. The same project configuration with xUnit successfully loads the test DLL and executes tests with the same higher Windows version TFM.

Additional Context

The Common.Test.dll.deps.json file contains the same runtime pack references when using either NUnit or xUnit. Below is an example when targeting net8.0-windows10.0.18362.0:
"runtimepack.Microsoft.Windows.SDK.NET.Ref/10.0.18362.57": { "runtime": { "Microsoft.Windows.SDK.NET.dll": { "assemblyVersion": "10.0.18362.38", "fileVersion": "10.0.18362.55" }, "WinRT.Runtime.dll": { "assemblyVersion": "2.2.0.0", "fileVersion": "2.2.0.48161" } } }

Thank you for your attention to this issue. If anyone has encountered this problem before or has additional suggestions for workarounds, I'd appreciate your insights. I'm available to provide any further information that might help in resolving this compatibility issue.

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

No branches or pull requests

1 participant