简体   繁体   中英

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:

在此输入图像描述

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.

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

你可以在mac中使用visual studio 2017

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM