omnisharp-roslyn: Omnisharp does not work with project that has reference
Omnisharp does not work with project that has reference to another project. For example I have two projects in a solution. One for code and One for unit test. I add reference at test project. This is how test project .csproj file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ThaiNumber\ThaiNumber.csproj" />
</ItemGroup>
</Project>
This is log message after I start Omnisharp.
info: OmniSharp.Http.Startup[0]
Starting OmniSharp on MacOS 10.12.6 (x64)
info: OmniSharp.Cake.CakeProjectSystem[0]
Detecting Cake files in '/Users/aki/Code/thai-number'.
info: OmniSharp.Cake.CakeProjectSystem[0]
Could not find any Cake files
info: OmniSharp.Http.Startup[0]
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
info: OmniSharp.MSBuild.ProjectSystem[0]
Detecting projects in '/Users/aki/Code/thai-number/thai-number.sln'.
info: OmniSharp.MSBuild.ProjectManager[0]
Queue project update for '/Users/aki/Code/thai-number/ThaiNumber/ThaiNumber.csproj'
info: OmniSharp.MSBuild.ProjectManager[0]
Queue project update for '/Users/aki/Code/thai-number/ThaiNumber.Tests/ThaiNumber.Tests.csproj'
info: OmniSharp.Script.ScriptProjectSystem[0]
Detecting CSX files in '/Users/aki/Code/thai-number'.
info: OmniSharp.Script.ScriptProjectSystem[0]
Could not find any CSX files
info: OmniSharp.Http.Startup[0]
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.Http.Startup[0]
Configuration finished.
info: OmniSharp.Http.Startup[0]
Omnisharp server running on port '2000' at location '/Users/aki/Code/thai-number' on host -1.
info: OmniSharp.MSBuild.ProjectManager[0]
Loading project: /Users/aki/Code/thai-number/ThaiNumber/ThaiNumber.csproj
info: OmniSharp.MSBuild.ProjectManager[0]
Successfully loaded project file '/Users/aki/Code/thai-number/ThaiNumber/ThaiNumber.csproj'.
info: OmniSharp.MSBuild.ProjectManager[0]
Adding project '/Users/aki/Code/thai-number/ThaiNumber/ThaiNumber.csproj'
info: OmniSharp.MSBuild.ProjectManager[0]
Loading project: /Users/aki/Code/thai-number/ThaiNumber.Tests/ThaiNumber.Tests.csproj
fail: OmniSharp.MSBuild.ProjectLoader[0]
The "GetReferenceNearestTargetFrameworkTask" task failed unexpectedly.
System.TypeLoadException: Could not resolve type with token 01000026 (from typeref, class/assembly NuGet.Common.INuGetLogMessage, NuGet.Common, Version=4.7.0.5, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
at NuGet.Common.LoggerBase.Log (NuGet.Common.LogLevel level, System.String data) [0x00011] in <edf7c3843b6343088d2c4161c18c58ba>:0
at NuGet.Build.Tasks.BuildTasksUtility.LogTaskParam (NuGet.Common.ILogger log, System.String direction, System.String name, System.String[] values) [0x0004e] in <ccfe602e13494476b1d015038cdc0c94>:0
at NuGet.Build.Tasks.BuildTasksUtility.LogInputParam (NuGet.Common.ILogger log, System.String name, System.String[] values) [0x00000] in <ccfe602e13494476b1d015038cdc0c94>:0
at NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask.Execute () [0x00020] in <ccfe602e13494476b1d015038cdc0c94>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in <82d05e73c22a425d94f54e932409b29e>:0
at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x00212] in <82d05e73c22a425d94f54e932409b29e>:0
warn: OmniSharp.MSBuild.ProjectManager[0]
Failed to load project file '/Users/aki/Code/thai-number/ThaiNumber.Tests/ThaiNumber.Tests.csproj'.
info: OmniSharp.MSBuild.ProjectManager[0]
Update project: ThaiNumber
fail: OmniSharp.MSBuild.ProjectManager[0]
Attemped to update project that is not loaded: /Users/aki/Code/thai-number/ThaiNumber.Tests/ThaiNumber.Tests.csproj
But when I remove the reference in .csproj file, there is no failure.
MacOS Sierra dotnet version: 2.1.300 mono version: 5.12.0.226
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 18 (3 by maintainers)
I’ve come across this problem as well. I’m a vim user, so I rely on the http version of OmniSharp. Since 1) this is apparently fixed in the vscode extension and 2) the stacktrace mentions the
Nuget.Commonassembly I simply copied allNuget.*.dllfiles from the vscode extension (~/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp) to the http version that is located under~/.omnisharp/omnisharp-roslynon my machine and now it works.Some additional info: I have the v1.32.1 release of omnisharp-roslyn installed (default version installed by omnisharp-vim at this moment).
I run omnisharp with a system-wide mono:
and I have this dotnet core:
In my eyes copy/pasting files around like that is not really a nice option, but I’m unsure at the moment where to fix this problem. Can someone point me in the right direction? Is it a source code issue where some project in the http-stack is referencing some nuget stuff different from the stdio-stack? (doesn’t look like to me) or is some build-task that is copying files differently for stdio and http versions? If someone can point me in the right direction but doesn’t have the time to fix it, I would be willing to try 😃
I’m using omnisharp-vim (not vscode) which accesses the http version of omnisharp-roslyn, will the fix be applicable there as well?
@yufufi You want https://github.com/OmniSharp/omnisharp-roslyn/releases/tag/v1.32.5, which includes the fix we shipped in the C# Extension.
@FomTarro We believe we have identified the cause of the “GetReferenceNearestTargetFrameworkTask” issue and we’ve created a beta of the C# extension that includes the fix. Please install the beta VSIX (https://github.com/OmniSharp/omnisharp-vscode/releases/download/v1.16.1-beta1/csharp-1.16.1-beta1.vsix) and let us know if that resolves the problem