Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

After upgrade | OmniSharp fails to load the Assembly-CSharp.csproj from a Unity project

Discussion in 'Editor & General Support' started by RowdyCoder, Dec 14, 2018.

  1. RowdyCoder

    RowdyCoder

    Joined:
    Jun 24, 2015
    Posts:
    28
    Hello All,

    I just upgraded to 2018.3.0f2. Now I no longer have access to intellisense capabilities via the C# extension for VS Code (OmniSharp).

    The Error:
    =========================================
    [info]: OmniSharp.MSBuild.ProjectManager
    Loading project: d:\Documents\GameDevelopment\UnityProjects\SimpleShooter\Assembly-CSharp.csproj
    [fail]: OmniSharp.MSBuild.ProjectLoader

    The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
    [warn]: OmniSharp.MSBuild.ProjectManager
    Failed to load project
    file 'd:\Documents\GameDevelopment\UnityProjects\SimpleShooter\Assembly-CSharp.csproj'...

    [fail]: OmniSharp.MSBuild.ProjectManager
    Attempted to update project that is not loaded: d:\Documents\GameDevelopment\UnityProjects\SimpleShooter\Assembly-CSharp.csproj

    =========================================


    My current workaround was simply to point to the targeting pack I have installed which is currently v4.6.1. In doing so everything works as expected.

    However, Unity overwrites the target framework value in the project file every time I open a script file or reopen the project. So it's frustrating to constantly have to manually reset the targeting version.

    My Current Version:


    What Unity Defaults back to:


    Any ideas as to how I can get the csproj file to maintain the targeting version I've given it? Or is there a better solution at solving this issue?

    My environment is Windows 10.



    TL;DR
    Upgrading to the latest version of Unity broke my .NET framework compatibility with VSCode for Unity projects. The only way to get VSCode to work with Omnisharp + Unity is to manually add the targeting framework to the csproj file every time I open a file or a project.

    I'm looking for a solution or a better workaround.

    Thanks in advance.
     
  2. RowdyCoder

    RowdyCoder

    Joined:
    Jun 24, 2015
    Posts:
    28
    Quick update:

    So I took the nuclear option and uninstalled everything i.e, Unity, VSCode, All .NET frameworks, etc.

    Reinstalled Unity. Then reinstalled VSCode.

    Now it's defaulting to a targeting framework of v4.7.1 and things appear to work as long as I open up the actual root of the Unity project folder when VSCode is launched...go figure.

    Whatever...it's better than what I was dealing with...I can live with it.
     
  3. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    Having the same issue. I just did a fresh re-install of Windows 10 Pro and thus Unity, VSCode, etc. but still not working. I will continue using Visual Studio Community Edition for the time being, but I really wanted to switch to VSCode to get all those juicy plugins.
     
  4. Stephen_O

    Stephen_O

    Joined:
    Jun 8, 2013
    Posts:
    1,510
    This was frustrating.. I guess it all stems from an actual 4.5 download not being available.. so we'll need to rename our 4.5.2 install.

    I fixed the bug by downloading .NET Framework 4.5.2 developer pack from here: https://dotnet.microsoft.com/download/dotnet-framework/net452

    Then after that, go to:
    `Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework`
    And rename the `v4.5.2` folder to `v4.5`.

    I figured out the last step from https://github.com/Unity-Technologies/vscode-unity-debug/issues/115 thanks to Ennothan's comment.
     
  5. CosmoPolite

    CosmoPolite

    Joined:
    Dec 13, 2016
    Posts:
    2
    Thanks a lot. Running into a similiar issue with Unity 2018.3.8f1.

    On Windows 10 only .NET Framework 4.7.2 is installed but OmniSharp wants 4.7.1.

    Copying the folder
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2
    to the new folder
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1
    is the working workaround.
     
  6. rohitvishwakarma1819

    rohitvishwakarma1819

    Joined:
    Feb 15, 2018
    Posts:
    14

    I solved this problem by trying this solution-

    1. Open Visual Studio Community(if you don't have, install it)

    2. Go to your unity Project folder

    3. There will be a file like -- 'YOUR_PROJECT_NAME.sln'

    4. Double click that file and choose to open in Visual Studio Community

    5. It will load your solution file

    6. Then it will show you a window saying unity is target to .net vsxxx and this is not installed in your computer. With 2 options
      a. Download that .net framework version
      b. change target .net framework version

    7. Download the missing .net framework version by clicking the option

    8. Restart Unity and vscode
     
    Samoajoe666, CoughE, Chastom and 3 others like this.
  7. CultHero77

    CultHero77

    Joined:
    Oct 22, 2019
    Posts:
    7
    Prid13, Lyje, acecase and 1 other person like this.
  8. acecase

    acecase

    Joined:
    Mar 16, 2014
    Posts:
    7
    This. It's actually a simple issue of a missing framework/devpack version. Just need to install it.
     
    Prid13 likes this.
  9. asqewfcq2egf

    asqewfcq2egf

    Joined:
    Nov 16, 2018
    Posts:
    15
    Last edited: Feb 13, 2020
  10. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    WixGames likes this.
  11. ShadowPam

    ShadowPam

    Joined:
    Sep 4, 2017
    Posts:
    1
    THANK YOU!

    I've been trying to make this work for 5h now and finally after scouring many many websites this reply fixes everything.
     
  12. studentutu

    studentutu

    Joined:
    Oct 22, 2017
    Posts:
    105
    Quick Update - if you are using VSCODe - don't forget to generate .csproj for packages! It will fix the problem Editor-> Preferences -> External Tools mark everything under Generate ..csproj files for
     
    gareth_withVR and samarth-robo like this.
  13. Desoxi

    Desoxi

    Joined:
    Apr 12, 2015
    Posts:
    195
    In case you have this issue with Visual Studio Code: Try to use the global mono version by changing this setting in VSCode: omnisharp.useGlobalMono": "always"

    The default seems to be "auto" but setting it to always and doing an upgrade to the newest mono version via https://www.mono-project.com/download/stable/ helped me to overcome this issue.

    EDIT: Also, I started visual studio once and made all updates VS told me to do (.net etc. etc.). I think this can help you to be up to date instead of using thousands of links to download this and that. But don't forget to change the default editor back to VSCode in unity after that.
     
  14. vishk197420

    vishk197420

    Joined:
    Nov 14, 2018
    Posts:
    1
    replace
    <TargetFrameworkVersion>v(YOUR VERSION)</TargetFrameworkVersion>
    to
    <TargetFrameworkVersion>v4.8(OR VERSION YOU INSTALLED .NET)</TargetFrameworkVersion>

    in the files Assembly-Csharp.csproj
    and others unity .csproj FILES 1.png
     
    over18years likes this.
  15. over18years

    over18years

    Joined:
    Aug 26, 2020
    Posts:
    1
    Hello, i saw your issue and if you still has this problem so this is solution.
    a.PNG
    You can see this version number in your output in the terminal. So you just need go to forlder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
    and change any version lastest become "v4.5"
    I tried and fixed it
     
  16. samarth-robo

    samarth-robo

    Joined:
    Aug 13, 2020
    Posts:
    4
    Thanks for this! My VSCode setup on MacOS was working fine for built-in Unity stuff but was not finding the MLAgents package. This fixed it.
     
  17. Yasmine010101

    Yasmine010101

    Joined:
    Mar 7, 2021
    Posts:
    1
    Thank you, it works for me, just change the name of the file with the current version of SDK
     
  18. Lioncio

    Lioncio

    Joined:
    Apr 11, 2021
    Posts:
    1

    IT'S WORKS!!! THANKS BRO. I just copy and paste my current version of dotnet which
    are version v4.8 and I copied it to the same directory and change the name to v4.7.1
    because vscode required dotnet framework of version 4.7.1 always.
     
    Last edited: Jun 29, 2021
  19. faculoyarte

    faculoyarte

    Joined:
    Nov 1, 2018
    Posts:
    3
    I solved the problem installing the .NET Framework X.X.X developer pack that my Assembly-CSharp TargetVersion said:
    https://dotnet.microsoft.com/download/dotnet-framework/netXXX <= change xxx with YOUR number. Reopen VSCode.
     
    GrammerPancreas likes this.
  20. cognalog

    cognalog

    Joined:
    Dec 28, 2017
    Posts:
    1
    I turned off omnisharp.useModernNet, and that fixed my unity+vscode setup completely, whereas before I had that same csproj-loading issue.
     
  21. DarkSealer

    DarkSealer

    Joined:
    Nov 24, 2015
    Posts:
    10
    yeah... turning off omnisharp.useModernNet does not work for me. I get the same error with or without it turned on.
     
  22. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,951
    KillDashNine likes this.
  23. Mshary

    Mshary

    Joined:
    Jan 20, 2014
    Posts:
    1
    Turning off useModernNet for OmniSharp in Settings and restarting VS Code solved it for me. This was after installing the correct version of .NET Framework (v4.7.1 for me) using the link in the C# logs.

    Thanks for the help everyone!