Failed to Create C# Solution

Godot Version

4.2.1 .NET Version

Question

When trying to attach cs script to a node or when trying to create C# solution from the drop down, I get the follwing error.

So far I’ve tried.

  • Uninstalled all .NET SDKs
  • Installed the Latest SDK (8.0.204)

try first delete all c# configuration files in project.(or make C# empty project and create any cs class in project)
check in Command line what versions of .Net is installed in system.
and make C# solution.

Tried creating a new project and then creating a C# script, produced the same error.

Ran “dotnet --info” into cmd


Running the Project->Tools->C#->Create C# Solution. Produced the same error as above

can you make easy console app like hello word?

Creating a new console app with VS Code I got this error. I assume it has to do with the .NET SDK version. I’ll have a look at downloading the x64 version of the SDK

Even though my PC has the x86 arch should I be using the x64 version of the SDK?

x86 refers to 32-bit architecture, while x64 denotes 64-bit architecture. A 32-bit system is only capable of running 32-bit programs, whereas a 64-bit system can run both 32-bit and 64-bit programs. When working with C# development kits and .NET frameworks, it’s essential to ensure that the versions match to avoid compatibility issues.

1 Like

you can try make Console app using command line
Create Folder
obraz
Open your folder in windows explorer
obraz
type cmd press enter and you will be in that folder in command line

in console type:
dotnet new console
dotnet run
you should see
obraz

Followed your steps to make a console app and it worked. Printed Hello World.

1 Like

then no problem from C# .Net,
What tool for programming? VS Code, VS?

I was going to use VSCode but I also have VS installed too

I suspect VS have problems, maybe is something outdate there.
you can try run my old Godot test project:

Downloaded, imported & Edited, Pressed Play, threw the original error with Failed to Build Project

I’ve re-downloaded Rider to try and see if building the solution of your test project would yield some results. If not I’ll try and build the solution in Visual Studio

Building the solution in Rider is successful but trying to actually build the project within the editor yields the same error as above, same applies for Visual Studio. Only difference I noticed was that Rider was using the x64 version of .NET ('C:\Program Files\dotnet) instead of the x86 version to build the solution. Could this be an issue with how Godot chooses which SDK to use to build the project?

you can try change things here:


or just uninstall all,
restart system and make fresh install

Fixed! I saw on another thread similar to my issue that GodotSharpEditor targets .NET 6 SDK, as a hail mary, I downloaded the SDK and it worked! Built Moreus’s test project, worked.

tldr; Download .NET 6 SDK alongside .NET 8 SDK.

1 Like

A familiar problem.
I had something similar with every new 4.2 dev 1-5 version.
(My answer on reddit)

Or I’ll describe it here in a nutshell.
Maybe it will help to rebuild the dotnet project.
You need to create a nuget.config file and write in it:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

Then in the terminal you need to go to the project folder and write the command dotnet restore.
If the error is due to the fact that some links to the SDK in the project have gone astray, for example, the problem can be solved.
(And the problem sounds a lot like this!)

By the way, I have 8.0 and everything works.