简体   繁体   English

OmniSharp未在global.json文件夹的VSCode中加载(但对project.json文件夹有效)

[英]OmniSharp not loaded in VSCode for global.json folder (but works OK for project.json folders)

I am running Visual Studio Code 1.4.0, .NET Core 1.0 and .NET Core SDK Preview 2. Tested on Windows 10 x64 and Ubuntu 16.04 x64, and observed the same problem. 我正在运行Visual Studio Code 1.4.0,.NET Core 1.0和.NET Core SDK Preview2。在Windows 10 x64和Ubuntu 16.04 x64上进行了测试,并观察到相同的问题。

In the simplest example, my folder structure looks like this: 在最简单的示例中,我的文件夹结构如下所示:

- Repo\
  |
  +-- global.json
  |
  +-- LibOne\
  |   |
  |   +-- project.json
  |   +-- ClassOne.cs
  |
  +-- LibOne.Tests\
      |
      +-- project.json
      +-- ClassOneTests.cs
  • Complete example is found in this GitHub repo . 完整示例在此GitHub存储库中找到。
  • LibOne is a class library LibOne是一个类库
  • LibOne.Tests contains xUnit tests for LibOne LibOne.Tests包含的xUnit测试LibOne
  • LibOne.Tests specifies LibOne in its dependencies. LibOne.Tests在其依赖LibOne.Tests指定LibOne
  • I am able to successfully restore, compile, and run tests with both CLI and VS Code. 我能够使用CLI和VS Code成功还原,编译和运行测试。

The problem is with IntelliSense. 问题出在智能感知上。 When I open the Repo folder in VS Code, the IntelliSense does not work. 当我在VS Code中打开Repo文件夹时,IntelliSense无法正常工作。 However, if I open either LibOne or LibOne.Tests folder, everything works fine. 但是,如果我打开LibOneLibOne.Tests文件夹,则一切正常。

The difference that I noticed is that when I open the Repo folder, I have no logs of OmniSharp (in VS Code, View -> Output -> OmniSharp Log). 我注意到的区别是,当我打开Repo文件夹时,没有OmniSharp的日志(在VS Code中,查看->输出-> OmniSharp日志)。 Whereas with project folders, I can see the logs of how OmniSharp is loaded, how it looks for projects, etc. It looks like OmniSharp is somehow not triggered or not associated with folders containing global.json , and is only loaded when one opens a folder that contains project.json . 鉴于使用项目文件夹,我可以看到OmniSharp的加载方式日志,查找项目的方式等。看起来OmniSharp某种程度上未触发或未与包含global.json文件夹相关联,并且仅当打开一个文件夹时才加载包含project.json文件夹。

I would appreciate any ideas about what could be wrong here. 对于在这里可能出什么问题的任何想法,我将不胜感激。

I should have read the documentation better. 我应该更好地阅读文档。 Here is what I was missing: https://code.visualstudio.com/docs/editor/codebasics#_opening-a-project 这是我所缺少的: https : //code.visualstudio.com/docs/editor/codebasics#_opening-a-project

In VS Code, when a folder is opened that contains multiple projects, only one project is active at a time (and none is active initially). 在VS Code中,打开一个包含多个项目的文件夹时,一次仅一个项目处于活动状态(最初没有一个项目处于活动状态)。 Project selector is located in the right bottom corner in the status bar. 项目选择器位于状态栏的右下角。

What is still missing from the documentation, is that the IntelliSense will only work for the active project . 文档中仍然缺少的是IntelliSense仅适用于活动项目 Not sure whether it is VSCode or OmniSharp limitation. 不确定是VSCode还是OmniSharp限制。 Once I selected an active project, the IntelliSense for that project started to work. 选择活动项目后,该项目的IntelliSense便开始工作。

Not convenient, but better than nothing. 不方便,但总比没有好。

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

相关问题 使用 Visual Studio 2017 的 .NET Core 解决方案上没有 project.json、global.json 等 - there is no project.json, global.json … etc on .NET Core Solution with Visual Studio 2017 不使用project.json时在vscode中的project.json警告 - project.json warning in vscode when not using project.json VS Studio现在在每个项目和.netCore中都包括global.json? - VS Studio now including global.json in every project and .netCore? NET Core中使用project.json构建后创建一个文件夹 - Create a folder after build using project.json in NET Core 引用SQLite的Project.json - Project.json referencing SQLite 发布项目时如何在Visual Studio 2022中使用global.json设置SDK小版本? - How to use global.json in Visual Studio 2022 to set SDK minor version when publishing project? VSCode Omnisharp 忽略 omnisharp.json 中的格式设置 - VSCode Omnisharp ignores format settings in omnisharp.json 使用“ global.json”项目属性解决依赖关系 - Resolving dependencies using “global.json” projects property ASP.NET 5中Global.json中项目部分的说明 - Explanation of the projects section in Global.json in ASP.NET 5 ASP.NET 5 global.json文件无法使用相对路径 - Asp.net 5 global.json file not working with relative path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM