Creating a Project
Creating a mod for PEAK is simple using the official BepInEx template. This guide covers installing the template, generating a project, and configuring it for development.
Installing
Section titled “Installing”.NET templates must be installed before they can be used. This means that when you install the template, it doesn’t create a new project for you, but you will get the ability to do that.
See the BepInEx Template repository
From NuGet (Recommended)
Section titled “From NuGet (Recommended)”Install the template by running:
dotnet new install PEAKModding.BepInExTemplateManual Install
Section titled “Manual Install”If you’re contributing to the template or prefer manual installation:
- Clone or download this repository
- Open a terminal in the root of the project
- Run:
dotnet new install .To update:
dotnet new install . --forceTo uninstall:
dotnet new uninstall .Once installed, the template will be available as PEAK BepInEx Plugin with an alias peakmod.
Creating a New Mod
Section titled “Creating a New Mod”Before creating a project, take a look at the available options so you are aware of what can be customized:
| Short Flag | Long Flag | Description | Required | Type | Default |
|---|---|---|---|---|---|
| -g | —guid | The global identifier for your mod. Example: AuthorName.ModName | true | text | |
| -tt | —ts-team | The thunderstore team to publish this package under. | false | text | TODO_team_name_here |
| -nt | —no-tutorial | If true, tutorial comments will not be present. | false | bool | false |
| -li | —library | If true, NuGet metadata is included in the project. | false | bool | false |
| -ig | —inverted-gitignore | Gitignore ignores everything and specifies what to include. | false | bool | false |
You can run dotnet new peakmod --help to see all available options.
Now that you are ready to create a project, open a terminal in your PEAK modding directory, and run the following, including any options of your choice:
dotnet new peakmod --output ModName --guid YourAccount.ModName --ts-team YourThunderstoreTeamThis will create a new directory with the mod name which contains the project.
You now have a (mostly) working setup. See Setting Up The Config File and Thunderstore Packaging & Publishing for more.
Project Structure
Section titled “Project Structure”This example demonstrates the structure of the project after using the template:
~/Workspace/PEAK$ dotnet new peakmod --output MyCoolMod --guid PEAKModding.MyCoolMod --ts-team PEAKModdingThe template "PEAK BepInEx Plugin" was created successfully.
~/Workspace/PEAK$ cd MyCoolMod/The file structure in MyCoolMod/ should look like this:
- CHANGELOG.md
- Config.Build.user.props.template
- Directory.Build.props
- Directory.Build.targets
- global.json
- icon.png
- LICENSE
- MyCoolMod.slnx
- README.md
Directorysrc
DirectoryMyCoolMod
- MyCoolMod.csproj
- Plugin.cs
./src/<project-name>/contains the C# source files for your mod<project-name>.csprojis the C# project configuration file, which builds adllfilePlugin.csis the C# source code file which defines your BepInEx plugin class
./contains project configuration filesDirectory.Build.*files contain shared configuration for all projects in subdirectoriesConfig.Build.user.props.templateis a template file for per-user configuration (see Setting Up The Config File)<project-name>.slnxis file which defines whichcsprojfiles are included in your projectglobal.jsoninforms your dev tools of the minimum supported .NET SDK version for the projectCHANGELOG.md,icon.png,LICENSE, andREADME.mdare placeholder files which are to be modified by you- These are included in your Thunderstore package, which is configured in
./src/<project-name>/<project-name>.csproj
- These are included in your Thunderstore package, which is configured in
The project is configured so that it’s easy to add new projects into your project solution. Even if you don’t need that, it’s a good idea to follow a standard project structure in case a need ever comes, or just so that everything is where you’d expect it to be. For example, does your project need automated tests? Copy your ./src/<project-name>/ plugin’s csproj and Plugin.cs to ./tests/<project-name>.Tests/, add the new csproj to your slnx project, and start working on your test project.
Setting Up The Config File
Section titled “Setting Up The Config File”At the root of your new project you should see Config.Build.user.props.template this is a special file that is the template for the project’s user-specific config. Make a copy of this file and rename it Config.Build.user.props without the template part.
This file will copy your assembly files to a plugins directory and it can be used to configure your paths to the game files and BepInEx plugins directory if the defaults don’t work for you.
Thunderstore Packaging & Publishing
Section titled “Thunderstore Packaging & Publishing”This template comes with Thunderstore packaging built-in, using ThunderPipe. You should configure the src/<project-name>/<project-name>.csproj file with the Thunderstore metadata for your mod.
You can build Thunderstore packages by building with release configuration:
dotnet build -c Release -v dThe built package will be found at ./artifacts/thunderstore/.
You can directly publish to Thunderstore by including -p:PublishTS=true in the command. See the Config.Build.user.props.template file for configuration instructions.