Omnisharp-vscode: Omnisharp crashes upon project load

Created on 15 Dec 2016  ·  18Comments  ·  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:
Tested on two versions.
First:

H:\tmp>dotnet --info
.NET Command Line Tools (1.0.0-preview5-004226)

Product Information:
 Version:            1.0.0-preview5-004226
 Commit SHA-1 hash:  7b109e4b53

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview5-004226

Second:

H:\tmp>dotnet --info
.NET Command Line Tools (1.0.0-preview5-004232)

Product Information:
 Version:            1.0.0-preview5-004232
 Commit SHA-1 hash:  355b6233cb

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-preview5-004232

VS Code version:

Версия 1.8.0
Фиксация 38746938a4ab94f2f57d9e1309c51fd6fb37553d
Дата 2016-12-13T17:45:32.595Z
Оболочка 1.4.6
Обработчик 53.0.2785.143
Node 6.5.0

C# Extension version: 1.6.0-beta4

Steps to reproduce

dotnet new
code .

Expected behavior

Project loads ok

Actual behavior

Console logs:

Starting OmniSharp server at 15.12.2016, 16:58:44
    Target: h:\tmp

OmniSharp server started
    Path: C:\Users\m.user\.vscode\extensions\ms-vscode.csharp-1.6.0-beta4\bin\omnisharp\OmniSharp.exe
    PID: 9920

OmniSharp: -s h:\tmp --hostPID 25200 --stdio DotNet:enablePackageRestore=false --encoding utf-8
[INFORMATION:OmniSharp.Startup] Omnisharp server running using Stdio at location 'h:\tmp' on host 25200.
[INFORMATION:OmniSharp.DotNet.DotNetProjectSystem] Initializing in h:\tmp
[INFORMATION:OmniSharp.DotNet.DotNetProjectSystem] Auto package restore: False
[INFORMATION:OmniSharp.DotNet.DotNetProjectSystem] Update workspace context
[INFORMATION:OmniSharp.DotNet.DotNetProjectSystem] Resolving projects references
[INFORMATION:OmniSharp#MSBuild] MSBuildExtensionsPath environment variable set to C:\Users\m.user\.vscode\extensions\ms-vscode.csharp-1.6.0-beta4\bin\omnisharp\msbuild
[INFORMATION:OmniSharp#MSBuild] MSBUILD_EXE_PATH environment variable set to C:\Users\m.user\.vscode\extensions\ms-vscode.csharp-1.6.0-beta4\bin\omnisharp\msbuild\MSBuild.exe
[INFORMATION:OmniSharp#MSBuild] MSBuildSDKsPath environment variable set to C:\Users\m.user\.vscode\extensions\ms-vscode.csharp-1.6.0-beta4\bin\omnisharp\msbuild\Sdks
[INFORMATION:OmniSharp#MSBuild] No solution files found in 'h:\tmp'
[WARNING:OmniSharp#MSBuild] Failed to process project file 'h:\tmp\tmp.csproj'.
h:\tmp\tmp.csproj(1,1)
System.UriFormatException: Недопустимый URI: Невозможно определить формат URI.
   в System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   в Microsoft.Build.Shared.FileUtilities.MakeRelative(String basePath, String path)
   в Microsoft.Build.Evaluation.Evaluator`4.ThrowForImportedProjectWithSearchPathsNotFound(ProjectImportPathMatch searchPathMatch, ProjectImportElement importElement)
   в Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   в Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   в Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   в Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   в Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   в Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   в Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   в Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   в Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   в Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   в Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   в OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create(String projectFilePath, String solutionDirectory, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics) в C:\Projects\omnisharp-roslyn\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:строка 106
   в OmniSharp.MSBuild.MSBuildProjectSystem.CreateProjectFileInfo(String projectFilePath) в C:\Projects\omnisharp-roslyn\src\OmniSharp.MSBuild\MSBuildProjectSystem.cs:строка 365

[INFORMATION:OmniSharp.Script.ScriptProjectSystem] Detecting CSX files in 'h:\tmp'.
[INFORMATION:OmniSharp.Script.ScriptProjectSystem] Could not find any CSX files
[INFORMATION:OmniSharp.Startup] Configuration finished.
Bug OmniSharp Resolved-Fixed

All 18 comments

Thanks for the report! I've got a fix over in https://github.com/OmniSharp/omnisharp-roslyn/pull/707. There should be another beta release out in the next hour or two to address this.

OK. I've released v1.6-beta5, which should fix this problem for you.

Still does not work for me.
Same error.
1.6.0-beta5

It looks like my issue is the same here: https://github.com/OmniSharp/omnisharp-roslyn/issues/706

@Phoenix-: Could you check and see if you have multiple %UserProfile%\.vscode\extensions\ms-vscode.csharp-* folders?

@DustinCampbell The only folder is ms-vscode.csharp-1.6.0-beta5
Also I have plugins for other languages, I don't think there can be interference, but anyway, full list:

donjayamanne.python-0.5.5
ms-vscode.cpptools-0.9.3
ms-vscode.csharp-1.6.0-beta5
ms-vscode.PowerShell-0.7.2

Also, I tried beta3 - it is working as it should. So the bug was introduced somewhere between beta 3 and 4

No, those wouldn't interfere. I've seen issues in the past where old C# extensions were left behind and caused issues.

FWIW, beta3 shouldn't work with csproj projects with an "Sdk" attribute.

Out of curiosity, do you have Visual Studio installed on your system? If so, which version?

Beta3 does not work for the project generated by latest sdk:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
  </ItemGroup>

</Project>

but it does for csproj that was created by dotnet migrate:

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.1.0</Version>
    </PackageReference>
  </ItemGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Here on my work pc I have a load of VS: 2010, 2012 and 2015, pro versions.
I will try again at home, where I have only 2015 and 2017, community ones.

OK. I'm going to try a VM later today or this weekend with more VS versions.

Thank you!
I will try to debug omnisharp.exe at home, maybe I'll figure out what went wrong.

OK. Though note that it's a bit messy.

The UriFormatException happens fairly deep in MSBuild project evaluation. Yesterday, the issue I fixed related to this was a situation where of the MSBuild properties in %USERPROFILE\.vscode\extensions\ms-vscode.csharp-1.6.0-beta5\bin\omnisharp\msbuild\MSBuild.exe.config were not expanding properly. Essentially, OmniSharp set MSBuildExtensionsPath as an environment variable. However, this config file defines MSBuildExtensionsPath as well, which overrode the environment variable. The definition in the config file is $(VsInstallRoot)\MSBuild, which expanded to \MSBuild on machines without VS, resulting in a UriFormatException. I fixed this by setting MSBuildExtensionsPath as a global variable here.

You might try deleting values from the MSBuild.exe.config file at the path above and see if that addresses the problem. Perhaps removing the "projectImportSearchPaths" node would fix the problem?

Wow... Thanks for the idea!
File %USERPROFILE\.vscode\extensions\ms-vscode.csharp-1.6.0-beta5\bin\omnisharp\msbuild\MSBuild.exe.config
I deleted lines 67-70:

        <property name="VsInstallRoot" value="$([MSBuild]::GetVsInstallRoot())" />
        <property name="MSBuildToolsRoot" value="$(VsInstallRoot)\MSBuild" />
        <property name="MSBuildExtensionsPath" value="$(VsInstallRoot)\MSBuild" />
        <property name="MSBuildExtensionsPath32" value="$(VsInstallRoot)\MSBuild" />

And everything worked.

Looks like somehow my old msbuild from VS managed to get past all the redefinitions.

OK. I just installed 1.6-beta5, and it looks like it actually has the wrong bits. My original fix does fix this issue, but the binary does not include it. It was probably just an error in publishing. I should have this fixed soon.

I've released 1.6-beta6 and verified that it actually has my changes this time. :smile:

Let me know if this works better for you.

Thank you! Beta5 and Beta6 work ok on my home system (VS 2015 + 2017)
I will check Beta6 at work on monday.

Checked at work, everything works, thanks again.

Great! Thanks for letting me know.

Was this page helpful?
0 / 5 - 0 ratings