Closed loco-choco closed 11 months ago
Update: exporting export FrameworkPathOverride=/nix/store/HASH-mono-6.12.0.182/lib/mono/4.8-api
actually allowed it to find the references in some situations.
Hmm weird. I am very unfamiliar with csharp. If it happens to be caused by the plugin configuration (or fixable by nixvim) I would be glad to review/merge it.
Could you try to replicate this bug in a non-nixvim (and even non-nix) environment ? (Same config on a classically installed and configured neovim)
I will try on a non nixvim enviroment. It also looks like there is a newer version of the ls that isn't on nixpkgs-unstable, so will also try that.
I made a PR to update csharp-ls
. I completely forgot that I was the maintainer for this !
Could you please update your flake inputs and re-try ?
You should now get the latest version of csharp-ls
(0.10.0).
Still the same issue sadly.
But I think I know why now, I guess it is an issue with dotnet msbuild not working well with .net framework projects in linux, cause it can't find the mono version of the assemblies.
Maybe if there was a way to make it look for the mono assemblies, without breaking msbuild, it would make it work, because even on this "broken" state, it can still warn if you are calling a function from a 3rd library wrong.
Ok, good to know.
Anyway, it is not related to nixvim nor the csharp-ls
package in nixpkgs
.
I will thus be closing this issue.
Good luck with it !
I know the issue is closed, but just found a work around to use dotnet build
with mono libraries, and wanted to have it here if someone finds themselves on the same situation.
Based on the solution in here, you can have a file called netfx.props
in your project, with the contents:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- When compiling .NET SDK 2.0 projects targeting .NET 4.x on Mono using 'dotnet build' you -->
<!-- have to teach MSBuild where the Mono copy of the reference asssemblies is -->
<TargetIsMono Condition="$(TargetFramework.StartsWith('net4')) and '$(OS)' == 'Unix'">true</TargetIsMono>
<!-- Look in the standard install locations -->
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/Library/Frameworks/Mono.framework/Versions/Current/lib/mono')">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono</BaseFrameworkPathOverrideForMono>
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
<!-- If we found Mono reference assemblies, then use them -->
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net45'">$(BaseFrameworkPathOverrideForMono)/4.5-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net451'">$(BaseFrameworkPathOverrideForMono)/4.5.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net452'">$(BaseFrameworkPathOverrideForMono)/4.5.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net46'">$(BaseFrameworkPathOverrideForMono)/4.6-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net461'">$(BaseFrameworkPathOverrideForMono)/4.6.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net462'">$(BaseFrameworkPathOverrideForMono)/4.6.2-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net471'">$(BaseFrameworkPathOverrideForMono)/4.7.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net48'">$(BaseFrameworkPathOverrideForMono)/4.8-api</FrameworkPathOverride>
<EnableFrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">true</EnableFrameworkPathOverride>
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
</PropertyGroup>
</Project>
And import it on your .csproj with the <Import Project="./netfx.props" />
line.
It should now allow dotnet build
to find the build dependencies, and thus allow csharp-ls to work.
Plugin affected: csharp-ls Nixpkgs channel: unstable Home-manager version: master
Description
After running neovim in a .cs file from a .net framework 4.8 project, it fails to load basic dependencies throwing unusable error warnings on the screen.
Here are the
:messages
it returns:I was able to get it to find the mscorlib dependencies by exporting
export FrameworkPathOverride=/nix/store/HASH-mono-6.12.0.182/lib/mono/4.8-api
before opening the file, but it kept not finding the other references, even thoughmsbuild
compiles the solution without an issue.Config