csharp-ls can't find its references to load on projects built with msbuild
Configuration
- Distro: NixOS on unstable branch
- Editor: Neovim
- csharp-ls version: 0.8.0
Bug
After opening a .cs file from a .net framework 4.8 project, it fails to load basic dependencies throwing unusable error warnings on the screen.
After looking at the output of :messages:
LSP[csharp_ls][Info] csharp-ls: initializing, csharp-ls version 0.8.0.0; cwd: "/home/locochoco/rw-mods/pd-detection/pd-detection"
LSP[csharp_ls][Info] csharp-ls: csharp-ls is released under MIT license and is not affiliated with Microsoft Corp.; see https://github.com/raz
zmatazz/csharp-language-server
LSP[csharp_ls][Info] csharp-ls: MSBuildLocator: will register ".NET Core SDK", Version=7.0.403 as default instance
LSP[csharp_ls][Log] csharp-ls: attempting to find and load solution based on cwd ("/home/locochoco/rw-mods/pd-detection/pd-detection")..
LSP[csharp_ls][Log] csharp-ls: 0 solution(s) found: []
LSP[csharp_ls][Log] csharp-ls: no or multiple .sln files found on /home/locochoco/rw-mods/pd-detection/pd-detection
LSP[csharp_ls][Log] csharp-ls: looking for .csproj/fsproj files on /home/locochoco/rw-mods/pd-detection/pd-detection..
LSP[csharp_ls][Log] csharp-ls: loading project "/home/locochoco/rw-mods/pd-detection/pd-detection/pd-detection.csproj"..
LSP[csharp_ls][Log] csharp-ls: OK, 1 project files loaded
LSP[csharp_ls][Log] csharp-ls: msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file '/home/locochoco/rw-mods/pd-det
ection/pd-detection/pd-detection.csproj' with message: /nix/store/j5rfwd16fngw915jsxgdfr7009sda5fm-dotnet-core-combined/sdk/7.0.403/Microsoft.
Common.CurrentVersion.targets: (1241, 5): The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the
Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs
at https://aka.ms/msbuild/developerpacks
LSP[csharp_ls][Log] csharp-ls: msbuildWorkspace.Diagnostics: [Warning] Unresolved metadata reference removed from project: /mscorlib.dll
"PDDetection.cs" 86L, 3149B written
it looks like it couldn't find the path of the mono libraries.
Doing export FrameworkPathOverride=MONO_API_PATH was able to make the language server find those dependencies, but it would then brake building from msbuild, and would incorrectly load/not find other libraries.
As I am not sure if this is a problem related to csharp-ls or how it is being packaged/configured for NixOs, I also made this issue https://github.com/nix-community/nixvim/issues/679 on the nixvim configuration flake.
I have uploaded a newer version of csharp-ls that has msbuild.locator lib updated–not really sure if related but you may want to check if it helps.
I was not getting this with 0.10.0 but now I am with 0.11.0 and building from source. My project is using dotnet 6.0.