带有 vscode 和 C# 扩展的 Ubuntu 19.10 上的 Unity3D:出现错误并且自动完成功能不起作用

Posted

技术标签:

【中文标题】带有 vscode 和 C# 扩展的 Ubuntu 19.10 上的 Unity3D:出现错误并且自动完成功能不起作用【英文标题】:Unity3D on Ubuntu 19.10 with vscode and C# extension : get an error and the autocomplete doesn't working 【发布时间】:2020-07-14 19:55:39 【问题描述】:

我是一名 Web 开发人员 (symfony

Ubuntu 19.10 上,我下载了 unity Hub v2.3.0 (https://unity3d.com/get-unity/download)

我从 unity hub 安装了 unity3D v2019.3.7f1(最新稳定版)和一些选项(Linux & WebGL & windows build support

我创建了一个简单的 2D 游戏

一切都像魅力一样,我可以在 unity3D 控制台中打开我的项目并运行我的新游戏而不会出现任何错误

在 Unity 中,当我创建一个 c# 脚本时,可以通过我的(非常简单的)文本编辑器 gedit 打开该文件。现在我想安装跨操作系统的 IDE 可视化代码,谢谢,当我编辑我的统一脚本时,我会得到一些有用的扩展和自动完成代码。

所以,我通过apt install 安装了vscode(我遵循了这个官方指南:https://code.visualstudio.com/docs/setup/linux)

我的 vscode 版本是:

经过一些网络搜索,我知道我必须安装 .NET 框架(也许我错了?)

我的 dotnet 版本(来自终端:dotnet --version)是 3.1.201

接下来我配置了统一参数以更改默认文本编辑器:

外部脚本编辑器:代码 code指路径/usr/bin/code,vscode的可执行文件 外部脚本编辑器参数:"$(ProjectPath)" -g "$(File)":$(Line):$(Column) 默认值,我什么都没改

我从 unity 创建了一个简单的 c# 脚本,我打开文件并自动打开 vscode(是的!)。从 vscode 我添加了两个公共变量(bool 'a' 和 Rigidbody2D 'b')

我保存了我的脚本并转到unity app,变量a和b在界面上可见:

所有作品! 但是现在,我想要来自 vscode 的自动完成代码。所以,我安装了 vscode c# 扩展。但是当安装完成时,会出现这条消息:

整个日志是:

Starting OmniSharp server at 4/2/2020, 8:10:51 PM
    Target: /home/okli/UnityProjects/SampleGame/SampleGame.sln

OmniSharp server started.
    Path: /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/run
    PID: 15372

[info]: OmniSharp.Stdio.Host
    Starting OmniSharp on ubuntu 19.10 (x64)
[info]: OmniSharp.Services.DotNetCliService
    DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Located 1 MSBuild instance(s)
        1: StandAlone 16.4 - "/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    MSBUILD_EXE_PATH environment variable set to '/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Registered MSBuild instance: StandAlone 16.4 - "/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin
        CscToolPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
    Detecting Cake files in '/home/okli/UnityProjects/SampleGame'.
[info]: OmniSharp.Cake.CakeProjectSystem
    Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
    Detecting projects in '/home/okli/UnityProjects/SampleGame/SampleGame.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
    Queue project update for '/home/okli/UnityProjects/SampleGame/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
    Detecting CSX files in '/home/okli/UnityProjects/SampleGame'.
[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.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.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
    Configuration finished.
[info]: OmniSharp.Stdio.Host
    Omnisharp server running using Stdio at location '/home/okli/UnityProjects/SampleGame' on host 14406.
[info]: OmniSharp.MSBuild.ProjectManager
    Loading project: /home/okli/UnityProjects/SampleGame/Assembly-CSharp.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.Timeline.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Animation.Runtime.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.PixelPerfect.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.VSCode.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.SpriteShape.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.TextMeshPro.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Path.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'UnityEngine.UI.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.Timeline.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Animation.Triangle.Runtime.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'PsdPlugin.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.CollabProxy.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.Rider.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.Mathematics.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Psdimporter.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.InternalAPIEngineBridge.001.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Sprite.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Common.Runtime.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Tilemap.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.SpriteShape.Runtime.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.PixelPerfect.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Animation.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.Mathematics.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.TextMeshPro.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.2D.Common.Editor.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'Unity.InternalAPIEditorBridge.001.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'UnityEditor.UI.csproj' does not exist.
[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/okli/UnityProjects/SampleGame/Assembly-CSharp.csproj'.
/home/okli/UnityProjects/SampleGame/Assembly-CSharp.csproj
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.Timeline.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Animation.Runtime.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.PixelPerfect.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.VSCode.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.SpriteShape.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.TextMeshPro.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Path.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'UnityEngine.UI.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.Timeline.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Animation.Triangle.Runtime.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'PsdPlugin.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.CollabProxy.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.Rider.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.Mathematics.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Psdimporter.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.InternalAPIEngineBridge.001.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Sprite.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Common.Runtime.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Tilemap.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.SpriteShape.Runtime.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.PixelPerfect.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Animation.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.Mathematics.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.TextMeshPro.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.2D.Common.Editor.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'Unity.InternalAPIEditorBridge.001.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1870,5): Error: The referenced project 'UnityEditor.UI.csproj' does not exist.
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,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/okli/UnityProjects/SampleGame/Assembly-CSharp.csproj

有些东西似乎不起作用......但是,我可以修改并保存我的 c# 脚本(例如添加一个新的公共 var,该变量是在统一界面中添加的),但是自动完成代码不起作用,当我输入 public Rigidbod 并按 ctrl + space 不会显示任何自动完成帮助。

我不熟悉 C#/vscode/microsoft 技术,如果我忘记了什么和/或在尝试(坏)解决方案之前做错了什么,我更喜欢在这里问

感谢您的帮助!

编辑:我刚刚在 unity3D 界面上通知了这个错误

我会搜索一下这个错误...

在 0xBFE1A8 回答后编辑:

我创建了一个新项目“扑通” 在 UnityEditor 中,我将 Visual Studio Code Editor 版本更改为 1.1.3,然后单击“更新 1.1.3”按钮

错误并没有消失,所以我继续:

我在“Packages/manifest.json”中将“com.unity.ide.vscode”修改为1.1.3 在 UnityEditor 中,选中“生成所有 .csproj 文件”复选框 然后,我在“资产”菜单中单击“全部重新导入”

毕竟,vsecode中的自动完成代码不起作用,但错误日志更小:

Starting OmniSharp server at 4/5/2020, 6:56:52 PM
    Target: /home/okli/UnityProjects/plop/plop.sln

OmniSharp server started.
    Path: /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/run
    PID: 30149

[info]: OmniSharp.Stdio.Host
    Starting OmniSharp on ubuntu 19.10 (x64)
[info]: OmniSharp.Services.DotNetCliService
    DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Located 1 MSBuild instance(s)
        1: StandAlone 16.4 - "/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    MSBUILD_EXE_PATH environment variable set to '/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
    Registered MSBuild instance: StandAlone 16.4 - "/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin
        CscToolPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
    Detecting Cake files in '/home/okli/UnityProjects/plop'.
[info]: OmniSharp.Cake.CakeProjectSystem
    Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
    Detecting projects in '/home/okli/UnityProjects/plop/plop.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
    Queue project update for '/home/okli/UnityProjects/plop/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
    Detecting CSX files in '/home/okli/UnityProjects/plop'.
[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.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.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
    Configuration finished.
[info]: OmniSharp.Stdio.Host
    Omnisharp server running using Stdio at location '/home/okli/UnityProjects/plop' on host 30017.
[info]: OmniSharp.MSBuild.ProjectManager
    Loading project: /home/okli/UnityProjects/plop/Assembly-CSharp.csproj
[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/okli/UnityProjects/plop/Assembly-CSharp.csproj'.
/home/okli/UnityProjects/plop/Assembly-CSharp.csproj
/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,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/okli/UnityProjects/plop/Assembly-CSharp.csproj

【问题讨论】:

【参考方案1】:

所以我找到了一个适合我的修复程序。 Omnisharp 网站 (https://github.com/OmniSharp/omnisharp-vscode) 说过,在 linux 上,您需要将 Use Global Mono for Omnisharp 设置为“从不”。默认为“自动”

相反,我可以通过将使用全局单声道设置为“始终”来修复此错误,并且它似乎可以正常工作。我不再收到错误,并且智能感知正在工作。

另外,我已经安装了 mono 和 dotnet。

【讨论】:

【参考方案2】:

如果 vscode unity auto complete 不起作用,请安装旧版本的 c# extensio,方法是单击配置按钮

【讨论】:

【参考方案3】:

我有同样的问题,但与 MonoVersion 无关。降级到 1.1.3生成 csproj 文件就可以了。我觉得很奇怪,因为这个错误与 1.1.4 版本有关,并开始进一步调查 vscode 扩展的 1.2.1。问题出在sln 文件中,我找到了一个简单的解决方案。

UnityEditor 中转到:[Edit]->[Preferences]->[External Tools]:点击复选框为以下各项生成 .csproj 文件:嵌入包,然后点击重新生成项目文件按钮来解决自动完成问题。

它在 sln 文件中添加了一些行,现在自动完成功能无需降级扩展即可工作。

希望对你有帮助!

【讨论】:

我检查了所有这些框是否正确,它解决了这个问题。但是您的回答为我指明了正确的方向,它甚至可能仅适用于检查“嵌入式软件包”。谢谢!【参考方案4】:

此警告是已知的Visual Studio Code Editor 1.1.4 bug。 根据this information,导致错误的是 Omnisharp 扩展:

此问题是由扩展程序引起的,请与 存储库(或联系人)扩展已在 VS 的概述中链接 代码或 VS Code 的市场。另请参阅我们的问题报告 指导方针。

编码愉快!

对我来说,降级到软件包的 1.1.3 版本可以解决问题。

UnityEditor 中转到:[Window]->[Package manager]->[Visual Studio Code Editor]->:选择 1.1.3 版本并点击“更新 1.1. 3" 按钮。

如果错误在那之后没有消失:

1) 更改了 "com.unity.ide.vscode": "1.1.3""Packages/manifest.json" 2) 在 UnityEditor 中转到:[Edit]->[Preferences]->[External Tools]: 设置“生成所有 .csproj 文件" CheckBox 为真。 3) 在 UnityEditor 中转到:[Assets]->[Reimport All]

有人说,如果你降级到 1.1.3 并在升级到 1.2.0 之后立即修复错误,但我没有尝试过。

【讨论】:

感谢您的详细帮助 :) 我创建了一个新项目并按照您的所有步骤进行操作,错误日志较小但我保留错误“无法加载项目文件'/home/okli/ UnityProjects/plop/Assembly-CSharp.csproj'。” ...“/home/okli/.vscode/extensions/ms-dotnettools.csharp-1.21.16/.omnisharp/1.34.15/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193, 5): 错误: .NETFramework,Version=v4.7.1 的参考程序集未找到。要解决此问题,请安装此框架版本的开发包(SDK/Targeting Pack)或重新定位...”。我会更新主帖 你的单声道版本是什么? 我的版本是 5.18.0.240(详细输出在这里:i.ibb.co/9NGqhW3/Screenshot-from-2020-04-05-19-52-04.png)。我通过一个简单的sudo apt install mono-devel (mono-project.com/docs/getting-started/install/linux) 安装了单声道 尝试更新到latest stable version。 很好!单声道版本有问题:D 自动完成功能就像一个魅力,感谢您的帮助和耐心;)

以上是关于带有 vscode 和 C# 扩展的 Ubuntu 19.10 上的 Unity3D:出现错误并且自动完成功能不起作用的主要内容,如果未能解决你的问题,请参考以下文章

开发环境Ubuntu 中使用 VSCode 开发 C/C++ ① ( 安装中文扩展 | 安装 C/C++ 扩展 )

vscode远程ubuntu代码编辑

ubuntu下vscode调试c++怎么配置launch.json和task.json

微软欲闭源VS Code的C#扩展惹众怒

带有 VScode 的 Scala

C#基础-01 | Helloword