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
What version of the .NET Core SDK are running? Could you provide the output of dotnet --info?
I'm having the exact same issue. Please see below for the output of dotnet --info
Note that I'm running omnisharp-roslyn 1.32.1 due to issue #1274 in latest.
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.401/
Host (useful for support):
Version: 2.1.3
Commit: 124038c13e
.NET Core SDKs installed:
2.1.200 [/usr/local/share/dotnet/sdk]
2.1.401 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Same issue for me, with similar output.
Downgrading msbuild from 15.8 back to 15.6 got it working again for me.
I was able to build the solution directly using msbuild 15.8 even when Omnisharp was failing to load it with the GetReferenceNearestTargetFrameworkTask failure errors.
Currently encountering this same error using VS Code. It was fine yesterday with no conscious software changes.
PS S:\Git Repos\gARden> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.301
Commit: 59524873d6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.301\
Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684
.NET Core SDKs installed:
2.1.301 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
@rudism @FomTarro Can you set "omnisharp.loggingLevel": "debug" in VS Code's options and share you OmniSharp log?
@rudism @FomTarro Can you set
"omnisharp.loggingLevel": "debug"in VS Code's options and share you OmniSharp log?
As additional info, I am using Unity version 2018.1. Haven't updated Unity since the spring, and as I said all was working fine last night.
Here's the full log, I think:
Starting OmniSharp server at 9/11/2018, 2:30:53 PM
Target: s:\Git Repos\gARden\gARden.sln
OmniSharp server started.
Path: C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\OmniSharp.exe
PID: 3848
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild
MSBuildToolsPath = C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 's:\Git Repos\gARden'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.Stdio.Host
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 's:\Git Repos\gARden\gARden.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 's:\Git Repos\gARden\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 's:\Git Repos\gARden\Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 's:\Git Repos\gARden\Assembly-CSharp-Editor-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 's:\Git Repos\gARden\Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 's:\Git Repos\gARden'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.Stdio.Host
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: s:\Git Repos\gARden\Assembly-CSharp.csproj
[info]: OmniSharp.Stdio.Host
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 's:\Git Repos\gARden' on host 9336.
[fail]: OmniSharp.MSBuild.ProjectLoader
The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 's:\Git Repos\gARden\Assembly-CSharp.csproj'.
s:\Git Repos\gARden\Assembly-CSharp.csproj
C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1657,5): Error: The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: s:\Git Repos\gARden\Assembly-CSharp-firstpass.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 's:\Git Repos\gARden\Assembly-CSharp-firstpass.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project 's:\Git Repos\gARden\Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: s:\Git Repos\gARden\Assembly-CSharp-Editor-firstpass.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 's:\Git Repos\gARden\Assembly-CSharp-Editor-firstpass.csproj'.
s:\Git Repos\gARden\Assembly-CSharp-Editor-firstpass.csproj
C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1657,5): Error: The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: s:\Git Repos\gARden\Assembly-CSharp-Editor.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 's:\Git Repos\gARden\Assembly-CSharp-Editor.csproj'.
s:\Git Repos\gARden\Assembly-CSharp-Editor.csproj
C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1657,5): Error: The "GetReferenceNearestTargetFrameworkTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Users\Steam\.vscode\extensions\ms-vscode.csharp-1.16.0\.omnisharp\1.32.4\msbuild\15.0\Bin" directory.
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: s:\Git Repos\gARden\Assembly-CSharp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-firstpass
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: s:\Git Repos\gARden\Assembly-CSharp-Editor-firstpass.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attemped to update project that is not loaded: s:\Git Repos\gARden\Assembly-CSharp-Editor.csproj
@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
This solves the problem, yeah
I'm using omnisharp-vim (not vscode) which accesses the http version of omnisharp-roslyn, will the fix be applicable there as well?
@rchande, are you referring to a fix omnisharp-vscode? Please note that this is the issue tracking for omnisharp-roslyn and the original issue was reproduced through omnisharp-vim.
@yufufi You want https://github.com/OmniSharp/omnisharp-roslyn/releases/tag/v1.32.5, which includes the fix we shipped in the C# Extension.
I believe this issue is fixed now--I'm going to close it, but feel free to keep discussing if you think it isn't.
Thanks @rchande. Unfortunately vim users on Mac/Linux are currently stuck on v1.32.1 due to #1274. And debugging/fixing #1274 is tricky because building on Linux doesn't work, see #1202. I've been waiting on a GitVersion fix, as @DustinCampbell suggested, not sure what more to do at this stage.
@nickspoons I left you a comment on #1202 -- basically, I would recommend disabling the GitVersion phase of the build so you're able to build/debug.
What are my options around #1258 & #1274? I am on Arch Linux with Vim
@mysteryjeans the latest OmniSharp-roslyn _release_ which works with vim is 1.32.1 - install this version in vim (using the latest OmniSharp-vim) by runnig :OmniSharpInstall 'v1.32.1' (in fact currently you only need to do :OmniSharpInstall - we've set the default to v1.32.1 until #1274 is resolved).
However, I believe it's a problem with the releases that is causing the HTTP connection issues seen in #1274, not the code. Building your own OmniSharp-roslyn should let you use the latest version from vim.
Unfortunately, building is also not straightforward at the moment, due to #1202. I did manage it on an Arch Linux system eventually, see my steps here
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.Common assembly I simply copied all Nuget.*.dll files 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-roslyn on 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:
tmadsen@mini ~
❯ mono --version
Mono JIT compiler version 5.18.0.225 (2018-08/bac9fc1f889 Fri Dec 21 11:33:29 EST 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS:
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(600)
Suspend: preemptive
GC: sgen (concurrent by default)
and I have this dotnet core:
tmadsen@mini ~
❯ dotnet --version
2.2.101
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 :)
All my problems were solved by installing msbuild, which wrongly I assumed was installed via mono-complete
sudo dnf install msbuild
" C#
let g:OmniSharp_highlight_types = 1
let g:OmniSharp_proc_debug = 1
let g:OmniSharp_loglevel = 'debug'
Once msbuild is installed, following the prompt to install rosyln, the debug logs showed a happy Omni-vim
dotnet --version
2.2.103
mono --version
Mono JIT compiler version 5.18.0.240 (tarball Thu Jan 17 08:37:29 UTC 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(600)
Suspend: preemptive
GC: sgen (concurrent by default)
Most helpful comment
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 :)