Hi, 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 <UsingTask> 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. Any help would be greatly appreciated.
https://developercommunity.visualst...oken-getreferencenearesttargetframeworkt.html Start Visual Studio Installer again. On the Build Tools 2017, click Modify, Ensure that "Nuget targets and build tasks" are ticked. Press Modify to complete.
Hi, I don't have an entry named "Build Tools 2017" in my Visual Studio Installer. Here is a screenshot:
@starikcetin I was a little lost as well. Looks like the NuGet package manager wasn't installed. Steps to add the component using Visual Studio Installer 15.5.1: Select Update if the option is available (as it is in your screenshot). Allow the update and install process to complete. Select Modify to edit your install. Select the Individual components tab. Scroll down to the Code Tools section. Check the box for NuGet package manager. Select Modify to add the missing component. That fixed the issue for me.
Yep, this fixed the issue. Thank you very much. For future reference, the solution of @wcoastsands also fixes this other problem I've been facing: There are unresolved project references.
Thanks as well, @liangcheng1984 -- fixed my issue also. This was driving my bonkers with 15.5 VS and 2017.3f2 Unity.
Found new the resolution for this problem also: Go to File Move/[whatever you put this script (ie Asset\Scripts\[script name] to... Then it will show off your project location. Click on that and it will work.
having same issue with Unity 2018.2.16f1 and VS 2017 15.9.1 Solved when checked the NuGet package manager, explained by @liangcheng1984 and @wcoastsands thanks a lot guys!!
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.
I have done the following solutions you have suggested but still, I do get the same error can anyone help me with this. It is so annoying
Thanks for this answer ! To everybody who does have NuGet installed and stil having this issue : THIS WORKED.