I was recently trying to get into game development with Unity. I chose Visual Studio Code for my script editor. After trying to figure out why they would not work, I found that the C# build for VSC was having trouble installing. The console said to download the .NET Framework Version 4.7.1, which I tried, but the file type was only compatible for windows. Please Help!
Error: (File Location & Stuff) 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 .NET SDKs for Visual Studio.
Before the last curly brace â}â, add the following line: **"omnisharp.useGlobalMono": "always"**
Save the file and restart VS Code.
Now, when you edit a Unity script in VS Code, you will get full Intellisense functionality. Note that you have to be patient for a few seconds when VS Code loads while it starts Omniserver and loads the Mono Framework, but once it has, it works great.
Hi I did this as you suggested and thank you for that as the original error has now now been fixed however interstellar still those not work infact when I open up a script in unity c# commands donât work such as Console.WriteLine
go the the finder then you will find (Go) up in the task bar click it and then choose (Go to Folder) and type (library) and thats it navigate to Application Support/Code/User/settings.json
Iâve been struggling with this issue for years now, getting it fixed until it got broken again some time later over and over again and I already had the âomnisharp.useGlobalMonoâ: âalwaysâ line
For anyone still struggling with this, here is something I found in the documentation of the C# extension:
â âIf you still need Unity or .NET Framework support, you can set omnisharp.useModernNet to false in your VS Code settings and restart OmniSharp.â
That did it for me.
EDIT:
As I understand it, Mono seems to no longer be required with newer versions of Unity and OmniSharp no longer ships with Mono. If, like me, you are still using an older version of Unity, setting that variable to false will force the download of the appropriate Mono version.
Im on Unity 2020.1.1f1 but depending on your version of Unity, Mono may not be the cause of the issue. Therefore, adding that line to your settings.json may not be the fix youâre looking for considering this issue has been around for so long and there always seems to be a different fix.
Every time I load VS Code, I get the message âSome projects have trouble loading, Please review the output for more details.â
I am using VS Code 1.76.2 on a Mac running OS 10.15.7
TBH I am a total beginner; Iâm literally just trying to write my first ever code in a Unity project and I feel like I have to learn all of these things that are way beyond my skill level just to print âhello worldâ for the first time.
I vaguely recall struggling with this ages ago when I first downloaded unity and first set up VS Code. I have no idea WTF Mono is but I installed it. (I really hate installing software without having any idea what it is.) Iâm pretty sure I installed .NET Framework at that time too-- yet again, I have no idea what it is, and anytime I try to look up what any of these things are I just feel like I am baragged with a whole bunch of other terms and concepts I donât understand.
I just re? installed Mono, hoping that might fix it. Restarted my computer and restarted Unity and VS Code and got the same error message.
I think I already have .NET framework, maybe? I tried following the link posted above but it just took me to the page to install VS Code.
If I disable the C# extension in VS Code I donât get that error message.
With C# disabled or enabled, Unity autocomplete doesnât work, and I canât get the script to use Unity things⌠I donât know the technical term. Like it wonât recognize Time.deltaTime and will give me a compliing error if I try to use it.
Anyway, if anyone can give me the beginner-friendly version of what I need to do, I would really appreciate it. Sometimes game development feels like this walled-in circle of terms that if you donât already know what they mean there is no way to find out.
I already had Mono installed, but I reinstalled it anyway.
I already had .NET 6 SDK installed, but I reinstalled it anyway.
Restarted my computer both times just for good measure.
Still getting that damn error message.
Located the settings.json file. It already had âomnisharp.useGlobalMonoâ: âalwaysâ typed into it.
Still getting the stupid error message every time I load a Unity C# script in VS Code with the C# extension on.
Still wonât autocomplete Unity things (methods? I dunno wtf these things are called, sorry.) But it appears I can use Time.deltaTime in a script, VS Code just wonât recognize it.
Tried chaning it to âomnisharp.useGlobalMonoâ: âfalseâ Still got an error message.
Btw, for anyone else on a Mac who had the same problem locating the âCodeâ folder, go to your USER folder and find the Library folder in there, not your main startup disc Library folder
Hereâs the error message I keep getting. If anyone can help me figure out WTF this means, would really appreciate it
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (RedirectingâŚ) and that you are running the .NET Framework build of OmniSharp (e.g. âomnisharp.useModernNetâ: false in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file â/Users/saffo/Unity/Projects/Blank Project/Assembly-CSharp.csprojâ.
/Users/saffo/Unity/Projects/Blank Project/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/6.0.407/Microsoft.Common.CurrentVersion.targets(1220,5): Error: This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine (RedirectingâŚ) and that you are running the .NET Framework build of OmniSharp (e.g. âomnisharp.useModernNetâ: false in C# Extension for VS Code).
Okay, sorry everyone for all the melodramatics. (Although I do think that coding/ development can be a bit of a closed loop sometimes which is really frustrating.)
I finally figured out how to turn off that setting and it seems to have fixed both problems (the error messages and the failure to auto-complete.)
For anyone like me who is new to this stuff and gets freaked out, let me try and summarize what I did. In the end itâs not that different from what was suggested above, except I had to turn the âalwaysâ setting OFF for Use Modern Net.
If youâre on a Mac and having trouble with VS Code, getting that weird error message ^, or you are not getting unity auto-complete stuff showing up in your VS Code, try this:
Install Mono (I still have no idea what it is.)
Install .NET SDK (latest version)
Inside VS Code, type Command-Comma. There should be a little search bar insite the little settings tab that opens up. Type âomnisharp use modern netâ. Make sure to uncheck the little box that shows up. Save everything and quit both VS Code and Unity. Reopen them. When you reopen VS Code you might get a little message that itâs installing something.
Hopefully, once itâs installed, things will work.
I still have no idea WTF I just did, or what Mono or .NET are, or what the difference is between .NET SDK and .NET Framework. But somehow this seemed to work.