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

OmniSharp fails to load project when adding reference to other project #2286

Closed
LunarLambda opened this issue May 11, 2018 · 19 comments
Closed

Comments

@LunarLambda
Copy link

LunarLambda commented May 11, 2018

Environment data

.NET Command Line Tools (2.1.101)

Product Information:
 Version:            2.1.101
 Commit SHA-1 hash:  6c22303bf0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.101\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.6
  Build    : 74b1c703813c8910df5b96f304b0f2b78cdf194d

VS Code version: 1.23.1
C# Extension version: 1.15.0

Steps to reproduce

dotnet new console
dotnet new classlib -o mylib
dotnet add reference mylib/mylib.csproj

Expected behavior

OmniSharp should load the project as normal and enable intellisense for classes inside mylib

Actual behavior

dotnet build / dotnet run work as expected, however:

OmniSharp fails to load the project console project, doesn't load mylib.csproj at all, and intellisense is not working. OmniSharp log:

Starting OmniSharp server at 2018-5-11 17:40:45
    Target: c:\Users\Luna\Desktop\Test

OmniSharp server started
    Path: C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\OmniSharp.exe
    PID: 5276

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\Luna\Desktop\Test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\Luna\Desktop\Test
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\Luna\Desktop\Test'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\Test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\mylib\mylib.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Luna\Desktop\Test\Test.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\Luna\Desktop\Test'.
[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.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\Luna\Desktop\Test' on host 5376.
[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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\Luna\Desktop\Test\Test.csproj'.
c:\Users\Luna\Desktop\Test\Test.csproj
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1656,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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.

Known workarounds

None, removing the reference to mylib.csproj from test.csproj and reloading the window causes omnisharp to load both projects correctly.

@DustinCampbell
Copy link
Member

Hi! Could you provide your full OmniSharp Log after loading this project? You can find this by selecting View->Output from the VS Code menu and then selecting "OmniSharp Log" from the dropdown at the top-right corner of the Output pane.

@LunarLambda
Copy link
Author

LunarLambda commented May 11, 2018

Starting OmniSharp server at 2018-5-11 16:58:29
    Target: c:\Users\Luna\Desktop\Test

OmniSharp server started
    Path: C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\OmniSharp.exe
    PID: 6660

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.6.27428.2037 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.6.27428.2037 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\Luna\Desktop\Test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\Luna\Desktop\Test
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\Luna\Desktop\Test'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\Test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\mylib\mylib.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\Luna\Desktop\Test'.
[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.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\Luna\Desktop\Test' on host 9552.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Luna\Desktop\Test\Test.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\Luna\Desktop\Test\Test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Luna\Desktop\Test\mylib\mylib.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\Luna\Desktop\Test\mylib\mylib.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Test
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: mylib
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\Test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Luna\Desktop\Test\Test.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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\Luna\Desktop\Test\Test.csproj'.
c:\Users\Luna\Desktop\Test\Test.csproj
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1603,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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.

@DustinCampbell
Copy link
Member

Could you try updating your VS 2017 Build Tools to the latest (15.7.1)?

@LunarLambda
Copy link
Author

Will do and report back asap.

@DustinCampbell
Copy link
Member

FWIW, the log's look identical. It doesn't appear that the VS 2017 build tools were actually updated. They have the same version numbers: 15.6.27428.2043. I just installed the latest VS 2017 build tools locally and the version is 15.7.27703.2000.

@LunarLambda
Copy link
Author

My bad, it's updating a second time now, this time for 15.7.1, sorry!

@LunarLambda
Copy link
Author

LunarLambda commented May 11, 2018

Okay, updated, version numbers match what you said, tried again, same procedure, same result.
Also, it does't appear to load mylib.csproj at all, even when opening / editing files that belong to it.
Removing the reference from the project file fixes the issue.

dotnet new console
dotnet new classlib -o mylib
dotnet add reference mylib/mylib.csproj
opened Program.cs to start OmniSharp

Starting OmniSharp server at 2018-5-11 17:40:45
    Target: c:\Users\Luna\Desktop\Test

OmniSharp server started
    Path: C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\OmniSharp.exe
    PID: 5276

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Luna\.vscode\extensions\ms-vscode.csharp-1.15.0\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\Luna\Desktop\Test'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\Luna\Desktop\Test
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\Luna\Desktop\Test'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\Test.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\Luna\Desktop\Test\mylib\mylib.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\Luna\Desktop\Test\Test.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\Luna\Desktop\Test'.
[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.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\Luna\Desktop\Test' on host 5376.
[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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\Luna\Desktop\Test\Test.csproj'.
c:\Users\Luna\Desktop\Test\Test.csproj
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1656,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:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin" directory.

PS: Updated original post with extra info

@DustinCampbell
Copy link
Member

Thanks for the update and sorry it didn't work. 😞

Out of curiosity, do you actually have the .NET Core workload installed into the VS 2017 build tools?

@LunarLambda
Copy link
Author

No, the .NET Core workload in the build tools only installs 1.0.0 from what I remember (maybe they changed it by now)

I installed the latest SDK manually. Install path and everything should be the same so I don't think it'd make a difference either way

@DustinCampbell
Copy link
Member

I believe the .NET Core workload installs newer than 1.0.0 now. I would expect it to be the same tools installed with VS 2017 15.7. @AndyGerlicher / @rainersigwald, is that the case?

So, the problem seems to be that OmniSharp is trying to use the instance of MSBuild from the VS 2017 Build Tools, but the .NET Core workload is not installed.

@LunarLambda
Copy link
Author

Should I try installing the .NET Core workload from the VS Build Tools installer then?

@rainersigwald
Copy link
Member

I believe the 15.7 build tools installer .NET Core workload installs the .NET Core SDK version 2.1.200.

@rainersigwald
Copy link
Member

(and also some other things, so I would expect it to be worth trying)

@LunarLambda
Copy link
Author

Alright, will try

@LunarLambda
Copy link
Author

Installing the NET Core workload worked! Thanks a lot! (Although for the future, would it be possible to make it so that it works with standalone installs too?)

image

@DustinCampbell
Copy link
Member

Excellent! I'll look into adding an option for OmniSharp to allow you to choose which MSBuild instance will be picked. OmniSharp's standalone MSBuild bits would have almost certainly worked in this case.

@DustinCampbell
Copy link
Member

I've created OmniSharp/omnisharp-roslyn#1186 to track adding some options.

@yuridiniz
Copy link

yuridiniz commented May 29, 2018

I'm having the same problem, even in the current version still happening :(

dotnet --info

Ferramentas de Linha de Comando do .NET (2.1.200)

Product Information:
 Version:            2.1.200
 Commit SHA-1 hash:  2edba8d7f1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16299
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.200\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

OmniSharp log

OmniSharp server started
    Path: C:\Users\yschmitz\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1\OmniSharp.exe
    PID: 10312

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Ferramentas de Build do Visual Studio 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\yschmitz\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Ferramentas de Build do Visual Studio 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\yschmitz\Documents\GitHub\Dev\Server'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\yschmitz\Documents\GitHub\Dev\Server
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Users\yschmitz\Documents\GitHub\Dev\Server'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\yschmitz\Documents\GitHub\Dev\Server\Snm.Api\Snm.Api.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\yschmitz\Documents\GitHub\Dev\Server\Snm.Business\Snm.Business.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\yschmitz\Documents\GitHub\Dev\Server'.
[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.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\yschmitz\Documents\GitHub\Dev\Server' on host 16580.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\yschmitz\Documents\GitHub\Dev\Server\Snm.Api\Snm.Api.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        A tarefa "GetReferenceNearestTargetFrameworkTask" não foi encontrada. Verifique se: 1.) O nome da tarefa no arquivo de projeto é o mesmo nome da classe da tarefa. 2.) A classe da tarefa é "public" e implementa a interface Microsoft.Build.Framework.ITask. 3.) A tarefa está declarada corretamente com <UsingTask> no arquivo de projeto ou nos arquivos *.tasks localizados no diretório "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin".
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\yschmitz\Documents\GitHub\Dev\Server\Snm.Api\Snm.Api.csproj'.
c:\Users\yschmitz\Documents\GitHub\Dev\Server\Snm.Api\Snm.Api.csproj
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1656,5): Error: A tarefa "GetReferenceNearestTargetFrameworkTask" não foi encontrada. Verifique se: 1.) O nome da tarefa no arquivo de projeto é o mesmo nome da classe da tarefa. 2.) A classe da tarefa é "public" e implementa a interface Microsoft.Build.Framework.ITask. 3.) A tarefa está declarada corretamente com <UsingTask> no arquivo de projeto ou nos arquivos *.tasks localizados no diretório "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"

VsCode

Version 1.23.1
Commit d0182c3417d225529c6d5ad24b7572815d0de9ac
Date 2018-05-10T17:11:17.614Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

@DustinCampbell
Copy link
Member

@yuridiniz : Could you file a new issue? The underlying problem reported here was discovered. I suspect you're experience a different problem that may look similar.

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

4 participants