I have this problem only with Unity 2018.2.0f2.
I’m working on other projects in Unity 2017.4.5f1 and the problem does not exist there.
Whenever I open Visual Studio Code, Intellisense does not work at all, so the autocomplete doesn’t work, and VS Code doesn’t do stuff like automatically formatting code layout.
I’m having the same issue, and I’m getting this in the VSCode Output (seemingly related to the OmniSharp extension, but don’t know if the fault lays in that or elsewhere):
The reference assemblies for framework ".NETFramework,Version=v4.7.1" 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 'f:\Projects\*******\Assembly-CSharp.csproj'.
f:\Projects\*******\Assembly-CSharp.csproj
C:\Users\#######\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1126,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.7.1" 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.```
Nothing has changed in my environment, save for updating Unity from 2018.1.X to 2018.2.1f1; I had Intellisense with 2018.1 in the morning, updated to 2018.2 over lunch, and no Intellisense in the afternoon.
I've tried:
- Uninstalling & reinstalling VS Code.
- Reinstalling VS Code plugins.
- Checking/resetting Unity's script editor setting in Edit > Preferences > External Tools.
- Restarting PC
Hope this gets addressed soon... although on the positive side of things, this has shown me that I rely too much on Intellisense!
This seems to happen to me on and off… this is pretty annoying. I think I’ve got the exact same error message, but lately I’ve got a bit different I think.
if I close a project that has only few classes, then open Unity, I get the similar error and autocomplete doesn’t work in VS Code. If I restart unity, I get the same error. If I start a new project, I won’t. The same thing repeats.
This has happened at least with some 2018.x versions. I’ve got similar issues with OmniSharp and Atom, but I’ve since just used VS Code.
Problem:
Seems like VS code OmniSharp plugin tries to find some “stuff” related to msbuild - I have no idea what it is about. And seems like there are two copies of that folder, one in Visual Studio Community edition (that I installed along Unity) and one in VS Code folder.
For some reason OmniSharp decides to load the one in Visual Studio folder, which results in something missing. This or similar issue has been reported in OmniSharp’s github… but the solutions seem to be really esoteric, or I just missed the good ones.
Hacky solution:
Rename the Visual Studio msbuild folder to something else, like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild —> MSBuild.old
Warning:
This will most likely break the same feature in Visual Studio… but this is a fix for VS Code.
If someone has a better solution, I’d be interested, but OmniSharp not working is a problem.
If that was aimed at me, could you define what exactly I should download and install and so on?
I think I’ve read that before, and also tried installing something like that, but it didn’t help with this OmniSharp problem, but can’t remember exactly…
@eses I had this problem few weeks ago after I switched my project to use newer .net script runtime, and I fixed it by upgrading mono runtime to 5.14.
I’m on mac tho, but try installing the latest mono from their official site. https://www.mono-project.com/download/stable/
By reinstalling VS Code plugins I suppose you mean actual VS Code plugins and not the VS Code plugin from the Asset Store.
I had this problem twice. First time I fixed it by installing the Visual Studio Code asset from the Asset Store, which enables a full integration with Unity and VS Code. After installing it, remember going into Preference → VS Code → Enable Integration, and set Enable Integration to true.
If this is not the problem, then I must ask: do you have a .project, project.json and your_project_name.sln files?
I don’t remember which one -sorry - but one of them was definitely needed for Unity intellisense and stuff. So just check which one you don’t have and create it. I must add that you are not to create any of these files on your Assets folder, but on your project’s folder. Your file tree should look something like this:
I guess I have a bit different problem. I don’t / didn’t get error about anything missing. And it really seems to have something to do with VS Code just getting messed up between where to find MSBuild.
Renaming folder seems to be the only fix I found… as soon as I rename the folder back, I get the error in VS Code.
Also, Installing the latest mono didn’t change this, just tested.
I know the answer wasn’t aimed at me - but I’m just curious…
I don’t think you need to use any 3rd party asset store project specific asset to have full integration any more?
Also, what are .project and project.json files? I know very little about VS Code… I just use it, haven’t had time to dig into it. I don’t think we have such files - this is how newly created project looks like at least for me:
I believe the .project file is a file created by Visual Studio Code saving a project’s data, such as dependencies and build specifications. The project.json file is a project management file usually created automatically on projects when using a editor -such as VS or VS Code-, though its creation can be deactivated on the settings. If you want to take a look at what it is specifically,
take a look at that.
This files are in deed necessary to my project for intellisense to work. If I erase them Intellisense ceases to work, and if I regenerate them it works again. Same happens with the VS Code package from the Asset Store.
Anyhow, reading the post I made I clearly forgot to mention I work on Linux, so perhaps this requirements depend on the OS?