Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Failed to convert 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319' to type 'OmniSharp.Options.MSBuildOptions'." #1246

Closed
blakeb-seriouslabs opened this issue Feb 16, 2017 · 3 comments

Comments

@blakeb-seriouslabs
Copy link

blakeb-seriouslabs commented Feb 16, 2017

Opening a C# file in a C# Project yields the following error in OmniSharp.

    Target: d:\dev\Visual Studio\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.sln

OmniSharp server started
    Path: C:\Users\blakeb\.vscode\extensions\ms-vscode.csharp-1.7.0\bin\omnisharp\OmniSharp.exe
    PID: 2408

OmniSharp: -s d:\dev\Visual Studio\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.sln --hostPID 6592 --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 'd:\dev\Visual Studio\ConsoleApplication1\ConsoleApplication1' on host 6592.
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in d:\dev\Visual Studio\ConsoleApplication1\ConsoleApplication1
[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 'MSBuildProjectSystem' threw exception during initialization.
Failed to convert 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319' to type 'OmniSharp.Options.MSBuildOptions'.
   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) in C:\projects\omnisharp-roslyn\src\OmniSharp.MSBuild\MSBuildProjectSystem.cs:line 80
   at OmniSharp.Startup.Configure(IApplicationBuilder app, IServiceProvider serviceProvider, ILoggerFactory loggerFactory, ISharedTextWriter writer, IAssemblyLoader loader, IOptions`1 optionsAccessor) in C:\projects\omnisharp-roslyn\src\OmniSharp.Host\Startup.cs:line 184
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\dev\Visual Studio\ConsoleApplication1\ConsoleApplication1'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Startup
        Configuration finished.

Environment data

dotnet --info output:


Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version: 1.9.1
C# Extension version: 1.7.0

Steps to reproduce

  1. Get a fresh install of Visual Studio Code 1.9.1 by uninstalling, deleting .vscode directory and Code directory from AppData/Roaming
  2. Install DotNet CLI Preview 2.1
  3. Install Visual Studio Code 1.9.1
  4. Run Visual Studio Code
  5. Install C# Extension via Extensions pane, reloading when prompted
  6. Open a blank C# project with at least one C# code file in it in Visual Studio Code (I used Visual Studio 2010)
  7. Open a C# code file in Visual Studio Code
  8. Open OmniSharp Log

Expected behavior

OmniSharp starts correctly when a project solution is correctly opened. Intellisense and other features such as Find All References work as expected.

Actual behavior

OmniSharp appears to error out during MSBuildProjectSystem initialization, despite not having MSBuild set as the project build tool in tasks.json. Intellisense features are unavailable, and Find All References does not work.

Notes

I tried this in multiple project files, a couple of them being Unity projects, one of them being a blank Visual Studio 2010 project.

I have done the following to try to fix this issue:

  1. Uninstall and reinstall DotNet CLI
  2. Uninstall DotNet CLI Preview 2.1 and install DotNet CLI Preview 2.0
  3. Set "omnisharp.useMono": true
  4. Fully uninstall and reinstall Visual Studio Code
  5. Downgraded to C# Extension version 1.6.2

Here is my PATH variable:
C:\Users\blakeb\AppData\Local\Microsoft\WindowsApps;C:\Python27;C:\Python27\Scripts;C:\android-sdk\platform-tools;C:\android-sdk\tools;C:\Program Files (x86)\Microsoft VS Code\bin

System PATH:
C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Perforce;C:\Program Files\Perforce\DVCS\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\dotnet\

I recognize that this may be fully dependent on my local setup, and was hoping to get any insight as to why this might be the case.

Also note that C:\projects\omnisharp-roslyn\src\ does not exist on my machine, though it appears to be referenced in the error log. I don't know if that's relevant, my guess is it isn't.

@DustinCampbell
Copy link
Member

Hi, sorry you're having trouble getting things working. Could you provide the project that you created in VS 2010?

A few quick points:

  • There's no need to set "omnisharp.useMono" -- that won't have any affect.
  • C:\projects\omnisharp-roslyn\src is likely unrelated. That's simply the source file listed in the exception call stack coming from OmniSharp.
  • Do you have an omnisharp.json file in your project? It's unlikely but I thought I'd check.
  • Do you happen to have an environment variable defined named "MSBuild"? It's entirely possible that a previously defined environment variable is getting confused as part of OmniSharp's configuration.

@blakeb-seriouslabs
Copy link
Author

Do you happen to have an environment variable defined named "MSBuild"? It's entirely possible that a previously defined environment variable is getting confused as part of OmniSharp's configuration.

That was the issue. Well that's embarrassing. I had removed it from the PATH but I forgot that it was still an environment variable. Thanks!

@DustinCampbell
Copy link
Member

Excellent! I'm glad that's all it was. Let me know if you have anymore trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants