'Incompatible Target Framework on Visual Studio Community

I`ve been trying to make a unit test in my project following this tutorial: https://docs.microsoft.com/en-us/visualstudio/test/walkthrough-creating-and-running-unit-tests-for-managed-code?view=vs-2019

But when I try to reference my project on step 5 shows this:

"Project(Incompatible target framework: .NETFramework, version=v4.7)"

Anyone has found a solution?

First of all, Thanks.



Solution 1:[1]

I just faced a similar issue. I was developing from a macbook and I notice when you start a new project, somehow by default it starts with .Net Framework and when you add a unit test (MSTest in my case) it sets it from .Net Core and the two are just not compatible targets as it says.

How I solved this is, at the start of the new project, I select under Web and Console -> App ->Console Application (since you are doing a console app from the shared link). Then when I hit next, I am given the option to select a target framework. There I select .Net Core and go on with other processes. Then when I added my unit test from there it worked with no issues.

Try that lets see if it works for you as well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mw509