dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 673 forks source link

Issue with Intellisense not coming up; Possibly Omnisharp crashing during initialization #1512

Closed Rwprice closed 7 years ago

Rwprice commented 7 years ago

Environment data

dotnet --info output: .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.10586 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.4

VS Code version: C# Extension version: 1.12.2

Steps to reproduce

Open a C# project folder in VsCode with Omnisharp extension installed, view logs.

Expected behavior

Intellisense begins working

Actual behavior

Intellisense does not begin working

Logs

Starting OmniSharp server at 5/24/2017, 12:12:46 PM
    Target: c:\Source\<project>\<project>\UserTokenDemo

OmniSharp server started
    Path: C:\Users\<user>\.vscode\extensions\ms-vscode.csharp-1.9.0\bin\omnisharp\OmniSharp.exe
    PID: 7692

OmniSharp: -s c:\Source\<project>\<project>\UserTokenDemo --hostPID 16716 --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:\Source\<project>\<project>\UserTokenDemo' on host 16716.
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Source\<project>\<project>\UserTokenDemo
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[fail]: OmniSharp.Startup
        The project system 'OmniSharp.MSBuild.MSBuildProjectSystem' threw exception during initialization.
System.InvalidOperationException: Failed to convert 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe' to type 'OmniSharp.Options.MSBuildOptions'. ---> System.NotSupportedException: TypeConverter cannot convert from System.String.
   at System.ComponentModel.TypeConverter.GetConvertFromException(Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at Microsoft.Extensions.Configuration.ConfigurationBinder.ConvertValue(Type type, String value)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.Configuration.ConfigurationBinder.ConvertValue(Type type, String value)
   at Microsoft.Extensions.Configuration.ConfigurationBinder.Bind(IConfiguration configuration, Object instance)
   at OmniSharp.MSBuild.MSBuildProjectSystem.Initalize(IConfiguration configuration)
   at OmniSharp.Startup.InitializeWorkspace(OmniSharpWorkspace workspace, CompositionHost compositionHost, IConfiguration configuration, ILogger logger, OmniSharpOptions options)
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Source\<project>\<project>\UserTokenDemo'.
[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.
filipw commented 7 years ago

@Rwprice it looks like you have an environment variable called MsBuild with the value C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe.

Due to a bug, this conflicts with internal OmniSharp configuration (at the moment it "reserves" MsBuild env variable for itself). This will be fixed in OmniSharp soon - but in the meantime, you can rename/remove that environment variable to fix your issue.

DustinCampbell commented 7 years ago

As a workaround, you can unset your "msbuild" environment variable before starting VS Code.

developerTN commented 7 years ago

Hi, It will be great, if you tell us how to unset it for Vscode

eaglexiang commented 6 years ago

@developerTN just run command like:

unset msbuild
HugoCortell commented 1 year ago

Issue happening with Unity Engine at the moment, not sure if it is a problem with VSCode or the engine itself.