今天新建了个unity项目,发现vscode无法提供C#的智能提示。OUTPUT面板显示:
2024-03-14 17:37:46.677 [warning] The project file 'F:\tgit\unity\WxTexExplorer\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.
2024-03-14 17:37:46.700 [error] Failed to load project 'F:\tgit\unity\WxTexExplorer\Assembly-CSharp.csproj'. One or more errors occurred. (This project is not supported in C# Dev Kit.)
2024-03-14 17:37:46.702 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.
同时vscode也弹窗提示:
image.png
检查了vscode是最新的,unity插件也是最新的,unity packagemanager里的vistual studio code包也是最新的,.project文件也重新生成了,但vscode还是无法识别C#项目。
最后在这篇贴文中找到解决办法:
https://discussions.unity.com/t/vscode-cant-load-c-project/273373/3
在所有*.csproj文件中搜索<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
,在下面添加一行:<TargetFramework>net7.0</TargetFramework>
,重启vscode即可。
附关于C# Dev Kit的说明:
https://code.visualstudio.com/docs/csharp/cs-dev-kit-faq#_what-project-types-are-currently-supported