'VSCode on Linux not loading .csproj file, outputs error : Some projects have trouble loading. Please review the output for more details
Mono is installed, everything is installed, but it can't load the .csproj file from Unity. Outputs an error:
Starting OmniSharp server at 26/2/2022, 8:26:37 am
Target: /E/projects/My project/My project.sln
OmniSharp server started with Mono 6.12.0.
Path: /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/OmniSharp.exe
PID: 30651
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on arch 0.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /usr/share/dotnet/dotnet
[warn]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
It looks like you have Mono 6.4.0 or greater installed but MSBuild could not be found.
Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support, or upgrade to latest Mono: https://www.mono-project.com/download/stable/.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 17.1.0 - "/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 17.1.0 - "/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/E/projects/My project'.
[info]: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/E/projects/My project/My project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/E/projects/My project/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/E/projects/My project'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/E/projects/My project' on host 30408.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /E/projects/My project/Assembly-CSharp.csproj
Can't find custom attr constructor image: /E/projects/My project/Library/ScriptAssemblies/Unity.Rider.Editor.dll mtoken: 0x0a000007 due to: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
[fail]: OmniSharp.MSBuild.ProjectLoader
The "ResolveAssemblyReference" task failed unexpectedly.
System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesDataInternal(System.Reflection.ICustomAttributeProvider)
at System.MonoCustomAttrs.GetCustomAttributesDataBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00010] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00006] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference+<>c.<Execute>b__255_4 (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.SystemState.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00010] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.GetUnifiedAssemblyMetadata (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.IEnumerable`1[Microsoft.Build.Tasks.UnifiedAssemblyName]& unifiedDependencies, System.String[]& scatterFiles) [0x00023] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure (System.Collections.Generic.IEnumerable`1[T] remappedAssembliesValue, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyFiles, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyNames, System.Collections.Generic.List`1[T] exceptions) [0x00038] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute (Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, Microsoft.Build.Tasks.GetAssemblyName getAssemblyName, Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata, Microsoft.Build.Shared.GetRegistrySubKeyNames getRegistrySubKeyNames, Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, Microsoft.Build.Tasks.GetLastWriteTime getLastWriteTime, Microsoft.Build.Tasks.GetAssemblyRuntimeVersion getRuntimeVersion, Microsoft.Build.Shared.OpenBaseKey openBaseKey, Microsoft.Build.Tasks.GetAssemblyPathInGac getAssemblyPathInGac, Microsoft.Build.Tasks.IsWinMDFile isWinMDFile, Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) [0x00515] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <29047405fcfe41bbb744a55b7d0f20fa>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002fb] in <29047405fcfe41bbb744a55b7d0f20fa>:0
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/E/projects/My project/Assembly-CSharp.csproj'.
/E/projects/My project/Assembly-CSharp.csproj
/home/mistreaper/.vscode/extensions/ms-dotnettools.csharp-1.24.0/.omnisharp/1.38.1-beta.72/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2301,5): Error: The "ResolveAssemblyReference" task failed unexpectedly.
System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not set up parent class, due to: Could not set up parent class, due to: assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/mistreaper/Unity/Hub/Editor/2020.3.30f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/E/projects/My project/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null)
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesDataInternal(System.Reflection.ICustomAttributeProvider)
at System.MonoCustomAttrs.GetCustomAttributesDataBase (System.Reflection.ICustomAttributeProvider obj, System.Type attributeType, System.Boolean inheritedOnly) [0x00010] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <62b430b945fa49a19a75382ef03e7bed>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00006] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference+<>c.<Execute>b__255_4 (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.SystemState.GetAssemblyMetadata (System.String path, System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue] assemblyMetadataCache, Microsoft.Build.Shared.AssemblyNameExtension[]& dependencies, System.String[]& scatterFiles, System.Runtime.Versioning.FrameworkName& frameworkName) [0x00010] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.GetUnifiedAssemblyMetadata (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.IEnumerable`1[Microsoft.Build.Tasks.UnifiedAssemblyName]& unifiedDependencies, System.String[]& scatterFiles) [0x00023] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure (System.Collections.Generic.IEnumerable`1[T] remappedAssembliesValue, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyFiles, Microsoft.Build.Framework.ITaskItem[] referenceAssemblyNames, System.Collections.Generic.List`1[T] exceptions) [0x00038] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute (Microsoft.Build.Shared.FileExists fileExists, Microsoft.Build.Shared.DirectoryExists directoryExists, Microsoft.Build.Tasks.GetDirectories getDirectories, Microsoft.Build.Tasks.GetAssemblyName getAssemblyName, Microsoft.Build.Tasks.GetAssemblyMetadata getAssemblyMetadata, Microsoft.Build.Shared.GetRegistrySubKeyNames getRegistrySubKeyNames, Microsoft.Build.Shared.GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, Microsoft.Build.Tasks.GetLastWriteTime getLastWriteTime, Microsoft.Build.Tasks.GetAssemblyRuntimeVersion getRuntimeVersion, Microsoft.Build.Shared.OpenBaseKey openBaseKey, Microsoft.Build.Tasks.GetAssemblyPathInGac getAssemblyPathInGac, Microsoft.Build.Tasks.IsWinMDFile isWinMDFile, Microsoft.Build.Tasks.ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) [0x00515] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <20c026c297134c06b9590841bcdf5d79>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <29047405fcfe41bbb744a55b7d0f20fa>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002fb] in <29047405fcfe41bbb744a55b7d0f20fa>:0
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /E/projects/My project/Assembly-CSharp.csproj
Am I missing anything? C# extensions are installed along with Unity extensions. Mono is also installed. I'm using Arch Linux, latest version and installed visual-studio-code-bin. Unity > External Tools > Generate .csproj files for Local packages.
Solution 1:[1]
This workaround on github comment fixed it for me.
Set the VS Code omnisharp setting "Use Modern Net" to true.
(This also entails installing dotnet sdk 6.x, and from what I see uses that version to build the projects, not sure if that breaks stuff for people using previous versions.)
Here's a screenshot of the extension settings:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | erandros |

