Omnisharp-vscode: Intellisense does not show suggestions

Created on 7 Jun 2017  Â·  28Comments  Â·  Source: OmniSharp/omnisharp-vscode

MVC Core applpication

dotnet --info output:
VS Code version:
C# Extension version:

Steps to reproduce

I create a simple model class with attributes, the intellisense do not suggest add the using class and cannot detect the error

Expected behavior

capture
capture1

Actual behavior

Needs More Info

All 28 comments

Could you provide the information from the issue template?

dotnet --info output:
VS Code version:
C# Extension version:

In addition, in your first screenshot, it looks like there was an exception in the OmniSharp Log that is only partially visible. Could you copy and paste the content of your OmniSharp Log here?

@DustinCampbell can you help me to find the OmniSharp Log, because I don't have Idea where its

It's in your first screenshot above. Here are explicit instructions:

  1. In VS Code, select View->Output to bring up the Output pane.
  2. In the Output pane, select "OmniSharp Log" from the combobox in the top-right corner.
  3. With the mouse, select the whole OmniSharp Log in the Output pane, right-click and choose "Copy".

@DustinCampbell Ohhh I got it:

Starting OmniSharp server at 6/7/2017, 1:00:43 PM
    Target: c:\inetpub\wwwroot\vega\Vega.sln

OmniSharp server started
    Path: C:\Users\Carlos-M\.vscode\extensions\ms-vscode.csharp-1.10.0\bin\omnisharp\OmniSharp.exe
    PID: 14608

OmniSharp: -s c:\inetpub\wwwroot\vega\Vega.sln --hostPID 15160 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
[info]: OmniSharp.Startup
        Omnisharp server running using Stdio at location 'c:\inetpub\wwwroot\vega' on host 15160.
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\inetpub\wwwroot\vega
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuild will use local Visual Studio installation.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Detecting projects in 'c:\inetpub\wwwroot\vega\Vega.sln'.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: c:\inetpub\wwwroot\vega\Vega.csproj
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        The "FindAppConfigFile" task could not be instantiated from the assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.FindAppConfigFile' to type 'Microsoft.Build.Framework.ITask'.
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        The "FindAppConfigFile" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file 'c:\inetpub\wwwroot\vega\Vega.csproj'.
c:\inetpub\wwwroot\vega\Vega.csproj

[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\inetpub\wwwroot\vega'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Startup
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Startup
        Configuration finished.

Thanks for the log, that helps a bit. Is there any chance that you could share your project?

dotnet –info

PS C:\inetpub\wwwroot\vega> dotnet --info
.NET Command Line Tools (1.0.4)

Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd

Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.4
Starting OmniSharp server at 6/7/2017, 12:09:31 PM
Target: c:\inetpub\wwwroot\vega\Vega.sln

OmniSharp server started
Path: C:\Users\Carlos-M.vscode\extensions\ms-vscode.csharp-1.10.0\bin\omnisharp\OmniSharp.exe
PID: 12080

OmniSharp: -s c:\inetpub\wwwroot\vega\Vega.sln --hostPID 9604 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
Omnisharp server running using Stdio at location 'c:\inetpub\wwwroot\vega' on host 9604.
Initializing in c:\inetpub\wwwroot\vega
Auto package restore: False
Update workspace context
Resolving projects references
MSBuild will use local Visual Studio installation.
Detecting projects in 'c:\inetpub\wwwroot\vega\Vega.sln'.
Loading project: c:\inetpub\wwwroot\vega\Vega.csproj
Failed to load project file 'c:\inetpub\wwwroot\vega\Vega.csproj'.
c:\inetpub\wwwroot\vega\Vega.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The tools version "15.0" is unrecognized. Available tools versions are "12.0", "14.0", "2.0", "3.5", "4.0". c:\inetpub\wwwroot\vega\Vega.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Project.Data.InitializeForEvaluation(IToolsetProvider toolsetProvider)
at Microsoft.Build.Evaluation.Evaluator4..ctor(IEvaluatorData4 data, ProjectRootElement projectRootElement, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary1 environmentProperties, ILoggingService loggingService, IItemFactory2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly, SdkResolution sdkResolution)
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(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.LoadProject(String filePath, String solutionDirectory, String sdksPath, ILogger logger, MSBuildOptions options, ICollection1 diagnostics, ImmutableArray1& targetFrameworks) at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create(String filePath, String solutionDirectory, String sdksPath, ILogger logger, MSBuildOptions options, ICollection1 diagnostics)
at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject(String projectFilePath)

    Detecting CSX files in 'c:\inetpub\wwwroot\vega'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
    Configuration finished.

Is there any chance that you could share your project?

Or, at least, the project file. I have a suspicion of what I think the issue is, but I'd like to verify.

One more ask: Could you increase the OmniSharp logging level and provide the log again? Here's you to do that:

  1. In VS Code, select Preferences->Settings to open your settings.json file
  2. In your settings.json file add, the following setting:
    JSON "omnisharp.loggingLevel": "debug"
  3. Restart VS Code and load your project.
  4. Grab the OmniSharp Log again.

Thanks!

testing the code on a zip

vega code with vscode error

Thanks! I received the project via email.

Out of curiosity, do you also have Visual Studio installed on the same machine? If so, what version?

Yes, I have Visual Studio Professional 2015 version 14.0.25431.01 Update 3
And Visual Studio Community Edition 2017 (2)

OK. I'm trying to understand why the two OmniSharp Logs you sent have different errors. The first shows this:

[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        The "FindAppConfigFile" task could not be instantiated from the assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.FindAppConfigFile' to type 'Microsoft.Build.Framework.ITask'.
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        The "FindAppConfigFile" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.

However, the second log above shows this:

[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file 'c:\inetpub\wwwroot\vega\Vega.csproj'.
c:\inetpub\wwwroot\vega\Vega.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The tools version "15.0" is unrecognized. Available tools versions are "12.0", "14.0", "2.0", "3.5", "4.0".  c:\inetpub\wwwroot\vega\Vega.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Evaluation.Project.Data.InitializeForEvaluation(IToolsetProvider toolsetProvider)
   at Microsoft.Build.Evaluation.Evaluator`4..ctor(IEvaluatorData`4 data, ProjectRootElement projectRootElement, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly, SdkResolution sdkResolution)
   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.ProjectFile.ProjectFileInfo.LoadProject(String filePath, String solutionDirectory, String sdksPath, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics, ImmutableArray`1& targetFrameworks)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create(String filePath, String solutionDirectory, String sdksPath, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics)
   at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject(String projectFilePath)

Did you try changing your csproj to include "15.0" in between attempts?

Yes I changed the version of : The tools version "15.0" on Vega.csproj from 15 to 14 and them I added the configuration that you suggest me

OK. Don't change the ToolsVersion in your csproj. :smile:

If you have VS 2017 Community edition installed, could you try the following?

  1. Close Visual Studio Code
  2. From the Windows Start Menu, launch Developer Command Prompt for VS 2017.
  3. In the Developer Command Prompt, type code . to launch VS Code.
  4. Open your project.

Do you still get the same error?

Ok , I don’t know if that help I used yo aspnetcore-spa generator

To be clear, your project is working on my machine, so I'm trying to help you workaround the issue. :smile:

They have to show suggestions like this image ☹

@DustinCampbell You can do this???

working

Yes, this works for me:

image

It's something wrong on my machine :( :( :(

Did you try my suggestion above?

If you have VS 2017 Community edition installed, could you try the following?

  1. Close Visual Studio Code
  2. From the Windows Start Menu, launch Developer Command Prompt for VS 2017.
  3. In the Developer Command Prompt, type code . to launch VS Code.
  4. Open your project.

Do you still get the same error?

Yes it work like a charm , but only using Visua Studio 2017 Command Prompt

When I click over the red error does not work only work when I click on the yellow icon

Yes it work like a charm , but only using Visual Studio 2017 Command Prompt

OK. So it sounds like things are working for you.

By launching VS Code from a VS 2017 Command Prompt, that provides enough context that to initialize an MSBuild build environment. This can be necessary to handle situations where there are several versions of Visual Studio installed. The VS 2017 Command Prompt sets two environment variables that can help MSBuild "find" itself:

  • VSINSTALLDIR: The path to VS, which could be something like C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\. This will depend on where VS 2017 is on your machine.
  • VisualStudioVersion: Set to 15.0.

If you like, you can set these environment variables to correct values before launching VS Code.

When I click over the red error does not work only work when I click on the yellow icon

Note that VS Code's editor experience is not identical to Visual Studio. It's not clear to me _exactly_ what you're describing, but it sounds like you may have encountered one of the differences between the products.

Let me know if you have anymore trouble.

Thank You @DustinCampbell you have been pretty helpfully

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiminuo picture kiminuo  Â·  3Comments

mattwoberts picture mattwoberts  Â·  3Comments

hamhub7 picture hamhub7  Â·  3Comments

gregg-miskelly picture gregg-miskelly  Â·  3Comments

ghost picture ghost  Â·  3Comments