Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Visual Studio Problem

Discussion in 'Editor & General Support' started by ZoltanBSF, Dec 7, 2017.

  1. ZoltanBSF

    ZoltanBSF

    Joined:
    Jul 25, 2017
    Posts:
    3
    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.
     
  2. ZoltanBSF

    ZoltanBSF

    Joined:
    Jul 25, 2017
    Posts:
    3
    I updated to Unity 2017.2.0f3 and the problem persists.
     
  3. liangcheng1984

    liangcheng1984

    Joined:
    Dec 7, 2017
    Posts:
    1
    Sean_bi and StartStart like this.
  4. ZoltanBSF

    ZoltanBSF

    Joined:
    Jul 25, 2017
    Posts:
    3
  5. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    259
  6. wcoastsands

    wcoastsands

    Joined:
    Sep 30, 2011
    Posts:
    25
    @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:
    1. Select Update if the option is available (as it is in your screenshot).
    2. Allow the update and install process to complete.
    3. Select Modify to edit your install.
    4. Select the Individual components tab.
    5. Scroll down to the Code Tools section.
    6. Check the box for NuGet package manager.
    7. Select Modify to add the missing component.
    That fixed the issue for me.

    Screenshot 2017-12-09 09.58.06.png
     
    Last edited: Dec 9, 2017
    ModLunar, Sean_bi, Mr-Knieves and 7 others like this.
  7. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    259
    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.
     
    Last edited: Dec 9, 2017
    wcoastsands likes this.
  8. evilangel89

    evilangel89

    Joined:
    Feb 8, 2017
    Posts:
    268
    wcoastsands likes this.
  9. geumyong

    geumyong

    Joined:
    Dec 12, 2017
    Posts:
    2
    @starikcetin Thank you. Your answer was a great help to me!
     
    starikcetin likes this.
  10. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    111
  11. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    307
    Thanks as well, @liangcheng1984 -- fixed my issue also. This was driving my bonkers with 15.5 VS and 2017.3f2 Unity.
     
  12. Mr-Knieves

    Mr-Knieves

    Joined:
    Mar 7, 2013
    Posts:
    41
    Ah nice! This also fixed the same issue I was having on vscode!
     
  13. CptBubbleButt

    CptBubbleButt

    Joined:
    Apr 24, 2018
    Posts:
    26
    Found new the resolution for this problem also:
    1. Go to File
    2. 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.
     
  14. elguilledigital

    elguilledigital

    Joined:
    Feb 1, 2017
    Posts:
    1
    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!!
     
  15. VLukianenko

    VLukianenko

    Joined:
    Mar 27, 2017
    Posts:
    29
    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?
     
    NinjaBanter likes this.
  16. Westerhof

    Westerhof

    Joined:
    Apr 29, 2017
    Posts:
    1
    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.
     
    devstudents likes this.
  17. devstudents

    devstudents

    Joined:
    Feb 18, 2014
    Posts:
    132
    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.
     
  18. unity_NoHCP6Hv0SSIyg

    unity_NoHCP6Hv0SSIyg

    Joined:
    Mar 28, 2019
    Posts:
    2
    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
     
  19. Rostagnat

    Rostagnat

    Joined:
    Nov 2, 2019
    Posts:
    1
    Thanks for this answer !
    To everybody who does have NuGet installed and stil having this issue : THIS WORKED.