Visual Studio Code Intellisense doesn't work with Unity 2018

Hello!

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.

Can anyone please help?

I’ve tried:

  • Uninstalling & reinstalling VS Code.
  • Reinstalling VS Code plugins.
  • Checking/resetting Unity’s script editor setting in Edit > Preferences > External Tools.

EDIT! - the solution that worked for me is in this post .
I simply had to install .NET Framework 4.7.1.

8 Likes

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!
1 Like

I’m having the same issue … I tried the same solutions above but nothing seems to work. Waiting for a fix.

Hey Anyone got a solution for this?

Re-install visual basic 2017, it worked for me.

I’ve fixed it changing to .NET 3.5 in my project (File → Build Settings → Player Settings). I had .NET 4.x before.

3636946--296761--Capture.PNG

7 Likes

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.

updating your mono runtime should fix it

@DylanYasen

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…

I’m on Windows 10.

@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/

1 Like

@DylanYasen

Well now that I checked what I did, I had installed “mono-5.4.1.6-x64-0.msi” from that site as a fix… but it didn’t help a thing.

So maybe it’s a bit earlier version.

Do I have to just install this one, not anything special?

I just tested it on my Windows machine. If you open your project with visual studio, it should notify you the missing .net framwork version

3644461--297715--snip.PNG

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 :slight_smile: - 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:


1 Like

@DylanYasen - Not working for me.

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.

Hi @santiagolopezpereyra

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:

Hi @eses

Sorry for the delayed response.

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?

Hey everyone, a colleague helped me fix this. I too had the error listed above in the VS Code output log…

.NETFramework,Version=v4.7.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version

The solution was simply to a) read the error and b) follow its instructions XD

How I fixed it…

After that, Intellisense worked fine in a project that was formerly broken. This is in Unity 2018.2.7f1 on Windows 10.

Hope that helps others with the same issue. Check the VS Code log when it warns you!

20 Likes

@CrowbarSka I did read the error and follow its instructions hahaha it didn’t fix it then, and it didn’t fix it now with 2018.2.10f2 either!

For me, Intellisense still is not working.

Sorry to hear that, not sure what to suggest if you have installed .NET Framework 4.7.1 and it’s still not working as that step solved it for me :confused:

To fix the issue

  1. Download and install Microsoft’s .NET Framework SDK any version with start 4.X from .NET SDKs for Visual Studio
  2. In VS Code, open ‘Assembly_CSharp.csproj’ file and change ‘TargetFrameworkVersion’ to what you installed .NET Framework SDK version
  3. And done! :slight_smile:
4 Likes