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

Cannot execute .NET 8 tests that require the Desktop or ASP.NET runtime #1383

Open
mlessmann opened this issue Jan 15, 2024 · 3 comments
Open

Comments

@mlessmann
Copy link

mlessmann commented Jan 15, 2024

Executing a .NET 8 test assembly that references types from WinForms, WPF, or ASP.NET results in the following (or similar) exception:
Could not load file or assembly 'System.Windows.Forms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e89'. The system cannot find the file specified.

The reason is that the nunit-agent only references the Microsoft.NETCore.App runtime in its runtimeconfig.json. Therefore a workaround is to manually add the missing runtimes (Microsoft.WindowsDesktop.App and/or Microsoft.AspNetCore.App) to the runtimeconfig.json.

As far as I know adding the WindowsDesktop runtime will lead to the agent no longer working on Linux. Ideally we could load the necessary runtimes dynamically depending on what dependencies the test assembly has, though I have no idea if that is even possible. The Microsoft documentation does not sound promising.

@ilCosmico
Copy link

ilCosmico commented Feb 13, 2024

The error occurs when the Microsoft.Windows.Compatibility package is added to the project.

Here is a repro
NUnitTestProject1.zip

@ilCosmico
Copy link

@OsirisTerje Any news on this?

@OsirisTerje
Copy link
Member

@ilCosmico No, we don't have anyone working here at the moment.

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

3 participants