I’ve been trying all day to get code completion to work in Visual Studio Code, which at some point worked, but now it doesn’t. Does anyone have the same problem? Or could someone post the version numbers of their working configuration? I’m on Windows 10 x64.
Installed extensions
Installed .NET SDKS
Visual Studio Code Version
Unity package installed
I’ve tried both versions 1.2.2 (latest) and 1.2.1
Additional
I’ve also installed .NET Framework 4.6 Targeting Pack as per the suggestion of this guide (which I followed): Visual Studio Code and Unity
Problem Description
Code completion does not work (see first image). This is caused I think by OmniSharp not understanding the project (?) and crashing.
I’m posting the OmniSharp log. Note that the crash is not related to SimpleCameraController.cs
, as it happens with any script. Note that it happens in any new or existing project. I’ve also tried to ‘regenerate project files’ in the external tools section.
Any help would be greatly appreciated!
/*
Starting OmniSharp server at 9/22/2020, 1:11:31 PM
Target: l:\repositories\newtestproject\newtestproject\newtestproject.sln
OmniSharp server started.
Path: c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\OmniSharp.exe
PID: 1384
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2017 15.9.28307.1259 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
2: StandAlone 16.8.0 - "c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
[warn]: OmniSharp.CompositionHostBuilder
It looks like you have Visual Studio lower than VS 2019 16.3 installed.
Try updating Visual Studio to the most recent release to enable better MSBuild support.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin"
CscToolExe = csc.exe
CscToolPath = c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\Roslyn
MSBuildExtensionsPath = c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild
MSBuildToolsPath = c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'l:\repositories\newtestproject\newtestproject'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'l:\repositories\newtestproject\newtestproject\newtestproject.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'l:\repositories\newtestproject\newtestproject\Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'l:\repositories\newtestproject\newtestproject'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj
[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.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'l:\repositories\newtestproject\newtestproject' on host 7824.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj'.
l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The expression ""Assets\Scripts\SimpleCameraController.cs".GetPathsOfAllDirectoriesAbove()" cannot be evaluated. Method 'System.String.GetPathsOfAllDirectoriesAbove' not found. c:\Users\Username\.vscode\extensions\ms-dotnettools.csharp-1.23.2\.omnisharp\1.37.1\.msbuild\Current\Bin\Roslyn\Microsoft.Managed.Core.targets
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1,T2](IElementLocation elementLocation, String resourceName, T1 arg0, T2 arg1)
at Microsoft.Build.Evaluation.Expander`2.Function`1.Execute(Object objectInstance, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Expander`2.ItemExpander.IntrinsicItemFunctions`1.<ExecuteStringFunction>d__13.MoveNext()
at Microsoft.Build.Evaluation.Expander`2.ItemExpander.<Transform>d__0`1.MoveNext()
(...the call stack does on for a bit, then an similar crash, then...)
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: l:\repositories\newtestproject\newtestproject\Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: l:\repositories\newtestproject\newtestproject\Assembly-CSharp-Editor.csproj
[info]: OmniSharp.OmniSharpWorkspace
Miscellaneous file: l:\repositories\newtestproject\newtestproject\Assets\testscript.cs added to workspace
*/