Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How to change VSCode's TargetFrameworkVersion

Discussion in 'External Tools' started by zIyaGtVm, Dec 17, 2018.

  1. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    106
    Hi, I just installed Unity2018.3 and reinstalled VisualStudio 2017 with frameworkVersion 4.7.1.

    When I create a script in unity and open it by VSCode, errors turn out:
    Then I found VSCode changed Assembly-CSharp.csproj automatically.
    Even though I tried to open new script in VS2017 first, VSCode will reset it from v4.7.1 to v4.5.:confused:

    Anyone knows how to avoid this?Thanks!

    Unity version 2018.3.0f2
    VScode versio 1.30.0
     
  2. StevenDelrue

    StevenDelrue

    Joined:
    Aug 21, 2014
    Posts:
    16
    You can manually set the framework to 4.7.1 in the project-file and the error will be gone.
    But the csproj-file gets regerenerated each time you reopen the project, so it's quite annoying :/ Would be nice if you manually set the Target Framework Version in Unity
     
  3. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    106
    Yes I manually set the framework to 4.7.1 in the project-file by texteditor, and it gets regerenerated.
    Would you tell me where to set the Target Framework Version in Unity?Thanks!
    u.png
     
  4. tantonxhx

    tantonxhx

    Joined:
    Jul 5, 2017
    Posts:
    2
  5. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    106
  6. tantonxhx

    tantonxhx

    Joined:
    Jul 5, 2017
    Posts:
    2
  7. zIyaGtVm

    zIyaGtVm

    Joined:
    Dec 27, 2017
    Posts:
    106
  8. StevenDelrue

    StevenDelrue

    Joined:
    Aug 21, 2014
    Posts:
    16
    I reinstalled visual studio community (studio, not code) with the .net frameworks and the error is gone now
     
  9. rainssong

    rainssong

    Joined:
    Nov 6, 2013
    Posts:
    7
    set .proj as read only
     
  10. rainssong

    rainssong

    Joined:
    Nov 6, 2013
    Posts:
    7
    it's useless...
     
  11. rainssong

    rainssong

    Joined:
    Nov 6, 2013
    Posts:
    7
  12. Halcomb

    Halcomb

    Joined:
    Jan 23, 2020
    Posts:
    3
    You can edit a Visual Studio C++ project file to target different versions of the C++ platform toolset, the Windows SDK and the .NET Framework (C++/CLI projects only). By default, the project system uses the .NET Framework version and the auto clicker toolset version that correspond to the version of Visual Studio that you use to create the project. You can modify all these values in the .vcxproj file so that you can use the same code base for every compilation target.
     
    Last edited: Jan 31, 2020
  13. SirIntruder

    SirIntruder

    Joined:
    Aug 16, 2013
    Posts:
    43
    Having plenty of experience with this, one thing that seems to work most reliably is to go:

    VS Installer -> dropdown next to your latest VS installation -> Modify -> Individual components tab -> install all missing targeting packs (see attached screenshot)

    Unlike manual installation of sdks, this just seems to work.

    If you see 4.5.1 installed and it still doesn't work, it's likely there are multiple VS installations on your pc, and system is looking up another installation of Visual Studio. Get rid of all old Visual Studio installations and make sure the ones you use have needed targeting packs
     

    Attached Files:

    • vs.png
      vs.png
      File size:
      72.4 KB
      Views:
      359
  14. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    437
    INSANE SOLUTION YOU WON'T BELIEVE IF ON MAC

    1. Download Rider (no, really)

    2. Install the Rider package manager inside Unity

    3. Probably restart every electronic device in your house

    4. Launch Unity, set the external script editor as Rider - launch

    5. Use Rider a few times, save, change files etc.

    6. Quit RIder and Unity

    7. Launch Unity - set the external script editor back to VSCode

    8. In the Project panel, double-click on a c# file, VSCode will open

    THE PROBLEM IS FIXED, VSCODE NOW WORKS

    WTF? Hope it saves someone some hours
     
  15. tbngrd

    tbngrd

    Joined:
    Jul 25, 2018
    Posts:
    5
    WTF indeed - from all the solutions online this is the only one that worked perfectly for me. Thank you so much!

    Now what do we do if it happens again and the Rider trial version is over? Lol.
     
  16. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    437
    @tbngrd it's a good question !

    I THINK the same applies if you actually use visual studio ... so I will try having both VS, and VSCode on my machine. I will "change to" VS when the problem arises!

    By the way on my machines, every single time I happen to add a new C# file, the VSCode system breaks, and I have to do the Rider Trick. What a fiasco :/

    the whole thing is so stupid .. wake up, Unity ..
     
unityunity