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.
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.
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.
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.
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.
Open Visual Studio Community(if you don’t have, install it)
Go to your unity Project folder
There will be a file like – ‘YOUR_PROJECT_NAME.sln’
Double click that file and choose to open in Visual Studio Community
It will load your solution file
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
Download the missing .net framework version by clicking the option
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
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 Download - Stable | Mono 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.
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
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.