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

Console fails against assembly relying on "Microsoft.AspNetCore.App" - incorrect runtimeconfig.json #1400

Closed
bthharper opened this issue May 17, 2024 · 1 comment

Comments

@bthharper
Copy link

Using "nunit-console3" to run unit tests for .NET 8.0 assemblies that require the "Microsoft.AspNetCore.App" framework fails with the following error:

Results (nunit3) saved as TestResult.xml
PS C:\git\common> C:\Platform\nunit.console\net8.0\nunit3-console.exe C:/git/common/Source/Framework.Test/bin/x64/Debug/Framework.Test.dll
NUnit Console 3.17.0+685c5b542b5e9ba632c905f0bd514a773d9758af (Release)
Copyright (c) 2022 Charlie Poole, Rob Prouse
17 May 2024 23:56:17

Runtime Environment
   OS Version: Microsoft Windows 10.0.22631
  Runtime: .NET 8.0.5

Test Files
    C:/git/common/Source/Framework.Test/bin/x64/Debug/Framework.Test.dll


Errors, Failures and Warnings

1) Invalid : C:/git/common/Source/Framework.Test/bin/x64/Debug/Framework.Test.dll
Unable to load one or more of the requested types.
Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
  ----> Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.Microsoft.AspNetCore.App

The workaround was to change the nunit3-comsole.runtimeconfig.json in the net8.0 folder to:

{
  "runtimeOptions": {
    "tfm": "net8.0",
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "8.0.0"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "8.0.0"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "8.0.0"
      }
    ],
    "configProperties": {
      "System.Reflection.NullabilityInfoContext.IsSupported": true,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

I would rather not have to modify the distribution of nunit3-console to make this work if possible, is there another solution I have missed for this?

As an aside, I am unable to use dotnet test as this does not work when the solution contains C++/CLI vcxproj - which is something Microsoft seem reluctant to fix.

@bthharper
Copy link
Author

Closed as I have just seen #1392.

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