VS Code Error [SOLVED]

I suddenly got this warning today from VS Code of my Unity project I have been working for months making me unable to keep programming my c# scripts, because it no longer has autocompletes terms from Mono develop or any other c# words.

6227133--685065--upload_2020-8-20_16-27-21.png

It has something to do with Omnisharp. I found some things online but nothing seamed to work and it is a very confusing subject I don't seem to get.

Can someone help me with clear instructions please?

Not to sure about that error the output might help but for your auto complete woes there should be a hidden folder called .vs in your project folder. delete it and reload the project normally fixes missing autocomplete problems. If its unity wide then you need to set the external editor to visual studio in your project settings.

Erased the folder and restarted unity and it was not solved.

Also did set Visual Studio Code as the external editor again, just to make sure. That's the weird thing, I did that a long time ago and it was working just fine. It stopped working all of a sudden.

I think it's important to say I use a Mac

Parts of the error:

The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

Attempted to update project that is not loaded:

1 Like

This worked out for me. It automatically updated yesterday and it caused those conflicts.

https://github.com/OmniSharp/omnisharp-vscode/issues/3065

Yeah, I dealt with this quite a lot. VSCode is just a garbage IDE, It's the worst thing I've ever used.

  • Try deleting the .sln file in your project
  • (< Unity 2020.1) Try going into Preferences > External Editors > Generate all .csproj files
  • (>= Unity 2020.1) Try going into Preferences > External Editors > Should be a button called "Regenerate ..." or something similar, click it.
  • Open any script via double click

Or
- Revert C# extension to a previous version

Or
- Give up and switch to a new IDE if you don't have to use VSCode.

3 Likes

Thanks for the reply! Which IDE would you suggest?


I would love to know the answer to that question as well.

I heard people praising Ryder, but it's quite expensive. It does have a free trial for a month, I might check it out.
Stick to regular Visual Studio if you can though. VSCode is common because it's 100% free so all tech companies are going for it, but it's inexcusably unpolished.

1 Like

I just received this same issue, did not make any difference deleting and regenerating those project files.
It was only after I downgraded VSCode C# extension from 1.23.1 to 1.23.0 that it started to work again.

4 Likes

Same that Theos. After 1 hour trying to figure out a solution, the easiest thing to do was to downgrade to 1.23.0.

2 Likes

I ran into this problem too but got it worked out after jumping through some hoops. Like others here mentioned, it turned out to be an issue with Microsoft/OmniSharp's C# extension for VS Code.

Here's the full set of steps I ran through to fix it:

  • Close out Unity.
  • Delete all the VS Project files in your Unity project folder (.csproj, .sln, .vscode folder).
  • Open VS Code, hit Ctrl+Shift+P and type Disable Auto Updating Extensions. This will stop Microsoft from auto-updating C# to a broken version.
  • Find the C# extension in the list of your installed VS Code extensions, right click, then click "Install Another Version".
  • Select v1.23.0 and let it install.
  • Close out of VS Code.
  • Open your Unity project, and the VS Project files will automatically be rebuilt.
  • VS Code and Intellisense back to normal again.
7 Likes

I had a new breakage with VSC on linux this week.
One day all was fine, next day, suddenly, VSC complains about all refs to code placed inside Plugins folder.

In my case it seems Omnisharp was skip/ignoring the Assembly-CSharp-firstpass.csproj file.
Downgrading C# extension from 1.23.3 to 1.23.0 fixed it. Thank you all.

(Beware, looks like MS is pushing .Net CORE so hard, they are breaking stuff left and right.)

1 Like

omg thank you so much. I tried so many things and this finally fixed the issue :)

EDIT: There seem to be plenty of logged issues with the extension:
https://github.com/OmniSharp/omnisharp-vscode/issues

Thank you #TorchFireStudios and the rest, life savers you are! I clicked some update button without paying attention... boy, almost wasted a whole work day. MAN!

Problem: Open VS Code, namespaces are screwed in a way that doesn't have much logic +1K errors with messages like .csproj files not found where they definitely are found.. all sorts of trouble that also seems to jump from on issue to another between restarts without much logic to it. In addition VS Code eats CPU time like a starved baboon on steroids, I mean on a scale from 0=working to 10=heroin-overdose we are at 9.9 nuclear catastrophy.
Culprit: C# for Visual Studio Code 1.23.4 or .3 not even sure. This is the editor extension that understands C#.
Fix: Downgrade option doesn't exist. 1. Uninstall, 2. download manually 1.23.0 VSIX file, 3. find "Install from VSIX" option, 4. Enjoy life again. Oh and 5. I also run "Extensions: Disable Auto Updating Extensions", figure that's necessary to avoid this in the future.


Thanks, man! I struggled with this problem a lot and as it turns out, I forgot to do this.

1 Like

Got this problem after updating Unity LTS. (Unity 2019.4.20f0 -> f1). The 1.23.0 downgrade solution didn't work for me though.

After some more googling, came across this thread: https://discussions.unity.com/t/777413

So I tried just changing the External Script Editor in Unity preferences to 'open by file extension', then closing both Unity and VSCode, then reopening and selecting VSCode again. Now it seems to work as it should with latest version of C# extension

2 Likes

Downgrading to 1.23.0 solved the problem. Thanks a lot!

Update for anyone else that runs across this problem...

It turned out that this is a known compatibility issue between the C# extension in VS code, Mono/Omnisharp, and Unity. It's even listed prominently at the top of the C# extension's changelog:

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". The current value of "auto" will remain "never" until Mono [upgrades their bundled MSBuild version](https://github.com/mono/mono/issues/20250).

So instead of downgrading to 1.23.0 (which also works but is outdated), you can instead just use their recommended solution:

  • In VS Code, open Settings
  • Search for "omnisharp use global"
  • Change Omnisharp: Use Global Mono setting to: "always"

Then to make sure Unity recognizes the changes...

  • Close all Unity projects
  • Delete any .sln or .csproj files (Unity will recreate them)
  • Re-open a Unity project
  • Double click any script to have it open in VS code
  • Let the omnisharp compiler do its thing
  • Intellisense should now be working again
3 Likes

I did some digging as I was struggling with something similar; I posted an answer on StackOverflow here; I hope it helps someone.

this should be sticked somewhere in forum or thread created just for Vs code related problems :face_with_spiral_eyes:
1 Like

Today on Mac, with the C# plugin installed, latest VSCode Editor package installed in the package manager (v.1.2.5), and latest install of monodevelop installed on my machine, I only have omnisharp.monoPath, and no omnisharp.useGlobalMono setting. Am I missing a step, or has this setting been removed?

There was another fix on the forums which was to set omnisharp.useModernNet to false. This worked for a moment, but whenever I reopen VSC, I'm given a popup saying that I need to have a full install of mono. If I go back to the omnisharp settings, check the use modern net box, restart the editor, and then turn it off again, suddenly I'm back in business. But frankly, this isn't something I should have to put up with every time I want to edit code in Unity.
I love using VSC for almost everything, but when it comes to Unity it's been a constant sore spot for the 3 years I've tried using it off and on.