Net6.0-windows(Winform project) cannot be referenced by .NETCore-App,Version=6.0(Xunit project)
See original GitHub issueDescribe the bug
A clear and concise description of what the bug is. When I use an xunit project to test winform project, But it will throws a NU1201 error
To Reproduce
This bug is easy to reproduce. Just create a winform project and xunit via visual studio 2022, and then add winform project reference to xunit project.
Exceptions (if any)
NU1201 Project WinFormsApp1 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Project WinFormsApp1 supports: net6.0-windows7.0 (.NETCoreApp,Version=v6.0)
Project '..\WinFormsApp1\WinFormsApp1.csproj' targets 'net6.0-windows'. It cannot be referenced by a project that targets '.NETCoreApp,Version=v6.0'. TestProject1 C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 1806
Further technical details
- Visual studio 2022 17.2.4
- winform and xunit projects are both created by vs
- dotnet sdk version 6.0.301
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
Add reference project winform to my unit test ...
the solution is go to properties of the Unit Test project and change the target SO to Windows and version to 7. and...
Read more >NU1201: xUnit project not compatible with .Net 5 WinForms ...
I have a .Net 5 WinForms Control library (Windows 10, Visual Studio 2019) and want to add some unit tests for the non-UI...
Read more >Cannot Add Reference To XUnit Test Project
Usually test projects are created as standalone libraries. You don't add references to them. You just run the tests straight out of them ......
Read more >Getting a "could not be found" from the unit test project
I've made some changes to a ASP.NET MVC Core (.NET 6) solution. There's two projects; the MVC project and a xUnit test.
Read more >Getting started: .NET Core with command line > xUnit.net
Getting Started with xUnit.net. Using .NET Core with the .NET SDK command line. In this article, we will demonstrate getting started with xUnit.net...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was able to resolve this by doing the following: Select the target project to test (the main app or a library usually) Press ALT-ENTER to open the project file. Note the version of windows being targeted.
Select the xUnit (or NUnit) test project. Press ALT-ENTER to open the project file. The Windows version is probably not selected. Select an OS to target.
That fixed the problem for me with NUnit and xUnit.
Spydee
Oh gawd. This works.