godot: Generating the C# project fails when .Net 8 Sdk is installed.
Godot version
4.1.1.stable.mono
System information
Godot v4.1.1.stable.mono - Windows 10.0.23531
Issue description
When I install .Net 8 on my system (I’m using the preview version of Visual Studio, so I can’t uninstall .Net 8), I get the message “Failed to create C# project.” when I create a C# script file, and it doesn’t generate the corresponding project files.
modules/mono/glue/runtime_interop.cpp:1324 - System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System cannot find the specified file.
File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at GodotTools.ProjectEditor.ProjectGenerator.GenAndSaveGameProject(String dir, String name)
at GodotTools.CsProjOperations.GenerateGameProject(String dir, String name) in /root/godot/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs:line 13
Transient parent has another exclusive child.
Steps to reproduce
- Install the latest preview version of .Net 8 Sdk.
- Create a new godot project.
- Add a scene root node.
- Attach a C# script to the node.
Minimal reproduction project
N/A
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 23 (9 by maintainers)
Is there somewhere I can track the Godot/.net8 integration progress?
TBH,
<TargetFramework>net8.0</TargetFramework>is a no-go because it triggers the exact same error as reported by OP:Saw the same error, v4.2.2 rc1, was fixed after a cache clear with
dotnet nuget locals -c@raulsntos Ah my apologies here, my case was actually a bit different. I was trying to set my
TargetFrameworktonet8.0to try out some things in 8.0.0.rc2 😃 Your comment in https://github.com/godotengine/godot/issues/83915#issuecomment-1779661812 actually fixed things for me though, settingDOTNET_ROLL_FORWARD_TO_PRERELEASEand now I’m able to run my .NET 8-compiled assembly!I have the same issue in Godot 4.2 Beta 1 with .NET SDK 8.0.100-rc.2.23502.2, even after cleaning NuGet cache. It only occurs in Godot projects and standalone .NET projects work well.
That’s what it tries to do first, it looks for the same major version and only falls back to something else if it can’t find it. I think this is happening because the version
8.0.100-rc.1.23455.8can’t be parsed byVersion.TryParse.https://github.com/godotengine/godot/blob/e3e2528ba7f6e85ac167d687dd6312b35f558591/modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs#L100-L101
The C# project is created using the
Microsoft.BuildAPIs. I believe this requires registering the SDK.So yep, seems to be related to the Visual Studio update replacing the .NET SDK 7 with version 8:
Manually reinstalling 7.0x in addition fixed the issue: