Setting up a Development Environment: Difference between revisions

From KSP 2 Modding Wiki
m (Fix category)
(Some minor formatting changes + added required versions of VS and .NET)
Line 6: Line 6:


# That you own a copy of Kerbal Space Program 2
# That you own a copy of Kerbal Space Program 2
# That you have dotnet installed
# That you have the .NET 6 SDK or newer installed
# That you have an IDE such as Rider or Visual Studio, or some other way to compile C# code into a DLL
# That you have an IDE such as Rider or Visual Studio 2022, or some other way to compile C# code into a DLL
==Template Setup==
==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.
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===
===Visual Studio or no IDE===
First install the template using the following command in the command line
First install the template using the following command in the command line:
  dotnet new install SpaceWarp.Template
  dotnet new install SpaceWarp.Template
====Visual Studio====
====Visual Studio====
If you are then using Visual Studio to develop the mods, the next steps are as follows
If you are then using Visual Studio to develop the mods, the next steps are as follows:
# Open Visual Studio
# Open Visual Studio
# ''Create a new project''
# ''Create a new project''
Line 53: Line 53:
|}
|}
===Rider===
===Rider===
For rider the steps are as follows
For Rider the steps are as follows:
# Download the latest release of [https://github.com/arthomnix/KerbalDev/releases KerbalDev]
# Download the latest release of [https://github.com/arthomnix/KerbalDev/releases KerbalDev]
# 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
# 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
# Now create a new solution via the new SpaceWarp Mod template, and fill out every parameter except Description/Source/Check Version
# Now create a new solution via the new SpaceWarp Mod template, and fill out every parameter except Description/Source/Check Version
==Post Template Instantiation==
==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 <code><KSP2 Root>/KSP2_x64_Data/Managed/Assembly-CSharp.dll</code> intoto the <code><project root>/external_dlls/</code> folder
After you have instantiated the template, the next steps are to copy KSP2's DLL to the project, this is done by copying <code><KSP2 Root>/KSP2_x64_Data/Managed/Assembly-CSharp.dll</code> into the <code><project root>/external_dlls/</code> folder.


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

Revision as of 14:43, 16 April 2023

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 the .NET 6 SDK or newer installed
  3. That you have an IDE such as Rider or Visual Studio 2022, 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 into the <project root>/external_dlls/ folder.

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