在Mac上使用.NET中的.NET 4.x.

cla*_*l3r 10 .net c# macos unity-game-engine visual-studio-code

如何在MAC上使用.NET 4.x 并使用VSCode作为编辑器!

我将这些设置设置为统一:

在此输入图像描述

在VScode中我收到以下错误:

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. 我找不到4.xmac的版本下载.

小智 21

如果可用,Omnisharp 默认使用 dotnet,这不足以满足您的需求。要使 omnisharp 使用 mono(随需要的配置文件一起提供),您需要:

  1. 安装 mono 5.8 或更高版本。我建议使用自制软件安装:brew install mono
  2. 在VSCode的用户设置文件,强制omn​​isharp使用全局单安装:"omnisharp.useGlobalMono": "always"auto

VSCode 中的输出应该显示类似

[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"
Run Code Online (Sandbox Code Playgroud)

如果执行此操作后它仍然抱怨(假设它选择了错误的单声道安装),您还可以通过设置强制 omnisharp 使用自制软件的单声道

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

或单声道的特定安装

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

  • 谢谢。安装单声道并将“omnisharp.useGlobalMono”首选项从“自动”更改为“始终”在 VIsual Studio Code 中是我需要的修复。 (2认同)

Jin*_*kur -1

到这里下载这个 https://www.microsoft.com/net/download

对于 mac osx 也可能缺少一些环境变量。尝试重新安装。