csharp-language-server icon indicating copy to clipboard operation
csharp-language-server copied to clipboard

No instances of MSBuild could be detected

Open pandasoli opened this issue 11 months ago • 3 comments

System: Windows Tiny11

After installing and installing .Net v8 and open my editor I see this error:

Error executing vim.schedule lua callback: ...m Files/Neovim/share/nvim/runtime/lua/vim/lsp/client.lua:588: RPC[Error] code_name = InternalError, message = "System.InvalidOperationException: No instances of MSBuild could be detected.\13\
Try calling RegisterInstance or RegisterMSBuildPath to manually register one.\13\
   at CSharpLanguageServer.Handlers.Initialization.handleInitialize@52-6.Invoke(Unit _arg2) in /_//src/CSharpLanguageServer/Handlers/Initialization.fs:line 55\13\
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\\workspace\\_work\\1\\s\\src\\fsharp\\FSharp.Core\\async.fs:line 464\13\
   at Ionide.LanguageServerProtocol.Server.sendServerNotification@139-3.Invoke(AsyncActivation`1 ctxt)\13\
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\\workspace\\_work\\1\\s\\src\\fsharp\\FSharp.Core\\async.fs:line 104"
stack traceback:
        [C]: in function 'assert'
        ...m Files/Neovim/share/nvim/runtime/lua/vim/lsp/client.lua:588: in function 'fn'
        vim/_editor.lua:351: in function <vim/_editor.lua:350>

pandasoli avatar Jan 08 '25 02:01 pandasoli

changing the dotnet version of the solution to the installed dotnet-sdk seems to fix this

Arrow-x avatar Jan 28 '25 18:01 Arrow-x

in every c# project there is a <project_name>.csproj xml file there is a tag like so

<TargetFramework>net8.0</TargetFramework>

since you have an updated dotnet-sdk, just change that 8 to 9 on every project

dotnet sdk is backward compatible so this shouldn't be happening though On Wednesday, February 5th, 2025 at 7:40 PM, spacexmoon @.***> wrote:

changing the dotnet version of the solution to the installed dotnet-sdk seems to fix this

what do you mean how do i know what version do i need and how to tell neovim to use that version

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Arrow-x avatar Feb 05 '25 18:02 Arrow-x

I'm also hitting this on Windows 10 with Neovim v0.10.3.

The output of my "dotnet --list-sdks" command: 9.0.102 [C:\Program Files\dotnet\sdk]

And in my .csproj file I have the Target Framework set to "net9.0".

yash3ahuja avatar Feb 13 '25 20:02 yash3ahuja

I figured out the fix, at least for my issue, it turns out you need to have .NET 8.0 installed, having .NET 9.0 is not sufficient. After installing .NET 8.0, the LSP correctly starts up for me.

yash3ahuja avatar Feb 13 '25 21:02 yash3ahuja