dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Some projects have trouble loading. Please review the output for more details. #2751

Closed kenjiuno closed 1 week ago

kenjiuno commented 5 years ago

Environment data

dotnet --info output:

PS D:\Proj\Oseibo> dotnet --info
.NET Core SDK (global.json を反映):
 Version:   2.1.403
 Commit:    04e15494b6

ランタイム環境:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.403\

Host (useful for support):
  Version: 2.1.5
  Commit:  290303f510

.NET Core SDKs installed:
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

VS Code version: 1.30.0

[Window Title]
Visual Studio Code

[Main Instruction]
Visual Studio Code

[Content]

バージョン: 1.30.0 (system setup)
コミット: c6e592b2b5770e40a98cb9c2715a8ef89aec3d74
日付: 2018-12-11T22:29:11.253Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 10.0.17134

[OK] [コピー (C)]

C# Extension version: 1.17.1

Steps to reproduce

  1. Launch VSCode.
  2. Open ASP.NET Core project.
  3. Open C# source code. Warning will be displayed: warn
  4. Try IntelliSense at C# code like services.

Expected behavior

Try

SET MSBuildSDKsPath=C:\Program Files\dotnet\sdk\2.1.403\Sdks

before launching VSCode will be:

intelli sense work

Actual behavior

intelli sense wont work

Show Output

Entire log: ``` Starting OmniSharp server at 12/18/2018, 10:50:56 AM Target: d:\Proj\Oseibo OmniSharp server started. Path: C:\Users\USER\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe PID: 12812 [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 3 MSBuild instance(s) 1: Visual Studio 2017 Desktop Express 15.8.28010.2050 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin" 2: Visual Studio Professional 2017 15.8.28010.2050 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin" 3: StandAlone 15.0 - "C:\Users\USER\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Visual Studio 2017 Desktop Express 15.8.28010.2050 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin" [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'd:\Proj\Oseibo'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.WorkspaceInitializer Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration. [info]: OmniSharp.MSBuild.ProjectSystem No solution files found in 'd:\Proj\Oseibo' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Proj\Oseibo\Oseibo.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'd:\Proj\Oseibo'. [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Proj\Oseibo\Oseibo.csproj [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'd:\Proj\Oseibo' on host 6564. [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file 'd:\Proj\Oseibo\Oseibo.csproj'. d:\Proj\Oseibo\Oseibo.csproj(1,1) Microsoft.Build.Exceptions.InvalidProjectFileException: 指定された SDK 'Microsoft.NET.Sdk.Web' は見つかりませんでした。 d:\Proj\Oseibo\Oseibo.csproj 場所 Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args) 場所 Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError) 場所 Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) 場所 Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) 場所 Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) 場所 Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext) 場所 Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) 場所 Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) 場所 Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) 場所 Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) 場所 Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion) 場所 OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath) 場所 OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath) 場所 OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader) 場所 OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) [fail]: OmniSharp.MSBuild.ProjectManager Attemped to update project that is not loaded: d:\Proj\Oseibo\Oseibo.csproj ```

Point

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio 2017 Desktop Express 15.8.28010.2050 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin"
            2: Visual Studio Professional 2017 15.8.28010.2050 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
            3: StandAlone 15.0 - "C:\Users\USER\.vscode\extensions\ms-vscode.csharp-

1: Visual Studio 2017 Desktop Express seems to be selected. I prefer 2: Visual Studio Professional 2017 as a primary selection.

matfantinel commented 5 years ago

I am having the same issue in Manjaro, running export MSBuildSDKsPath=/opt/dotnet/sdk/2.2.100/Sdks also worked as a workaround.

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.100
 Commit:    b9f2fa0ca8

Runtime Environment:
 OS Name:     manjaro
 OS Version:  
 OS Platform: Linux
 RID:         arch-x64
 Base Path:   /opt/dotnet/sdk/2.2.100/

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  2.2.100 [/opt/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.NETCore.App 2.2.0 [/opt/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
ksivasenthil commented 5 years ago

@matfantinel where did you run the export command?

matfantinel commented 5 years ago

@ksivasenthil on system's Terminal, before opening VS Code. Doesn't matter which folder you're on.

kenjiuno commented 4 years ago

IMO This isn't an easy problem? Because MSBuildSDKsPath depends on project's <TargetFramework>.

My MSBuildSDKsPath for netcoreapp3.1 is:

set MSBuildSDKsPath=C:\Program Files\dotnet\sdk\3.1.101\Sdks
code .

csproj

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

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

  <ItemGroup>
    <PackageReference Include="CommandLineParser" Version="2.6.0" />
    <PackageReference Include="CsvHelper" Version="15.0.0" />
    <PackageReference Include="Dapper" Version="2.0.30" />
    <PackageReference Include="npgsql" Version="4.1.2" />
    <PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
  </ItemGroup>

</Project>
JoeRobich commented 1 week ago

A lot has changed with project loading since this issue as opened. If you are still running into problems, please open a new issue.