本文介绍了OmniSharp.MSBuild.ProjectManager 尝试更新未加载的项目:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 VS 代码开发 Asp.net Core Web API.但是当我输入代码时,Intellisense/Suggestions 无法正常工作.我在互联网上的一些资源中看到他们正在键入 using Microsoft.EntityFrameworkCore 显示为建议.但就我而言,它没有显示.在 OmniSharp 日志中向我显示以下错误.

I started to develop Asp.net Core web API with the VS code. But when I typing the code Intellisense/Suggestions not working properly. I saw in some resource on the internet while they are typing using Microsoft., EntityFrameworkCore showing as a suggestion. But In my case, it's not showing. In the OmniSharp log showing following error to me.

Starting OmniSharp server at 4/5/2019, 3:37:16 PM
    Target: c:Dotnet CoreNgWebApi

OmniSharp server started.
    Path: C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11OmniSharp.exe
    PID: 13684

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild15.0Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild15.0BinMSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild15.0Bin"
            CscToolExe = csc.exe
            CscToolPath = C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild15.0BinRoslyn
            MSBuildExtensionsPath = C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild
            MSBuildToolsPath = C:UsersAcer.vscodeextensionsms-vscode.csharp-1.18.0.omnisharp1.32.11msbuild15.0Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:Dotnet CoreNgWebApi'.
[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
        No solution files found in 'c:Dotnet CoreNgWebApi'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:Dotnet CoreNgWebApiNgWebApi.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:Dotnet CoreNgWebApi'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:Dotnet CoreNgWebApiNgWebApi.csproj
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:Dotnet CoreNgWebApi' on host 17188.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:Dotnet CoreNgWebApiNgWebApi.csproj'.
c:Dotnet CoreNgWebApiNgWebApi.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  c:Dotnet CoreNgWebApiNgWebApi.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
   at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
   at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
   at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: c:Dotnet CoreNgWebApiNgWebApi.csproj

我重新安装了 VS Code 和 C#C# Extention 来解决这个问题,但它仍然发生.我认为原因是没有显示 Intellisense/Suggestions 项目未正确加载.谁能告诉我如何避免此错误以及如何解决未显示问题的智能感知/建议.

I re-installed the VS Code and C# , C# Extention to solve this problem, but it's still occurring. I think the reason was to not showing Intellisense/Suggestions the project is not properly loaded. Can anyone tell me how to avoid this error and how to solve Intellisense/Suggestions not showing the issue.

推荐答案

为了解决这个问题,我做了几件事.首先,我通过安装他们的测试版来降级 OmniSharp 版本.将该版本的 .vsix 文件下载到我的机器上.使用以下步骤将 .vsix 安装到 Visual Studio Code 中.

To solve this I did several things. First of all, I downgrade OmniSharp version by installing their beta version. download the .vsix file for that release to my machine. Used the following steps to install the .vsix into Visual Studio Code.

  1. 打开 Visual Studio Code 并从菜单中选择查看"->扩展"以显示扩展"窗格
  2. 通过单击扩展窗格右上角的 ... 并选择从 VSIX 安装..."在菜单上.
  3. 找到我下载的.vsix文件并打开它
  4. 然后重启vs代码
  1. Open Visual Studio Code and select View->Extensions from the menu to display the Extensions pane
  2. By clicking the ... at the top-right corner of the Extensions pane and select "Install from VSIX..." on the menu.
  3. Located the .vsix the file I downloaded and Opened it
  4. Then restart vs code

但问题依旧,于是我将.Net core SDK v2.2.202 版本降级为2.1.202,问题解决了.

But the problem still occurred, so then I downgraded the .Net core SDK v2.2.202 version to 2.1.202 and the problem is solved.

更新:重新安装 VS Code 后不得不再次面临同样的问题,解决.

  1. 在visual studio代码菜单中,进入文件 >偏好 >设置.或按 ++

  1. In the visual studio code menu, go into File > Preferences > Settings. or Press ++

搜索设置字段中,输入omnisharp.path

点击在 settings.json 中编辑.

在那里像这样添加/编辑,

in there Add / Edit like this,

{
  "omnisharp.path": "latest"
}

如果您的 settings.json 中已经有条目,请在最后一个后面加一个逗号并添加如下行:

If your settings.json already had entries in it, put a comma behind the last one and add the line like this:

{
  "workbench.colorTheme": "Solarized Light",
  "omnisharp.path": "latest"
}

最后,保存settings.json

您将看到提示:OmniSharp 配置已更改.您想用您的更改重新启动 OmniSharp 服务器吗?"单击重新启动 OmniSharp";按钮重新加载它.

You'll see a prompt: "OmniSharp configuration has changed. Would you like to relaunch the OmniSharp server with your changes?" Click the "Restart OmniSharp" button to reload it.

在输出窗口中,您可以在下载最新版本时看到更新

In the Output window, you can see updates while the latest version downloads

这篇关于OmniSharp.MSBuild.ProjectManager 尝试更新未加载的项目:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 10:48