I create a Winform project with c# in VS2022 with target framework '.net 6.0', target OS: windows with minimum OS version 7. I want to "Unit Test" the project, so I add a new unit test project to the solution and when I reference the AppUpdate project to the unit test project (under dependencies of the unit test project, right clic, add project reference, add AppUpdate) show an exclamation mark(!) and when I build the solution give me this error:
Severity Code Description Project File Line Suppression State Error Project '..\AppUpdate\AppUpdate.csproj' targets 'net6.0-windows'. It cannot be referenced by a project that targets '.NETCoreApp,Version=v6.0'. ServerUpdateTest C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 1806
I try different kind of unit test project, but is always the same. The projects templates I have tried are:
- xUnit test project
- MSTest test project
- Unit Test Project (.NET Framework)
I found something similar but is not the same problem: Your project does not reference ".NETFramework,Version=v4.6.2" framework. Add a reference to ".NETFramework,Version=v4.6.2" in the "TargetFrameworks"