NU1201: xUnit project not compatible with .Net 5 WinForms project

I have a .Net 5 WinForms Control library (Windows 10, Visual Studio 2019) and want to add some unit tests for the non-UI classes. After adding an xUnit project and referencing my library I get this error:

error NU1201: Project WinFormsControlLibrary1 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Project WinFormsControlLibrary1 supports: net5.0-windows7.0 (.NETCoreApp,Version=v5.0)

This happens because the WinForms library targets .Net 5 Windows, which is more specific than general .Net 5.

I fix this by double-clicking the unit test project (in solution explorer) and editing the target framework from:




Then, close my project and Visual Studio, and re-open it. (This gives VS2019 a chance to figure what’s going on!) Now the project compiles and I can create and run unit tests.

Note: The Target Framework, shown in the project properties page, is now blank:

So I select .Net 5, close the page, and look again at the project JSON file – now the target framework has changed to:


What’s the difference? I think, nothing! Although at some point I’m sure this will change. More information here:

One thought on “NU1201: xUnit project not compatible with .Net 5 WinForms project

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s