I’m running Unity 2017.1.2f1. When I open a C# file in Visual Studio Community 2017 (15.5.0) and try to build the solution, I get a bunch of weird errors, for example:
The “GetReferenceNearestTargetFrameworkTask” task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is “public” and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin” directory.
Also, many components are reported by VS as not found, like:
The referenced component ‘UnityEngine’ could not be found.
What if NuGet package manager is already installed, but this still happens? There’s a lot of voodoo dancing involved to temporary fix this - manually adding files to solution, attaching VS to Unity, restarting everything - but it’s so annoying… Is there a solution that would prevent that from happening permanently?
I had this problem with Visual Studio 2019 and Unity 2019.2.a
Fixed it by going into Unity > Edit > Preferences > External Tools > and manually selecting Visual Studio 2019 from the drop-down menu.
After that my scripts where recognized again in Visual Studio.
Yep that did if for me too in visual studio 2017 and unity 2019.1.3. I can probably try using the newest Unity now that I know this problem has an easy fix.