vscode-csharp: Problems loading Unity project
Environment data
dotnet --info
output:
.NET SDK (reflecting any global.json):
Version: 5.0.103
Commit: 72dec52dbd
Runtime Environment:
OS Name: arch
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /usr/share/dotnet/sdk/5.0.103/
Host (useful for support):
Version: 5.0.3
Commit: c636bbdc8a
.NET SDKs installed:
2.1.813 [/usr/share/dotnet/sdk]
2.2.110 [/usr/share/dotnet/sdk]
3.1.108 [/usr/share/dotnet/sdk]
5.0.103 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.NETCore.App 2.1.25 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
VS Code version: 1.53.2
C# Extension version: v1.23.9
OmniSharp log
Starting OmniSharp server at 2/23/2021, 10:53:57 PM
Target: /home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/test.sln
OmniSharp server started with Mono 6.12.0.
Path: /home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/OmniSharp.exe
PID: 1010195
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on arch 0.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 16.8.0 - "/usr/lib/mono/msbuild/Current/bin"
2: StandAlone 16.8.0 - "/home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin"
[warn]: OmniSharp.CompositionHostBuilder
It looks like you have Visual Studio 2019 installed without .NET Core SDK support which is required by OmniSharp.
Try updating Visual Studio 2019 installation with .NET Core SDK to enable better MSBuild support.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.8.0 - "/home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/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.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/test.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test' on host 1009992.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Assembly-CSharp.csproj
Can't find custom attr constructor image: /home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/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/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Library/ScriptAssemblies/UnityEngine.TestRunner.dll type:TestRunCallbackAttribute member:(null) assembly:/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/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/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/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 <efe941bb62534dc3a62ceb1a818964a0>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <efe941bb62534dc3a62ceb1a818964a0>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <efe941bb62534dc3a62ceb1a818964a0>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <efe941bb62534dc3a62ceb1a818964a0>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <284d11f275764cafba668d0e682555f7>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <efe941bb62534dc3a62ceb1a818964a0>: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 <284d11f275764cafba668d0e682555f7>:0
at (wrapper delegate-invoke) <Module>.invoke_void_string_ConcurrentDictionary`2<string, AssemblyMetadata>_AssemblyNameExtension[]&_string[]&_FrameworkName&(string,System.Collections.Concurrent.ConcurrentDictionary`2<string, Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata>,Microsoft.Build.Shared.AssemblyNameExtension[]&,string[]&,System.Runtime.Versioning.FrameworkName&)
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 <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <f7274894ce154696afba1f0ffcd06434>: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) [0x002fc] in <f7274894ce154696afba1f0ffcd06434>:0
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Assembly-CSharp.csproj'.
/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Assembly-CSharp.csproj
/home/jirka/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2123,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/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Object member:(null) assembly:/home/jirka/Programs/Unity/Editor/2019.4.20f1/Editor/Data/NetStandard/ref/2.0.0/netstandard.dll type:Attribute member:(null) assembly:/home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/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 <efe941bb62534dc3a62ceb1a818964a0>:0
at System.MonoCustomAttrs.GetCustomAttributesData (System.Reflection.ICustomAttributeProvider obj, System.Boolean inherit) [0x00011] in <efe941bb62534dc3a62ceb1a818964a0>:0
at System.Reflection.CustomAttributeData.GetCustomAttributes (System.Reflection.Assembly target) [0x00000] in <efe941bb62534dc3a62ceb1a818964a0>:0
at System.Reflection.RuntimeAssembly.GetCustomAttributesData () [0x00000] in <efe941bb62534dc3a62ceb1a818964a0>:0
at Microsoft.Build.Tasks.AssemblyInformation.GetFrameworkName () [0x00025] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyInformation.get_FrameworkNameAttribute () [0x00028] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata..ctor (System.String path) [0x00019] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.AssemblyInformation+<>c.<GetAssemblyMetadata>b__21_0 (System.String p) [0x00000] in <284d11f275764cafba668d0e682555f7>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <efe941bb62534dc3a62ceb1a818964a0>: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 <284d11f275764cafba668d0e682555f7>:0
at (wrapper delegate-invoke) <Module>.invoke_void_string_ConcurrentDictionary`2<string, AssemblyMetadata>_AssemblyNameExtension[]&_string[]&_FrameworkName&(string,System.Collections.Concurrent.ConcurrentDictionary`2<string, Microsoft.Build.Tasks.AssemblyDependency.AssemblyMetadata>,Microsoft.Build.Shared.AssemblyNameExtension[]&,string[]&,System.Runtime.Versioning.FrameworkName&)
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 <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.FindDependenciesAndScatterFiles (Microsoft.Build.Tasks.Reference reference, System.Collections.Generic.List`1[T] newEntries) [0x0003a] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.FindAssociatedFiles () [0x000ea] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure () [0x0000a] in <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>: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 <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute () [0x00000] in <284d11f275764cafba668d0e682555f7>:0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <f7274894ce154696afba1f0ffcd06434>: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) [0x002fc] in <f7274894ce154696afba1f0ffcd06434>:0
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /home/jirka/Programs/Projects/Unity/LearnUnity/FirstTry/test/Assembly-CSharp.csproj
Steps to reproduce
Create any project using Unity hub, in Unity editor create New C# script
, open it in visual studio code
Expected behavior
Loading the project correctly and working intelisense
Actual behavior
The project fails to load and intelisense is not working
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 40 (17 by maintainers)
Looking at the packages again and perhaps
mono
mono-msbuild
andmono-msbuild-sdkresolver
are all needed?I was experiencing the same issue on Arch-Linux after Upgrading Unity to
2020.2.x
, having onlyextra/mono 6.12.0.107-1
installed. This worked with Unity2020.1.x
before.My setup:
1.53.2
v1.23.9
I’m not using AUR and installing both
community/mono-msbuild 16.8.xamarinxplat.2020.07.30.15.02-1
community/mono-msbuild-sdkresolver 16.8.xamarinxplat.2020.07.30.15.02-1
fixed the problem for me.
I added your configuration notes to a wiki page - https://github.com/OmniSharp/omnisharp-vscode/wiki/Configuring-Arch-Linux-for-Unity-development. Thanks to your contribution, I will be able to point developers to that page in the future when they are having configuration issues.