【问题标题】:Using .NET 4.x in Unity on a Mac在 Mac 上的 Unity 中使用 .NET 4.x
【发布时间】:2019-02-17 04:24:26
【问题描述】:

如何在 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. 我找不到适用于 mac 的 4.x 版本的下载。

【问题讨论】:

标签: c# .net macos unity3d visual-studio-code


【解决方案1】:

如果可用,Omnisharp 默认使用 dotnet,这不足以满足您的需求。要使omnisharp 使用单声道(所需的配置文件附带),您需要:

  1. 安装单声道 5.8 或更高版本。我建议使用自制软件安装:brew install mono
  2. 在VSCode的用户设置文件中,强制omnisharp使用全局单声道安装:"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"

如果这样做后仍然报错(假设它选择了错误的单声道安装),您也可以通过设置强制omnisharp使用自制软件的单声道

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

或特定的单声道安装

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

【讨论】:

  • "安装单声道 5.8 或更高版本。"你的意思是5.18?我找不到更高的东西。
  • 这就是我们所有人的答案!甚至适用于 .NET 7.1.3
  • 谢谢。在 VIsual Studio Code 中安装单声道并将“omnisharp.useGlobalMono”首选项从“自动”更改为“始终”是我需要的修复程序。
  • 此解决方案也适用于 Linux。谢谢!
  • 这在 2021 年仍然适用于我在 MacOSX 和 Unity 上
【解决方案2】:

你必须使用 .NET Core 而不是 .NET Framework,核心只有 2.1

不幸的是,请查看另一个类似的问题。

here

前两个答案会告诉你你需要知道什么。

【讨论】:

    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      • 2020-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多