Open reaz1995 opened 1 year ago
Omnisharp-roslyn runs in wsl (Ubuntu) The assembly files of Unity are located on Windows. There no way to bypass unity auto generate csproj file with windows paths. So the only way to make it works is to update omnisharp-roslyn.
Please make omnisharp-roslyn to look up for wsl paths if it can't resolve windows paths, or check for platform then translate paths to look up for assemblies.
Thats how the error loks like:
[ERROR][2024-08-13 12:50:45] ...lsp/handlers.lua:535 "OmniSharp.MSBuild.ProjectManager: Failure while loading the analyzer reference 'Microsoft.Unity.Analyzers': Could not find a part of the path '/mnt/c/Users/User/Desktop/Unity_Projects/Game/C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/Extensions/Microsoft/Visual Studio Tools for Unity/Analyzers/Microsoft.Unity.Analyzers.dll'. | "
it does stack up the local path(in wsl format) of project with the reference path to assemblies(in windows format)
When manually change path from Windows path to wsl path, like so:
<Reference Include="UnityEngine">
<HintPath>/mnt/c/Program Files/Unity/Hub/Editor/2021.3.26f1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>
</Reference>
Omnisharp-roslyn starts to works correctly.
if anyone wonders how to make nvim lsp omnisharp works with Unity, here the solution: https://github.com/reaz1995/UnityNvimSupport
I would like use it for unity projects, but omnisharp can't resolve Windows paths of Unity and VS assemblies. Unity generate Assembly-CSharp.csproj file with paths for Unity assemblies
and VS assemblies
After manually converting to wsl paths, omnisharp load quick and provide all of its features.
Autocheck every path and translate would solve this problem.
@@ edit First fails the analyzer
https://github.com/OmniSharp/omnisharp-roslyn/blob/0f526554c1488891ec524629c031d1c2782bef1f/src/OmniSharp.MSBuild/ProjectManager.cs#L374
then other assemblies fails silently without logging https://github.com/OmniSharp/omnisharp-roslyn/blob/0f526554c1488891ec524629c031d1c2782bef1f/src/OmniSharp.Host/Services/AssemblyLoader.cs#LL79C25-L79C25
Hows about to add another check for os platform then check if assemblies exist under translated path?