Visual Studio Code无法在Unity3D安装Ubuntu上找到.Net Framework

乔纳斯·沃格特(Jonas Voigt)

我最近将操作系统从Windows切换到了Ubuntu 20.04。在对Unity3D安装进行了一些麻烦之后,我尝试为Unity编码安装Visual Studio Code。

问题:

通过在Unity3D中按“打开C#项目”来启动Visual Studio代码时,我收到一条错误消息(末尾为完整错误消息):

[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for .NETFramework,Version=v4.7.1 were not found.
        To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework 
        version or retarget your application. You can download .NET Framework Developer
        Packs at https://aka.ms/msbuild/developerpacks

之后,我可以编辑代码,但是IntelliSense for Unity(也许还有一些我还没有注意到的东西)不起作用

我尝试过的内容:

  • 安装.NETFramework 4.7.1版:我不知道为什么,但是4.X版不适用于Linux。因此,这将不是一个选择。
  • 修改Assembly-CSharp.csproj文件:当改变TargetFrameworkVersion我的当前安装的版本的SDK(3.1.401)或框架的版本(3.1.7),我会得到同样的错误消息。修改其他标签也无济于事。此外,每次Unity启动Visual Studio Code时,文件都会重置。
  • 重新启动,重新安装Visual Studio,重新安装Unity,重置Ubuntu
  • 按照其他一些论坛的建议安装Mono。我真的不知道单声道是什么或做什么,所以也许我在这里做错了...

起作用的东西:

  • dotnet new Console创建一个C#Hello World项目该项目可以通过Visual Studio Code打开,编译并运行,没有任何问题。如果需要,我可以提供该项目的一些文件。

  • 运行Mono测试。

  • Unity确实会编译代码并完全正常运行。

可能令人感兴趣的东西:

我如何安装应用程序:

  • Unity:我正在使用从官方网站下载的Appimage文件
  • .Net:我遵循了教程
  • Visual Studio代码:通过Ubuntu软件
  • 单声道:我已经按照这些步骤进行了

.Net安装

 Version:   3.1.401
 Commit:    39d17847db

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

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

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

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

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

单声道安装

Mono JIT compiler version 6.10.0.104 (tarball Fri Jun 26 19:38:44 UTC 2020)
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 
    Interpreter:   yes
    LLVM:          yes(610)
    Suspend:       hybrid
    GC:            sgen (concurrent by default)

完整的错误信息

Starting OmniSharp server at 8/28/2020, 10:20:28 AM
    Target: /home/jonas/Documents/Unity/testproject/testproject.sln

OmniSharp server started.
    Path: /home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/run
    PID: 9757

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on ubuntu 20.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin
            CscToolPath = /home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/jonas/Documents/Unity/testproject'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/home/jonas/Documents/Unity/testproject/testproject.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/jonas/Documents/Unity/testproject/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/jonas/Documents/Unity/testproject'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/jonas/Documents/Unity/testproject/Assembly-CSharp.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/home/jonas/Documents/Unity/testproject' on host 9670.
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/jonas/Documents/Unity/testproject/Assembly-CSharp.csproj'.
/home/jonas/Documents/Unity/testproject/Assembly-CSharp.csproj
/home/jonas/.vscode/extensions/ms-dotnettools.csharp-1.23.1/.omnisharp/1.37.0/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1178,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /home/jonas/Documents/Unity/testproject/Assembly-CSharp.csproj

因为我是Ubuntu和Linux的新手,所以我可能无意中遗漏了重要的信息。请询问,我很乐意分享其他信息。感谢您的帮助

ardaboluk

这对我有用。

https://github.com/OmniSharp/omnisharp-vscode/issues/3351

我认为这里的主要问题是C#扩展正在更新。但这与VSCode使用的Mono版本不兼容。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

我如何使用Visual Studio Code在Ubuntu中开发Unity3D项目

Visual Studio 2015 Web应用程序.NET Core与.NET Framework

如何在未安装Visual Studio的情况下构建.NET 4.6 Framework应用程序?

通过Visual Studio 2010定位.NET Framework 4.5

Visual Studio 2012中缺少.net Framework 4.5.1

无法在Visual Studio项目属性中选择.NET Framework 4.6.1

在Ubuntu / Visual Studio Code上从.Net Core连接到SqlServer

无法在Visual Studio 2012 Ultimate上安装SSH.NET

如何获取Visual Studio 2017 Evaluation以识别已安装的.NET Framework 4.6.2?

在Windows Server 2016的Visual Studio安装程序中找不到.NET Framework 4.7目标包

如何将.NET Framework 3.5 SP1安装到Visual Studio 2017中

Visual Studio 2017不会在.NET标准库中加载.NET Framework参考

JSON.NET Visual Studio 2008和.NET 3.5 Compact Framework

Azure Function App无法在需要.NET Framework 4.7.1的Visual Studio 2017上运行

缺少.NET Framework模板Visual Studio 2017

NET Framework版本与Visual Studio包的兼容性

Visual Studio无法定位.NET Framework 4.8

Visual Studio 2019 C#Windows Forms App(.NET Framework)-没有View Designer或View Code

.NET Framework 4.0 Targeting Pack在Visual Studio中不显示

Visual Studio 2010无法识别.NET Framework 4.0.3

Visual Studio无法识别已安装.NET Framework 4.6.2

Visual Studio 2013 on .NET Framework 4.5.2

.NET Framework 4.5.2上的Visual Studio 2013

Visual Studio安装程序安装程序项目将不正确的.net Framework版本检测为依赖项

在Visual Studio 2013上定位.NET Core

使用Visual Studio和.NET Framework进行多目标构建

Visual Studio无法连接到Unity3D iPhone

在 Visual Studio 中选择 .Net Framework 版本

无法在 Visual Studio Build Framework 中选择 .NET Core 3.0