Getting Setup for Modding - Monster-Train-2-Modding-Group/Trainworks-Reloaded GitHub Wiki

Whether you want to work locally in Visual Studio or use GitHub Codespaces in the cloud, this guide walks you through setup, testing, and releasing your first mod.

💡 Recommendation:
If you’re new to programming or don’t have Visual Studio and Python installed, use GitHub Codespaces.
It includes everything you need and requires no local setup.


Prerequisites

  • A GitHub account (required for NuGet package access and automated builds / releasing)
  • Basic familiarity with Git/GitHub (optional but helpful)

Important

Without a GitHub account, you’ll need to manually set up a Visual Studio project along with all of the dependencies — that’s outside the scope of this guide.


Step 1: Create a Public Github Repository

  1. Go to GitHub and log in or sign up.
  2. Click the + icon in the top-right → New repository.
  3. Choose a name (e.g. MyModProject).
  4. Set Visibility to Public (this is required).
  5. Check “Initialize with a README” (Important if you are planning on using a GitHub Codespace).
  6. Click Create repository.

Step 2: Create a Thunderstore Account and Namespace

  1. Go to Thunderstore.io.
  2. Sign up and log in.
  3. Navigate to Settings → Teams → Create Team.
  4. Create your namespace and save the name — you’ll need it later.

Step 3: Generate a GitHub Personal Access Token (PAT)

We’ll use this token to authenticate with GitHub Packages.

  1. On GitHub, go to
    Profile → Settings → Developer Settings → Personal Access Tokens → Tokens (classic)
  2. Click Generate new token (classic) with the following permissions:
    • read:packages
    • public_repo
  3. Copy and store your token securely — you’ll need it in the next step.

Step 4: Add Repository Secrets

For GitHub Codespaces
  1. Go to your repo’s Settings → Secrets and Variables → Codespaces → New repository secret

    Add:

    • GH_AUTH_TOKEN → your Personal Access Token
  2. Go to your repo’s Settings → Secrets and Variables → Actions → New repository secret

    Add:

    • GH_AUTH_TOKEN → your Personal Access Token
For Local Visual Studio Users
  1. Go to your repo’s Settings → Secrets and Variables → Actions → New repository secret

    Add:

    GH_AUTH_TOKEN → your Personal Access Token

(Optional) Dependabot Setup

To get Pull Requests from Dependabot in case any of the dependencies change:

  1. Go to Settings → Secrets and Variables → Dependabot → New repository secret
  2. Add:
    • DEPENDABOT_GITHUB_USERNAME → your GitHub username
    • DEPENDABOT_GITHUB_TOKEN → your Personal Access Token

Step 5: Open Your Development Environment

Option 1: GitHub Codespaces
  1. On your repository page, click Code → Open with Codespaces → New Codespace

  2. Wait for setup to finish (it may take a minute).

If you added or changed Codespace secrets after creating the Codespace, rebuild the container (see Step 8).

Option 2: Local Visual Studio
  1. Clone your repository:

    git clone https://github.com/<YourUsername>/<YourRepo>.git

  2. Open a terminal in the directory where you cloned your repository.

Step 6: Install Cookiecutter

Cookiecutter is a program that generates your mod’s project structure from our template.

  • In Codespaces:

    pip install cookiecutter

  • Locally (requires a Python installation):
    Run the same command in your terminal.

Step 7: Generate Your Mod from our Template

Run this in your terminal:

cookiecutter https://github.com/Monster-Train-2-Modding-Group/Mod-Template.git

cookiecutter will prompt for the following things:

  1. project_name. Enter your mod's name. This can't be edited easily later.
  2. description. Enter the short description of your mod. Used as the description of your mod on thunderstore and populates the README.md
  3. author. Your name.
  4. mod_namespace. Important this is your mod namespace from Thunderstore from Step 2.
  5. generate_minimal_clan. Leave this on the default (1). We are getting introduced to modding. Later when you actually want to make a clan mod you can set this to (2) to get a full clan example.
  6. enable_harmony_patching. Also leave this on the default (1). This just adds code to enable Harmony patches, which we will cover much, much later.

Move the Generated Files to Your Repository Root

After cookiecutter finishes, you’ll see a new folder created with the same name as your project_name. Now move the contents of that folder up one level with the following command

Important

Replace <YourProjectName> in the command below with the actual folder name that was created.

mv <YourProjectName>/{*,.*} . 2>/dev/null

Example: If you named your project CoolMod, run:

mv CoolMod/{*,.*} . 2>/dev/null

If you’re unsure what the folder is called, check with:

ls

The output should be the folder name and a README.md file. The folder name is the one whose contents you are moving.

Step 8: (Codespaces Only) Rebuild the Container

After successfully moving the folder's contents in the bottom left hand corner should be a popup with the text

We've noticed a change to the dev container configuration. Rebuild the container to apply them now.

You can press the green Rebuild Now button. And then press Full Rebuild

Otherwise here are the steps to do this manually

  1. Open the Command Palette:

    • Windows/Linux: Ctrl+Shift+P

    • macOS: Cmd+Shift+P

    • (In Firefox, use F1 instead)

  2. Search for “Rebuild Container” and run it.
    Your Codespace will rebuild with updated secrets and dependencies

Step 9: Test Build

Visual Studio (Local)
  1. Open the .sln file.

  2. When prompted, log in with:

    • Username: your GitHub username

    • Password: your Personal Access Token

  3. Build the solution.
    Output files will appear in the bin/Debug/netstandard2.1/ folder.

Codespaces

Run the following command:

dotnet build -c Release --output ./dist

If successful, you will see a new dist/ folder containing your compiled mod.

If the command fails run the command

dotnet nuget update source --username $GITHUB_USER --password $GH_AUTH_TOKEN monster-train-packages --store-password-in-clear-text

Then attempt to build again. If it fails again please report the build failure to #mt2-modding on discord or file a GitHub issue.


Continue onto Testing Your Mod

⚠️ **GitHub.com Fallback** ⚠️