Skip to content

Unexpected errors on when running cli program outside of directory with solution #321

@nickbeaird

Description

@nickbeaird

I am new to the project and I ran into an error on the CLI invocation. I downloaded the tooling according to the command in the README dotnet tool install --global csharp-ls. I followed the output of that and ran csharp-ls and I received uncaught System.AggregateException: One or more errors occurred. (Header does not end with expected \r\n character sequence: ). I believe that this might related to ticket #106 .

I am am on an M1 mac and I have dotnet 10.0.100 installed.

Error output:

20:30:41.764 fail: LSP[0]
      System.AggregateException: One or more errors occurred. (Header does not end with expected \r\n character sequence: )
       ---> StreamJsonRpc.BadRpcHeaderException: Header does not end with expected \r\n character sequence:
         at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadHeadersAsync(CancellationToken cancellationToken)
         at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadCoreAsync(CancellationToken cancellationToken)
         at StreamJsonRpc.MessageHandlerBase.ReadAsync(CancellationToken cancellationToken)
         at StreamJsonRpc.JsonRpc.ReadAndHandleRequestsAsync()
         --- End of inner exception stack trace ---
         at Ionide.LanguageServerProtocol.Server.startWithSetupCore[client](FSharpFunc`2 setupRequestHandlings, IJsonRpcMessageHandler jsonRpcHandler, FSharpFunc`2 clientCreator, FSharpFunc`2 customizeRpc) in /_//src/LanguageServerProtocol.fs:line 215
         at Ionide.LanguageServerProtocol.Server.startWithSetup[client](FSharpFunc`2 setupRequestHandlings, Stream input, Stream output, FSharpFunc`2 clientCreator, FSharpFunc`2 customizeRpc) in /_//src/LanguageServerProtocol.fs:line 230
         at Ionide.LanguageServerProtocol.Server.start@271-1.Invoke(FSharpFunc`2 customizeRpc)
         at CSharpLanguageServer.Lsp.Server.startCore(ServerSettings settings) in /_//src/CSharpLanguageServer/Lsp/Server.fs:line 479
         at CSharpLanguageServer.Lsp.Server.start(ServerSettings options) in /_//src/CSharpLanguageServer/Lsp/Server.fs:line 484 crashed
Image

I did run the troubleshooting csharp-ls --diagnose and interestingly it seems that the program then tries to recursively iterate through all of the git projects that I have that are children of the repo that I started in. I keep most of my projects in a directory called code and there are a number of projects that have a .sln file installed.

..... <truncated output>

      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/Tools/dotnet-sql-cache/src/dotnet-sql-cache.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.408 dbug: Roslyn.Solution[0]
      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/Tools/dotnet-user-jwts/src/dotnet-user-jwts.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.418 dbug: Roslyn.Solution[0]
      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/Tools/dotnet-user-jwts/test/dotnet-user-jwts.Tests.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.428 dbug: Roslyn.Solution[0]
      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.440 dbug: Roslyn.Solution[0]
      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/Tools/dotnet-user-secrets/test/dotnet-user-secrets.Tests.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.449 dbug: Roslyn.Solution[0]
      loadProjectTfms: failed to load /Users/nick/code/aspnetcore/src/WebEncoders/src/Microsoft.Extensions.WebEncoders.csproj: Microsoft.Build.Exceptions.InvalidProjectFileException
20:53:22.453 info: Roslyn.Solution[0]
      Will use MSBuild props: map []
20:53:23.225 dbug: Diagnostics[0]
WindowShowMessage: csharp-ls: Solution "/Users/nick/code/aspnetcore/AspNetCore.sln" could not be loaded: System.AggregateException: One or more errors occurred. (An exception of type System.InvalidOperationException was thrown: Error while calling hostfxr function hostfxr_resolve_sdk2. Error code: -2147450725 Detailed error: A compatible .NET SDK was not found.

      Requested SDK version: 9.0.100-preview.2.24078.1
      global.json file: /Users/nick/code/aspnetcore/global.json

      Installed SDKs:

      Install the [9.0.100-preview.2.24078.1] .NET SDK or update [/Users/nick/code/aspnetcore/global.json] to match an installed SDK.

      Learn about SDK resolution:
      https://aka.ms/dotnet/sdk-not-found
      )
       ---> Microsoft.CodeAnalysis.MSBuild.RemoteInvocationException: An exception of type System.InvalidOperationException was thrown: Error while calling hostfxr function hostfxr_resolve_sdk2. Error code: -2147450725 Detailed error: A compatible .NET SDK was not found.

      Requested SDK version: 9.0.100-preview.2.24078.1
      global.json file: /Users/nick/code/aspnetcore/global.json

      Installed SDKs:

      Install the [9.0.100-preview.2.24078.1] .NET SDK or update [/Users/nick/code/aspnetcore/global.json] to match an installed SDK.

      Learn about SDK resolution:
      https://aka.ms/dotnet/sdk-not-found

         at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeCoreAsync(Int32 targetObject, String methodName, List`1 parameters, Type expectedReturnType, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeNullableAsync[T](Int32 targetObject, String methodName, List`1 parameters, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.<GetBuildHostAsync>g__NoLock_GetBuildHostAsync|15_0(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostWithFallbackAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectFileInfosAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadProjectInfosFromPathAsync(String projectPath, DiagnosticReportingOptions reportingOptions, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.LoadAsync(CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
         at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenSolutionAsync(String solutionFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
20:53:23.226 dbug: Diagnostics[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions