繁体   English   中英

Visual Studio 代码 C# 扩展不工作

[英]Visual Studio Code C# Extension not working

Windows 10 专业版 x64

几天来我一直在尝试解决这个问题,下载了多个不同版本的 .NET SDK,但我仍然从 C# 扩展中得到这个错误:“找不到 .NET 核心 SDK。确保启用核心调试不会是.NET 核心 SDK 已安装并在路径上。”

我去了那个帮助页面,它说在 cmd 提示符 window 中输入 where.exe,我这样做了,收到了一个结果,然后回到帮助页面,它说,“没有已知的原因PATH 不会传播到 VS Code 进程。”

这是我的 OmniSharp output 日志:

Starting OmniSharp server at 11/8/2021, 4:43:45 PM
    Target: c:\Users\eleph\Unity Projects\bEan\bEan.sln

OmniSharp server started.
    Path: c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\OmniSharp.exe
    PID: 15972

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
        Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 17.0.0 - "c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 17.0.0 - "c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild
            MSBuildToolsPath = c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin
[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.Completion.CompletionOptionsProvider, 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.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\eleph\Unity Projects\bEan'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'c:\Users\eleph\Unity Projects\bEan\bEan.sln'.
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\UnityEngine.TestRunner.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.Timeline.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\UnityEngine.UI.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.TextMeshPro.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\eleph\Unity Projects\bEan\Assembly-CSharp.csproj'
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\UnityEditor.TestRunner.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.PlasticSCM.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\UnityEditor.UI.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.Services.Core.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.Timeline.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.TextMeshPro.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.CollabProxy.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.Rider.Editor.csproj
[warn]: OmniSharp.MSBuild.ProjectSystem
        Found project that doesn't exist on disk: c:\Users\eleph\Unity Projects\bEan\Unity.VSCode.Editor.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\eleph\Unity Projects\bEan'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\eleph\Unity Projects\bEan' on host 11172.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\eleph\Unity Projects\bEan\Assembly-CSharp.csproj
[warn]: OmniSharp.MSBuild.ProjectLoader
        The referenced project 'Unity.VSCode.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.Timeline.Editor.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.TextMeshPro.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The referenced project 'UnityEditor.UI.csproj' does not exist.
[warn]: OmniSharp.MSBuild.ProjectLoader
        The referenced project 'Unity.PlasticSCM.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 'UnityEngine.UI.csproj' does not exist.
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for ".NETFramework,Version=v5.0.402" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\eleph\Unity Projects\bEan\Assembly-CSharp.csproj'.
c:\Users\eleph\Unity Projects\bEan\Assembly-CSharp.csproj
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.VSCode.Editor.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.TextMeshPro.Editor.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.Timeline.Editor.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.Timeline.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.TextMeshPro.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'UnityEditor.UI.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.PlasticSCM.Editor.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'Unity.Rider.Editor.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2068,5): Error: The referenced project 'UnityEngine.UI.csproj' does not exist.
c:\Users\eleph\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5): Error: The reference assemblies for ".NETFramework,Version=v5.0.402" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: c:\Users\eleph\Unity Projects\bEan\Assembly-CSharp.csproj

作为参考,这是来自 Unity 项目的 C# 文件,但常规的 C# 文件也不起作用。 请帮助,我目前在没有 IntelliSense 且没有正确语法突出显示的情况下进行编程,这让我发疯。

切换到VS,VSCode相比VS对Unity的支持确实不多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM