15

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.

2
  • visualstudio.microsoft.com/vs/mac Commented Sep 18, 2018 at 14:09
  • unfortunately VS code is very limited support to .Net Framework projects, see here for some workarounds Commented Sep 25, 2018 at 8:10

3 Answers 3

23

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

Sign up to request clarification or add additional context in comments.

4 Comments

"Install mono 5.8 or greater." do you mean 5.18? I could not find anything higher.
This right here is the answer for all of us! Works even with .NET 7.1.3
THANK YOU. Installing mono and changing the "omnisharp.useGlobalMono" preference from "auto" to "always" in VIsual Studio Code was the fix I needed.
this still worked for me on MacOSX and Unity in 2021
0

you have to use the .NET Core not the .NET Framework, core is only at 2.1

check out this other similar question, unfortunately.

here

the first two answers will tell you what you need to know.

Comments

-1

go here and download this https://www.microsoft.com/net/download

for mac osx It may be some environment variable missing too. Try reinstalling.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.