Setting up the development environment

To start developing BepInEx, we need three components:

All these parts are next discussed in more detail

.NET SDK

Note

If you have .NET SDK already installed, you can skip this part.

.NET SDK is a software development kit (SDK) that allows compiling code written in C# and using different .NET libraries. As you may notice later, plugins use different .NET API versions and variations such as .NET Framework or .NET Standard. When it comes to plugin development, all those can be handled by the modern .NET SDK.

To install .NET SDK, do the following:

  1. Head to .NET downloads page

  2. Select the latest recommended .NET SDK for your OS:

    Example of "Download .NET SDK" from .NET downloads page

  3. Download and run the installer according to your OS's instructions

    You may need to restart your PC for the install to finalise.

Once you have installed .NET SDK, verify that it works by opening a command line prompt and running

dotnet --list-sdks

If you have installed .NET SDK correctly, the command should return at least one .NET SDK version and its location.
An example output is:

5.0.201 [C:\Program Files\dotnet\sdk]

Once you have at least one .NET SDK version installed, you can choose a code editor.

Picking an IDE

While plugins can be made with a simple text editor, it is recommended to use a proper editor for programming.
Different editors exist with varying level of integration with .NET building tools. Proper IDEs provide more extensive features like code style suggestions, automatic completions and even debugging.

A list of some editors that are known to be usable for BepInEx plugin development:

Pick one of the code editors and ensure they work with C#.

Installing and configuring BepInEx

Next, make sure you have BepInEx installed in your game.
If you don't have yet, follow the installation guide.

Run the game with BepInEx at least once in order to generate configuration files and any additional libraries.

To make debugging easier, it is useful to enable the BepInEx console. To do so, go to BepInEx/config folder and open BepInEx.cfg.
Find the following configuration section/value and edit it as follows:

[Logging.Console]

## Enables showing a console for log output.
# Setting type: Boolean
# Default value: false
Enabled = true

Installing BepInEx plugin templates

BepInEx provides helper templates to start off with plugin development.
We will be using them to make our plugins.

To install the template, run the following command:

dotnet new -i BepInEx.Templates --nuget-source https://nuget.bepinex.dev/v3/index.json

If the install is successful, you should see a listing of all .NET project templates. Among them should be the following BepInEx templates:

Templates                                     Short Name            Language    Tags
--------------------------------------------  --------------------  ----------  --------------------------------------
BepInEx 5 Plugin Template                     bepinex5plugin        [C#]        BepInEx/BepInEx 5/Plugin
BepInEx 6 .NET Launcher Plugin Template       bep6plugin_netfx      [C#]        BepInEx/BepInEx 6/Plugin/.NET Launcher
BepInEx 6 Il2Cpp Plugin Template              bep6plugin_il2cpp     [C#]        BepInEx/BepInEx 6/Plugin/Il2Cpp
BepInEx 6 Unity Mono Plugin Template          bep6plugin_unitymono  [C#]        BepInEx/BepInEx 6/Plugin/Unity Mono

Summary

In this part, we installed .NET SDK, a code editor, BepInEx and BepInEx plugin templates. With all components set up, creating a new plugin is a fairly simple process.

Next: Writing a basic plugin