Unity build mode (ForgeBuild.cs)
Forge ships a small C# script (Assets/Editor/ForgeBuild.cs) you can install in any Unity project. It exposes static methods Unity can call from the command line, so you can run release builds without opening the Editor.
This is what makes it possible to wire a “Build Windows” task into your tasks.toml and run it from the command palette.
Install
Section titled “Install”Open Settings → MCP → Forge Unity Bridge while in a Unity project. Below the bridge install button, click Install build script.
Forge writes the file to <project>/Assets/Editor/ForgeBuild.cs. Reinstalling overwrites it (so a Forge upgrade carries fixes forward, but any local edits you made are lost).
What it does
Section titled “What it does”ForgeBuild is a public static class with one method per build target:
BuildWindows(StandaloneWindows64)BuildLinux(StandaloneLinux64)BuildOSX(StandaloneOSX)BuildWebGLBuildAndroid
Each method calls BuildPipeline.BuildPlayer with the scenes from your Build Settings, the matching target, and a default output path of <project>/Builds/<Target>/.
You can override the output path by setting the FORGE_BUILD_PATH environment variable. Useful for CI, where you want builds inside a workspace folder rather than the project root.
Run a build
Section titled “Run a build”From a terminal:
& "C:\Program Files\Unity\Hub\Editor\6000.0.0f1\Editor\Unity.exe" ` -batchmode -nographics -quit ` -projectPath . ` -executeMethod ForgeBuild.BuildWindows ` -logFile -Exit codes:
0: build succeeded.1: build failed. Look at theBuildReportsummary in the log for warnings and errors.2: no scenes in Build Settings. Add at least one before invoking.
Wire it into tasks.toml
Section titled “Wire it into tasks.toml”The typical setup looks like:
[[tasks]]name = "build-windows"label = "Build Windows"shell = "powershell"command = '& "$env:UNITY_PATH" -batchmode -nographics -quit -projectPath . -executeMethod ForgeBuild.BuildWindows -logFile -'
[[tasks]]name = "build-webgl"label = "Build WebGL"shell = "powershell"command = '& "$env:UNITY_PATH" -batchmode -nographics -quit -projectPath . -executeMethod ForgeBuild.BuildWebGL -logFile -'Forge sets UNITY_PATH automatically when it detects a Unity project, so the tasks pick up whichever Editor version your project requires.
Once the tasks exist, run them from the command palette: Ctrl+Shift+P, then Task: Build Windows.
What’s next
Section titled “What’s next”- Tasks runner covers the broader
tasks.tomlshape. - Connect Unity bridge for the rest of the bridge story.