未找到框架“.NETFramework,Version=v4.7.1”的参考程序集

Posted

技术标签:

【中文标题】未找到框架“.NETFramework,Version=v4.7.1”的参考程序集【英文标题】:Reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found 【发布时间】:2019-01-26 17:35:21 【问题描述】:

我尝试在 Linux (Ubuntu 18.10) 下使用 VSCode 打开 Unity3D 项目。 omn​​isharp 扩展不加载项目,说没有找到程序集。

这似乎很愚蠢,但我还没有真正习惯.Net,而且我已经被这个错误困扰了好几天了。 我一直在尝试重新安装 dotnet(甚至使用 snap 包)、mono、vscode 和omnisharp 扩展。

欢迎任何帮助! :)

Unity 版本:2018.3.1f1

日志:

dotnet -- 信息

.NET Core SDK (reflecting any global.json):
 Version:   2.2.103
 Commit:    8edbc2570a

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.10
 OS Platform: Linux
 RID:         ubuntu.18.10-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.103/

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  2.2.103 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

单--版本

Mono JIT compiler version 4.6.2 (Debian 4.6.2.7+dfsg-1ubuntu1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen

完整的日志错误:

    Starting OmniSharp server at 1/26/2019, 7:13:55 PM
    Target: /home/eyap/Projects/Unity/TestProject/TestProject.sln

OmniSharp server started.
    Path: /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run
    PID: 30136

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on ubuntu 18.10 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild
            BypassFrameworkInstallChecks = true
            CscToolPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin
            TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/eyap/Projects/Unity/TestProject'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/home/eyap/Projects/Unity/TestProject/TestProject.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/eyap/Projects/Unity/TestProject'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/home/eyap/Projects/Unity/TestProject' on host 30056.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        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.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj'.
/home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj
/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/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.

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj

【问题讨论】:

【参考方案1】:

尝试了这里提到的步骤,没有解决错误。必须将omnisharp.useGlobalMono 选项更改为always。这适用于C# extension for VS Code=1.23.2

来源:Reddit Post

您的错误输出告诉我您正在使用官方 C# 扩展 对于 VS 代码。所述扩展的最新版本 1.23.2 具有此功能 在其更新日志中说:

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". This

在 Mono 升级其捆绑的 MSBuild 版本之前需要

默认设置自动不起作用。将其切换为始终和 重新启动扩展。或者,您可以降级到 1.23.1。

【讨论】:

这在 VSCode 1.49.1、Unity 2020.1.6f1 和 Mono 6.10.0 Stable 上对我有用,无需修改 PATH 或任何环境变量 在这一步之后,我终于让我的 Intellisense 像魅力一样工作了。绝对让我开心,谢谢!! 你是我的英雄,这拯救了我的夜晚! 我在这里,一年半后,再次发现此错误。这一次,这个解决方案对我很有用!谢谢:) 在 Mac 上 -> 代码 -> 首选项 -> 设置 -> 输入“使用全局单声道”,将配置更新为始终。【参考方案2】:

我有同样的问题,但在 OSX 上。安装最新版本的 Mono 清除了缺失的 .net v4.7.1 框架参考。

我从https://www.mono-project.com/download/stable安装了Mono V5.18.0

更新:请参阅下面有关全局全锐化设置的评论

【讨论】:

可能就是这样!我之前安装了单声道,就像他们在他们的网站上描述的那样,但我错误地认为它是最新的。但 Ubuntu 18.10 并非如此(它仍在 4.6 中)......我明天会尝试,非常感谢! 这对我有用。我猜我安装的最后一个 Unity 更新将所需的版本号提高到超过 Ubuntu Apt 源提供的版本号。 '''sudo apt upgrade mono-devel'''。当前最新版本是 6.10 我有最新的 Mono,但我仍然遇到这个问题。 可以在 Ubuntu 18.04 上确认这项工作。非常感谢!【参考方案3】:

我遇到了同样的情况,我在这里找到了解决方法:https://github.com/Microsoft/msbuild/issues/2728

您必须export FrameworkPathOverride=/lib/mono/4.5 并且会找到 .NETFramework。

【讨论】:

感谢您的回答。在 macOS 上为我工作。将该变量添加到我的 shell 配置中。 您在哪里输入导出行? Unity 或 VS Code 是如何知道如何找到该导出的? 这对我有用:export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current 这正是问题所在,你拯救了我的一天,谢谢【参考方案4】:

我遇到了同样的问题,这是我如何解决的。

    从here 下载最新的稳定版 Mono 并安装。

    将 FrameworkPathOverride 添加到 .bash_profile

export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current

重启 VSCode 就可以了。

【讨论】:

【参考方案5】:

    在 linux mint 18.3 Sylvia (ubuntu 16.04) 中安装 mono-devel,如 https://www.mono-project.com/download/stable/#download-lin。

    然后在终端执行export FrameworkPathOverride=/etc/mono/4.5

    打开 vs 代码并运行。

【讨论】:

安装最新的mono 对我没有帮助。但是导出解决了问题,谢谢!【参考方案6】:

在 Linux mint 18.3 Sylvia (Ubuntu 16.04) 中安装 mono-devel,如 https://www.mono-project.com/download/stable/#download-lin。 然后在终端执行

export FrameworkPathOverride=/etc/mono/4.5

打开 VScode 就可以了。这对我来说是全新安装 Ubuntu 20.04 的方法。

【讨论】:

【参考方案7】:

经过一天研究出了什么问题。在 ubuntu 和 unity 上使用 .NETFRAMEWORK 4.7。我通过将 omnisharp:useglobalmenu 更改为始终在 VSCODE 设置中解决了这个问题。这是我找到的解决方案链接https://github.com/OmniSharp/omnisharp-vscode/issues/3613#issuecomment-677451385

【讨论】:

以上是关于未找到框架“.NETFramework,Version=v4.7.1”的参考程序集的主要内容,如果未能解决你的问题,请参考以下文章

框架 Firebase 未找到 Swift [重复]

未找到 AppleTalk 框架

ld:未找到框架 DTXProfiler

Django Rest 框架 - “详细信息”:“未找到。”

如何播放特定频率和框架的声音未找到音频单元问题

Django REST 框架 http 404 详细信息”:“未找到。”