Godot Incorrectly Uses 32-bit .NET SDK Even When 64-bit Is Installed

by ADMIN 69 views

Introduction

Godot is a popular open-source game engine that supports various programming languages, including C#. However, a recent issue has been reported where Godot incorrectly uses the 32-bit .NET SDK even when the 64-bit SDK is installed. This issue can lead to build failures and hinder the development process. In this article, we will delve into the details of this issue, explore the possible causes, and provide a workaround to resolve the problem.

Tested Versions

The issue can be reproduced on Godot v4.2.2.stable.mono.official [15073afe3] with the following system information:

  • Godot Version: v4.2.2.stable.mono.official [15073afe3]
  • OS: Windows 10.0.22000
  • Graphics: Vulkan (Mobile) - integrated Intel(R) Iris(R) Xe Graphics (Intel Corporation; 32.0.101.6078)
  • Processor: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 Threads)

Issue Description

When both 32-bit and 64-bit .NET SDKs are installed on Windows, Godot detects the correct 64-bit SDK version (e.g., 8.0.15) but still attempts to use the 32-bit SDK during compilation. This results in a System.IO.FileNotFoundException error, as shown in the following console output:

/root/godot/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:471 - .NET Sdk not found. The required version is '8.0.15'.
  /root/godot/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:416 - System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 系统找不到指定的文件。
  File name: 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
     at GodotTools.ProjectEditor.ProjectUtils.Open(String path)
     at GodotTools.GodotSharpEditor.ApplyNecessaryChangesToSolution() in /root/godot/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs:line 416
--- Debug adapter server started ---
--- GDScript language server started on port 6005 ---

Expected Behavior

Godot should prioritize the 64-bit .NET SDK when both architectures are present, especially if the OS is 64-bit.

Actual Behavior

Godot incorrectly selects the 32-bit SDK, leading to build failures.

Environment

  • Godot Version: v4.2.2.stable.mono.official [15073afe3]
  • OS: Windows 11 x64
  • .NET SDKs or runtimes:
    • 8.0.15 (x64) at C:\Program Files\dotnet
    • 8.0.14 (x86) at C:\Program (x86)\dotnet (only runtimes)

Additional Context

This issue does not occur if only the 64-bit SDK is installed. A workaround is to manually uninstall the 32-bit SDK, which forces Godot to use the 64-bit version.

Steps to Reproduce

  1. Install both 32-bit and 64-bit .NET SDK (or runtimes):
    • 8.0.15 (x64) at C:\Program Files\dotnet
    • 8.0.14 (x86) at C:\Program Files (x86)\dotnet (only runtimes)
  2. Open any C# project with Godot (v4.2.2.stable.mono.official [15073afe3]).
  3. Observe the error logs in Godot output panel.

Minimal Reproduction Project (MRP)

Use the following Git repository to get a reproducible project:

git clone https://gitee.com/acrsinx/1024.git

Conclusion

Q: What is the issue with Godot using the 32-bit .NET SDK?

A: The issue is that Godot incorrectly uses the 32-bit .NET SDK even when the 64-bit SDK is installed, leading to build failures. This is a problem because the 32-bit SDK is not compatible with 64-bit systems, and using it can cause errors and crashes.

Q: Why is Godot using the 32-bit .NET SDK instead of the 64-bit SDK?

A: The exact reason for this issue is not clear, but it is believed to be related to the way Godot detects and selects the .NET SDK. Godot may be using an outdated or incorrect method to detect the .NET SDK, which is causing it to select the 32-bit SDK instead of the 64-bit SDK.

Q: What are the symptoms of this issue?

A: The symptoms of this issue include:

  • Godot attempting to use the 32-bit .NET SDK instead of the 64-bit SDK
  • Build failures and errors
  • Errors and crashes when running Godot projects

Q: How can I reproduce this issue?

A: To reproduce this issue, you will need to:

  1. Install both 32-bit and 64-bit .NET SDKs on your system
  2. Open a C# project in Godot
  3. Observe the error logs in Godot output panel

Q: What is the workaround for this issue?

A: The workaround for this issue is to manually uninstall the 32-bit .NET SDK, which will force Godot to use the 64-bit SDK. This will resolve the issue and allow you to build and run your Godot projects without errors.

Q: Is this issue specific to Godot or can it affect other applications?

A: This issue is specific to Godot and is not a general problem with .NET SDKs. However, it is possible that other applications may experience similar issues if they are using outdated or incorrect methods to detect and select .NET SDKs.

Q: How can I report this issue to the Godot team?

A: If you are experiencing this issue, you can report it to the Godot team by:

  1. Creating a new issue on the Godot GitHub page
  2. Providing detailed information about your system, Godot version, and the steps you took to reproduce the issue
  3. Attaching any relevant logs or error messages

Q: Will the Godot team fix this issue?

A: The Godot team is aware of this issue and is working to resolve it. However, the exact timeline for a fix is not clear. In the meantime, the workaround of uninstalling the 32-bit .NET SDK is available to resolve the issue.

Q: Can I use a different .NET SDK with Godot?

A: Yes, you can use a different .NET SDK with Godot. However, you will need to ensure that the SDK is compatible with Godot and that it is installed correctly on your system.