Skip to content

About

Tools for developing mods for Kerbal Space Program

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

KSP1Retooled Build Tools

Documentation Status CI NuGet Version

This repository provides a common set of tools for developing mods for Kerbal Space Program and KSP Retooled. It integrates with MSBuild to simplify setting up plugins, and integrates with CKAN to easily reference other mods. it also includes a set of CI actions for automating builds.

Full Documentation

Installation

Run dotnet add package KSP1Retooled.BuildTools on your project, or add

<ItemGroup>
  <PackageReference Include="KSP1Retooled.BuildTools"/> 
</ItemGroup>

to the .csproj file. Pinning the version is highly recommended.

Usage

Once you have a KSP installation to link to, all the game DLLs will be automatically included in your project automatically.

Configure your mod's location in GameData and where to put the output DLLs

<!-- DLLs will be written to ../GameData/ModName/Plugins/ -->
<KSPBT_ModRoot>$(MSBuildThisFileDirectory)/../GameData/$(MSBuildProjectName)</KSPBT_ModRoot>
<KSPBT_ModPluginFolder>plugins</KSPBT_ModPluginFolder>

Reference dependency mods in your DLL by adding ModReference items to the project. They will be automatically installed using CKAN.

<!-- Depends on Modulemanager and Harmony -->
<ItemGroup>
  <ModReference Include="Modulemanager">
    <DLLPath>GameData/Modulemanager*.dll</DLLPath>
    <CKANIdentifier>ModuleManager</CKANIdentifier>
  </ModReference>
  <ModReference Include="0Harmony">
    <DLLPath>GameData/000_Harmony/0Harmony.dll</DLLPath>
    <CKANIdentifier>Harmony2</CKANIdentifier>
  </ModReference>
</ItemGroup>

Auto-generate version files from your project's FileVersion. This works well with minver.

<!-- Version Files -->
<ItemGroup>
  <KSPVersionFile Include=".">
    <Destination>$(KSPBT_ModRoot)/mymod.version</Destination>
    <URL>https://github.com/username/repo/releases/latest/download/mymod.version</URL>
    <Download>https://github.com/username.repo/releases/latest</Download>
  </KSPVersionFile>
</ItemGroup>

From there you should be able to build your mod with just dotnet build

KSP Retooled

Whether you are building for stock KSP or for KSP Retooled is detected from your KSP install. When building for Retooled the KSP_RETOOLED and UNITY_6_7 symbols are defined.

To build for both, set the path to each install in your .csproj.user file. Your mod then gets a MyMod.dll for stock KSP and a MyMod.zRetooled.dll for Retooled, and each game loads the right one.

<KSPBT_StockGameRoot>C:\Games\Kerbal Space Program</KSPBT_StockGameRoot>
<KSPBT_RetooledGameRoot>C:\Games\KSP Retooled</KSPBT_RetooledGameRoot>

For more details, see the MSBuild section in the docs.

About

Tools for developing mods for Kerbal Space Program

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages