Skip to content

2dog new ​

Creates a new Godot project with 2dog hosts. Without host flags it asks which hosts to create. Host flags skip that wizard. On a terminal, the tool can still offer to install a missing workload (wasm-tools, android). -y runs unattended.

bash
2dog new [Name] [dir] [hosts] [options]
ArgumentMeaning
NameProject name, used for folders, assemblies and namespaces; letters, digits, . and _ stay, - becomes _, and C# keywords and leading digits get a _ prefix; the tool tells you when it changes the name
dirDirectory to create; defaults to the sanitized name

Hosts ​

Use any host flag. Repeat a flag to add another host of the same kind. Without host flags, an unattended run creates the generic and Web hosts, except the ones that you exclude with --no-<host>. Add tests explicitly with --xunit, --gdunit or --nunit. With a test host, the root global.json selects Microsoft.Testing.Platform, so dotnet test runs every test host.

Options ​

OptionEffect
-n, --name <name>Project name; same as Name
-o, --output <dir>Directory; same as dir
--dry-runPrint the plan; change nothing
--forceOverwrite existing files from the setup; never deletes
--double-precision [true|false]Select matching double precision bindings and natives for the game and all hosts; false selects single precision
--web-threads [true|false]Enable experimental multithreading for Web and Blazor clients; the web server must send COOP/COEP headers
--no-restoreSkip the final dotnet restore
--install-wasm-toolsInstall missing wasm-tools for browser hosts without an installation prompt
--install-android-workloadInstall the missing android workload for Android hosts without an installation prompt

See build options for the build settings' requirements.

Plus the global and output options.

--no-restore skips the workload offers; the install flags work in CI too. --dry-run never checks or installs workloads. If the restore fails, the tool returns exit code 2 and keeps the created files. Fix the reported cause. Then run dotnet restore again.

Examples ​

Install the .NET 10 SDK, then create and run a project with a generic .NET host:

bash
dnx 2dog new MyGame --generic
cd MyGame
dotnet run --project MyGame.2dog

Open project.godot in the Godot .NET editor to edit scenes and scripts. See Project Layout for the generated files and Hosts for host types.

Choose hosts interactively, or supply host flags:

bash
2dog new MyGame                            # interactive host choice
2dog new MyGame --generic --xunit          # unattended
2dog new MyGame --gdunit                   # GDScript tests
2dog new MyGame --web --double-precision --web-threads
2dog new "My Game" -o games/mine --no-web  # name adjusted to MyGame

For an existing project, use 2dog add.

Use the .NET Template ​

The same template is available through dotnet new in the separate 2dog.templates package:

bash
dotnet new install 2dog.templates
dotnet new 2dog -n MyGame --web false

If you previously installed the template from 2dog, run dotnet new uninstall 2dog before you install 2dog.templates. This command does not remove the 2dog tool.

This creates a generic .NET host. Omit --web false to include Web; install wasm-tools when you want to build or publish that host. The template also accepts --double-precision true and --web-threads true.

Test hosts are opt-in. Pass --xunit true, --gdunit true or --nunit true to dotnet new 2dog, or use 2dog new MyGame --xunit, --gdunit or --nunit.

Debugging the Godot project in VS Code ​

New projects include .vscode/launch.json, tasks.json, and a recommendation for Microsoft's C# extension. To debug the Godot project:

  1. Open the project root folder in VS Code.
  2. Install the recommended C# extension.
  3. In Run and Debug, select Godot: Play (C#).
  4. Press F5.

The build task builds only the root Godot project, in the Debug configuration.

The debugger must know where Godot is. Do one of these steps:

  • Set the GODOT4 environment variable to the main .NET-enabled Godot executable. Then restart VS Code.
  • Replace program in launch.json with the absolute path of that executable.

On Windows, use the mono executable, not the _console.exe wrapper. The editor path setting in Godot Tools is not enough for the C# debugger.

The root project uses the Godot SDK and builds a library that Godot loads. To debug it, VS Code must start the Godot executable. The .2dog host is a regular .NET executable and supports the usual .NET launch workflow. Godot: Attach (C#) can attach to an already running .NET Godot game or editor. Select the process that loads your scripts.

2dog is Free and Libre Open Source under the MIT License.
2dog is not affiliated with or endorsed by the Godot Foundation.
Godot is licensed under the MIT License; the Godot logo is by Andrea Calabró under CC BY 4.0. @icons made by Voxy under the MIT License.
Continuous Integration compute graciously supported by Blacksmith.