Missing something to build C# Godot

Godot Version

Godot v4.3

Question

Hello everyone.

Has someone encountered this problem working in C# Godot v4.3 while generating the c# project?

/root/godot/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs:13 - System.BadImageFormatException: Could not load file or assembly ‘Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’. Format of the executable (.exe) or library (.dll) is invalid.
File name: ‘Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ —> System.BadImageFormatException: Could not load file or assembly ‘C:\Program Files (x86)\dotnet\sdk\8.0.403\Microsoft.Build.dll’. Format of the executable (.exe) or library (.dll) is invalid.
File name: ‘C:\Program Files (x86)\dotnet\sdk\8.0.403\Microsoft.Build.dll’
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at Microsoft.Build.Locator.MSBuildLocator.<>cDisplayClass15_0.gTryLoadAssembly|1(AssemblyName assemblyName)
at Microsoft.Build.Locator.MSBuildLocator.<>cDisplayClass15_0.b0(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName)

It is not letting me generate c# Solution in an empty newly created godot project and I make sure to have also the SDK installed.

Yesterday, I made a software cleaning including old SDKs and other tools I am not using anymore, and after that I make sure to install SDKs needed (the ones indicated in the web), but it seems I am still missing something to make Godot generate the project properly.
Any idea what is going wrong with my setup?

Thanks :slight_smile:

Here is my .csproj file:

<Project Sdk="Godot.NET.Sdk/4.3.0">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
    <TargetFramework Condition=" '$(GodotTargetPlatform)' == 'ios' ">net8.0</TargetFramework>
    <EnableDynamicLoading>true</EnableDynamicLoading>
  </PropertyGroup>
</Project>

On my system I have dotnet sdk 6.0.414 installed and it works fine.
So you can try to install this version or change the one in the first <TargetFramework> tag

The thing is I can not generate my .csproj. Whenever I try to generate it, it triggers the error I show in the previous post,
My project folder only contains:
project.godot
icon.svg and icon.svg.import
.godot

I have tried to generate the C#project both with an old project and with a recently created project and all of them show the same error.

I guess you already tried reinstalling the dotnet 8 sdk?

Maybe Godot 4.3 is trying to use an sdk version that does not match. You could try to create a [gamename].csproj file and paste a configuration from here, e.g. the one from tshadow999 or this one from me (cleaned up), which targets net 8.0:

<Project Sdk="Godot.NET.Sdk/4.3.0">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <EnableDynamicLoading>true</EnableDynamicLoading>
  </PropertyGroup>
</Project>

Yes, I have already tried reinstalling it but it still doesnt work.
I think it could be related with the architecture version I am working on, but I am not sure how to solve it.
I am working with the Godot (Windows - .NET - x86_64), and I have installed both .NET SDK x64 and x86. BUt for some reason my PC is not recognizing the net SDK x64 version. (I had this working before I made a clean up of old software)


If I uninstall SDK x86 version, it is not recognizing the .NET SDK x64 version as installed.
I also have tried to create the .csproj manually and tryint to build it but it still shows these errors.

And at this point I am out of ideas. I am going to try to install .NET SDK 6.0 since th old .csproj I had in my godot projects were pointing to this version, but it is still not the .NET SDK version Godot has in its webpage.

try instal in "C:\Program Files\" instead "C:\Program Files (x86)\"

I’ve already done that. That is the path for the .NET SDK x64 version

MacOS Sequoia 15.2 MacBook Air M1, Godot v4.3.stabe.mono.official, .NET SDKs installed: 6.0.428 8.0.405 9.0.102.

When I restarted my Mac after installing .NET 6 and 9, it just worked when i clicked. Project > Project Tools, C#, Create C# Solution.