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

Error when adding reference to a classlib #2355

Closed
yuridiniz opened this issue May 30, 2018 · 3 comments
Closed

Error when adding reference to a classlib #2355

yuridiniz opened this issue May 30, 2018 · 3 comments

Comments

@yuridiniz
Copy link

Environment data

dotnet --info output:


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

VS Code version:

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

C# Extension version: ms-vscode.csharp-1.15.2

Steps to reproduce

dotnet new webapi -o Teste.Api
dotnet new classlib -o Test.MyLib
dotnet add Teste.Api/Teste.Api.csproj reference Test.MyLib/Test.MyLib.csproj

Steps to reproduce (simplified)

dotnet new webapi
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 Test.MyLib

I have verified that other issues with the same steps for execution also generates the same output, but in an earlier version, I was instructed to start a new issues, possibly the cause should be another #2286

Actual behavior

"dotnet run" works fine, but intelisense does not work, OminiSharp does not seem to work

Starting OmniSharp server at 2018-5-30 09:47:51
    Target: c:\Users\yschmitz\Documents\GitHub\Dev\teste1

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

[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\teste1'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in c:\Users\yschmitz\Documents\GitHub\Dev\teste1
[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\teste1'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Test.MyLib\Test.MyLib.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Teste.Api\Teste.Api.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\yschmitz\Documents\GitHub\Dev\teste1'.
[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\teste1' on host 6060.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Test.MyLib\Test.MyLib.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Test.MyLib\Test.MyLib.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Teste.Api\Teste.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\teste1\Teste.Api\Teste.Api.csproj'.
c:\Users\yschmitz\Documents\GitHub\Dev\teste1\Teste.Api\Teste.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".

@DustinCampbell
Copy link
Member

Thanks for filing a separate issue. I have a couple of questions:

  1. The OmniSharp Log above indicates that OmniSharp is using the MSBuild toolset from the VS 2017 Build Tools. Did you install the appropriate workloads into the VS 2017 Build Tools needed by your project (for example, correct version of .NET Framework, .NET Core, etc).

  2. If the VS 2017 Build Tools are complete, could you try setting "omnisharp.path" to "latest" in the VS Code settings? This will cause C# to download and use a newer version of OmniSharp.

@yuridiniz
Copy link
Author

Thanks @DustinCampbell

I enabled Omnisharp for Debug mode and the output displayed the following error:

FAILURE: Could not locate 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\

I uninstalled Visual Studio 2017 and removed the folder, now OminiSharp is looking for buildtools in:

\User\.vscode\extensions\ms-vscode.csharp-1.15.2\.omnisharp\1.30.1-beta.63\msbuild\15.0\Bin\

Everything is working fine

@ghost
Copy link

ghost commented Jun 16, 2018

Is there a place to manually set the path to look for buildtools at? I get this error if I have Visual Studio 2017 and VSCode 1.24.1 installed on the same machine.

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

No branches or pull requests

2 participants