简体   繁体   中英

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.

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 .
  • LibOne is a class library
  • LibOne.Tests contains xUnit tests for LibOne
  • LibOne.Tests specifies LibOne in its dependencies.
  • I am able to successfully restore, compile, and run tests with both CLI and VS Code.

The problem is with IntelliSense. When I open the Repo folder in VS Code, the IntelliSense does not work. However, if I open either LibOne or LibOne.Tests folder, everything works fine.

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). 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 .

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

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). 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 . Not sure whether it is VSCode or OmniSharp limitation. Once I selected an active project, the IntelliSense for that project started to work.

Not convenient, but better than nothing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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