I open scripts by vscode, but get error, and There are no code hints!
2023-07-27 20:12:35.538 [warning] The project file '/home/Workspace/U3DTrain/Assembly-CSharp.csproj' is in unsupported format (for example, a traditional .Net Framework project). It need be converted to new SDK style to work in C# Dev Kit.
2023-07-27 20:12:35.698 [error] Failed to load project '/home/Workspace/U3DTrain/Assembly-CSharp.csproj'. One or more errors occurred. (This project is not supported in C# Dev Kit.)
2023-07-27 20:12:35.709 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.
OS: Deepin 23(Debian 10.10)
Editor: VS-code(with plugins .NET Install Tool for Extension Authors, C#, C# Dev Kit, IntelliCode for c#, Debugger for Unity)
apt Installed: dotnet-sdk-7.0, mono-devel, mono-complete, mono-dbg
UnityEditor: 2022.3.5f1 LTS
If you are getting this issue after you got the new update to the vs code and before everything was working normally
To solve the issue
- Download and install the official version of the unity extension . Announcing the Unity extension for Visual Studio Code - Visual Studio Blog
- Go to package manager and unity registry , search “studio” and update both extensions to recommended version.
- Open the VSCode and check for code completion
- If still no code completion , Open the project folder and there you can see all your csproj files for eg : “Assembly-CSharp.csproj”
- Open the csproj file and search for word “TargetFramework”. You will see one like this
<TargetFramework>net7.0</TargetFramework> copy this and paste under the step 5 line. Do same for all your csproj files if you have more than one.
Now you can see code completion and syntax highliting etc.
I found another, less hacky, solution.
First, make sure you are using Unity 2021 or above
- go to Window → Package Manager
- remove the “Visual Studio Code Editor” package (it’s deprecated). If you’re unable to uninstall this might be because it’s part of the “Engineering feature set”. You can remove this package and add it’s contents manualy (you can see what’s part of this set here).
- Install and/or update “Visual Studio Editor” (version 2.0.20+). From this version and higher it also includes Visual Studio Code support.
In File Explorer
- Delete all .csproj and .sln files from your unity project folder (Make a back-up if you want)
- Go to Edit → Preferences → External Tools
- Set VS Code as Code Editor
- Click “Regenerate Project Files”
- double click any script to open VSCode
Thank you shamsad for pointing me in the right direction. Also thanks to this issue page on Github (github .com/microsoft/vscode-dotnettools/issues/271#issuecomment-1672096480)
Sorry for the misformatted links. As a new user I’m not allowed to post more links.
In VSCode go to settings and look for omnisharp.useModernNet
uncheck and restart VS Code
Load unity solution from unity
Autocomplete should work.
make sure you have dotnet SDK and MS build tools installed.
Hope this helps,
It seems like both files
Assembly-CSharp.csproj are missing the line:
After adding it everything works fine.
The question is, how to make this permanent? Because every new project will be generated, it misses the TargetFramework on both files, any fix for Unity on that?
Thank you so much. I’ve spent all night looking for a solution and nothing worked. Nothing, except this. Thank you again