Setting up a Development Environment

From KSP 2 Modding Wiki
Revision as of 13:18, 16 April 2023 by Cheese (talk | contribs) (Fix category)

This page provides information on how to set up a development environment for Kerbal Space Program 2 modding.

Prerequisites

This guide assumes you have the following prerequisites satisfied

  1. That you own a copy of Kerbal Space Program 2
  2. That you have dotnet installed
  3. That you have an IDE such as Rider or Visual Studio, or some other way to compile C# code into a DLL

Template Setup

This is the first step in setting up a development environment, depending on which IDE/Method of compilation you are using it has to be done in a few different ways.

Visual Studio or no IDE

First install the template using the following command in the command line

dotnet new install SpaceWarp.Template

Visual Studio

If you are then using Visual Studio to develop the mods, the next steps are as follows

  1. Open Visual Studio
  2. Create a new project
  3. Search for "SpaceWarp" in the search bar at the top, then select it and click Next
  4. Fill out your project name and click Next
  5. Fill out the fields on the following page. You can find more information about the parameters by hovering over the corresponding "i" icons
  6. Click on Create and your project will be made.

No IDE

If you aren't using Visual Studio, use the following command but replace all the parameters with the ones to describe your mod

dotnet new spacewarpmod -n MyAwesomeModName -G my_awesome_mod_name -A "munix" -B "com.github.munix.my_awesome_mod_name" -M "My Awesome Mod Name" -D "This is the description of my awesome mod." -S "https://github.com/munix/MyAwesomeModName" -V "1.0.0"
Parameters (Bold entries are required)
Parameter Console Argument Short Argument Description Default Value
Project name --name -n The name of your project in PascalCase <current directory name>
TargetFramework --TargetFramework -T .NET version to target, default value is set for KSP 2 .netstandard2.0
UnityVersion --UnityVersion -U Unity version to target, default value is set for KSP 2 2020.3.33
GUID --GUID -G Your mod's ID which serves as the folder and .dll name of your built mod, used by SpaceWarp -
Author --Author -A The name(s) of the mod's author(s) -
BepinexName --BepinexName -B Your mod's ID in domain syntax, for example: com.github.author.modname, used by BepInEx -
ModName --ModName -M The name of your mod -
Description --Description -D A short description of your mod "" (empty)
Source --Source -S The repository or download location of the mod's source code "" (empty)
Check Version --CheckVersion -C URL to up-to-date swinfo.json for version checking (for example: https://raw.githubusercontent.com/author/mod/main/swinfo.json) "" (empty)
Version --Version -V The mod's initial version 1.0.0

Rider

For rider the steps are as follows

  1. Download the latest release of KerbalDev
  2. In Rider, install the plugin by going to the settings/plugins, and click the gear icon to install the zip file as a plugin from disk
  3. Now create a new solution via the new SpaceWarp Mod template, and fill out every parameter except Description/Source/Check Version

Post Template Instantiation

After you have instantiated the template, the next steps are to copy KSP2's DLL to the project, this is done by copying <KSP2 Root>/KSP2_x64_Data/Managed/Assembly-CSharp.dll intoto the <project root>/external_dlls/ folder

Now you should be set up with an example project and can get started on your mod.