0

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:

  1. xUnit test project
  2. MSTest test project
  3. 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"

1 Answers1

1

My project 'AppUpdate' have the target to minimal SO 'Win 7' and all the unit test templates have target to any SO.

the solution is go to properties of the Unit Test project and change the target SO to Windows and version to 7.

and that will make the unit test to work property.

Cheers.