Skip to content

Creating a New Project

Create and run a complete 2dog project without installing a tool:

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

2dog new asks which hosts to include. Pass --desktop, --web, --webxr, --tests, --winforms, --winui, --avalonia, or --non-interactive to skip the prompts.

Already have a Godot project? Use 2dog add instead. It creates the same layout around your existing content.

Using dotnet new

The same project template ships in the 2dog NuGet package:

bash
dotnet new install 2dog
dotnet new 2dog -n MyGame
cd MyGame
dotnet run --project MyGame.2dog

The generated project references the required 2dog packages; there is no separate SDK to install.

What You Get

text
MyGame/                     # Godot project root and solution root
├── project.godot
├── MyGame.csproj           # Godot.NET.Sdk game project
├── MyGame.slnx
├── main.tscn
├── export_presets.cfg
├── global.json             # included with the web host
├── MyGame.2dog/            # generic host
├── MyGame.web/             # browser host (holds TwoDogWebBoot.cs)
├── MyGame.tests/           # xUnit tests
├── .editorconfig
└── .gitignore

Each host folder contains .gdignore, so the Godot editor, importer, and exporter skip it. The game project also excludes host sources from its compile globs.

See Hosts for the shared host contract and each generated host's anatomy. See Project Layout for how the nested projects fit together.

Choose Hosts

The full template includes desktop, browser, and test hosts. To leave optional hosts out, or to opt into the WebXR host, the Windows-only WinForms and WinUI 3 hosts, or the cross-platform Avalonia host:

bash
dotnet new 2dog -n MyGame --tests false --web false
dotnet new 2dog -n MyGame --avalonia true
ParameterDefaultDescription
-n, --namerequiredProject name
--teststrueInclude MyGame.tests with xUnit and 2dog.xunit
--webtrueInclude the MyGame.web browser host
--webxrfalseInclude the MyGame.webxr browser host with the WebXR Layers polyfill for VR
--winformsfalseInclude the MyGame.winforms WinForms host (Windows-only at runtime)
--winuifalseInclude the MyGame.winui WinUI 3 host (Windows-only; builds only on Windows)
--avaloniafalseInclude the MyGame.avalonia Avalonia host (cross-platform GUI; controls composite over the game)
--skipRestorefalseSkip automatic package restore
--twodogVersioncurrent release2dog package version
--nativesVersioncurrent releaseNative platform package version
--godotVersioncurrent releaseGodot.NET.Sdk version

Work with the Project

From MyGame/:

bash
dotnet build
dotnet run --project MyGame.2dog
dotnet run --project MyGame.2dog -c Release

Use the Godot editor normally; the project root is a regular Godot project. C# scripts belong in that root and compile into MyGame.csproj, which every host references.

For tests, see Testing. The Browser Host guide covers prerequisites, building, local serving, configuration, and platform limits. Browser builds require:

bash
dotnet workload install wasm-tools
dotnet publish MyGame.web

The rest of the solution builds without wasm-tools; browser publishing is an explicit step.

Manage the Template

bash
dotnet new update
dotnet new uninstall 2dog

If dotnet new 2dog is not found, check dotnet new list and reinstall with dotnet new install 2dog.