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; a missing workload (wasm-tools, android) can still be offered on terminals. -y runs unattended.

bash
2dog new [Name] [dir] [hosts] [options]
ArgumentMeaning
NameProject name, used for folders, assemblies and namespaces; letters, digits, . and _ survive, - becomes _, C# keywords and leading digits get a _ prefix, an adjustment is announced
dirDirectory to create; defaults to the sanitized name

Hosts ​

Any host flag, repeatable. Unattended without one: generic and browser, minus the --no-<host> ones. 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 scaffolded files that exist; 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; serving requires 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. A failed restore returns exit code 2 and keeps the created files. Fix the reported cause and 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 installing 2dog.templates. This leaves the 2dog tool installed.

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. Open the project root folder, install that extension, select Godot: Play (C#) in Run and Debug, and press F5. The build task builds only the root Godot project in Debug configuration.

Set the GODOT4 environment variable to the main .NET-enabled Godot executable and restart VS Code, or replace program in launch.json with its absolute path. On Windows, use the mono executable, not the _console.exe wrapper. Godot Tools' editor path setting alone does not configure the C# debugger.

The Godot SDK root is a library loaded by Godot, so it needs this external executable launch. 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. @icons made by Voxy under the MIT License.
Continuous Integration compute graciously supported by RunsOn.