Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using .NET 4.x in Unity on a Mac

How can you use .NET 4.x on a MAC and use VSCode as the editor!

I have those settings set in unity:

enter image description here

In VScode I get the following 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. Failed to load project file '/Data/unity_learn/RIG/Assembly-CSharp.csproj'. /Data/unity_learn/RIG/Assembly-CSharp.csproj /Users/doekewartena/.vscode/extensions/ms-vscode.csharp-1.16.0/.omnisharp/1.32.4/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1195,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. I can't find a download for 4.x version for the mac.

like image 836
clankill3r Avatar asked Sep 12 '18 13:09

clankill3r


People also ask

Can I use C# and Unity on a Mac?

Build your next game or real-time 3D Unity application with best-in-class debugging, C# support, and productivity tools included in Visual Studio for Mac.

Which .NET framework should I use for Unity?

By default, most Unity projects should use the . NET Standard 2.0 profile.

Can I use .NET in Unity?

Unity uses the open-source . NET platform to ensure that applications you make with Unity can run on a wide variety of different hardware configurations. The . NET platform supports a range of languages and API libraries.

What .NET version does Unity 2021 use?

NET Standard 2.1 support in Unity 2021 LTS enables us to start modernizing the Unity runtime in a number of ways.


1 Answers

Omnisharp defaults to using dotnet if it's available, which isn't enough for what you need. To make omnisharp use mono (which comes with the needed profiles), you'll need to:

  1. Install mono 5.8 or greater. I recommend installing with homebrew: brew install mono
  2. In VSCode's user settings file, force omnisharp to use the global mono installation: "omnisharp.useGlobalMono": "always" (auto

The output in VSCode should show something like

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Located 2 MSBuild instance(s)
        1: Mono 15.0 - "/usr/local/lib/mono/msbuild/15.0/bin"
        2: StandAlone 15.0 - "/Users/x/vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Registered MSBuild instance: Mono 15.0 - "/usr/local/lib/mono/msbuild/15.0/bin"

If it still complains after doing this (if, let's say, it picks the wrong mono installation), you can also force omnisharp to use homebrew's mono by setting

"omnisharp.monoPath": "/usr/local/"

or a specific installation of mono with

"omnisharp.monoPath": "/usr/local/Cellar/mono/5.14.0.177/"

like image 169
Andreia Gaita Avatar answered Sep 27 '22 03:09

Andreia Gaita