nunit3-console doesn't see DLLs from Microsoft.AspNETCore.App

24 views Asked by At

When I run UTs from Visual Studio all runs fine but when I need to run it with nunit3-console My.Tests.dll I see FileNotFoundException like this

Could not load file or assembly 'System.Security.Cryptography.Xml, ...

I see them only for DLLs from Microsoft.AspNETCore.App folder, DLLs from Microsoft.NETCore.App are loaded fine.

The test file

[Test]
public void Test1()
{
    Assembly.Load("System.Security.Cryptography.Xml, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51");
}

If I explicitly load then tests run fine

Assembly.LoadFrom("C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\8.0.0\\System.Security.Cryptography.Xml.dll");
1

There are 1 answers

0
Shahar Shokrani On

Look like its an inner issue with NUNIT3-CONSOLE's how the runtime locates assemblies, read about it here.

It can be solve easily with using the dotner cli with dotnet test.

If you must use it (would be happy to know why), you can try to modify the runtime configuration. [YourTestAssembly].runtimeconfig.json something like:

{
  "runtimeOptions": {
    "tfm": "netcoreapp3.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "3.1.0"
    },
}

Change the target verion number.