How to create Godot compatible C# projects on Linux

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kzvr

I am on Ubuntu and have created a Godot Mono (3.2.2 Stable) Project, with some C# node scripts.

I would like to encapsulate much of the game logic in C# classes that are not tied to Godot Nodes. It is straightforward to manually create .cs files and add them to the game.csproj file so they are compiled.

The next step is to create 2-3 more C# projects, one for unit tests, and one to run game logic on a server. Neither of these projects will depend on Godot C# libraries. (End goal is running the game logic on a lean web server with no godot dependancy)

I am a professional C++ developer, but am new to C#. What tools exist to help me set up these projects on linux? I have Mono, MSBuild, and Nuget installed. I am comfortable with command line tools. csproj files appear to be manually modifiable, but .sln files do not. Google searching different permutation of “mono setup project solution c# linux etc.” has not been fruitful.

How can I:

  1. Create a “GameLogic” library project
  2. add the GameLogic library project as a dependency of the GodotProject (so I can use classes from it in node scripts)
  3. Create a “Testing” unit test project (preferably with mstest, nunit, or xunit), with the GameLogic library linked as a dependency
  4. Create a “GameServer” executable project, with the GameLogic library linked as a dependency

I have tried Visual Studio Code with the C# Extension, but it does not seem to have the tooling to create/manage C# solutions/projects.

:bust_in_silhouette: Reply From: rakkarage
mkdir test
cd test
dotnet new classlib

Is the dotnet tool not part of the .NET core package? Or is there a mono-compatible dotnet tool as well?

kzvr | 2020-09-09 21:06

.NET and Ubuntu overview - .NET | Microsoft Learn
ya it should come with dotnet core

rakkarage | 2020-09-10 01:21