Zlepper.RimWorld.ModSdk
0.0.6
See the version list below for details.
<Sdk Name="Zlepper.RimWorld.ModSdk" Version="0.0.6" />
RimWorld ModSdk
This is a dotnet sdk that allows you to create mods for RimWorld with less messing with configurations.
Features
- Provides support for C# 10 (At least the features .NetFramework can support).
- Allows multiple RimWorld versions to be supported at the same time.
- Automatically references common RimWorld assemblies.
- Provides an easy hook for referencing more assemblies.
- Easily reference other Steam mods for your mod.
- Harmony and HugsLib have special support, to make them even easier to reference.
- Other local mods for development can are automatically referenced in an msbuild
<ProjectReference>
is created.
- Automatically copies the mod to the RimWorld mods folder.
- Support for Rider + Visual Studio run buttons without additional configuration.
- Debugging is not yet magically supported and does require additional manual configuration.
- Implicit
using
s forRimWorld
,Verse
,System
,System.Collections.Generic
andSystem.Linq
. - Fully automatically generated
About.xml
file. - The
PublishedFileId.txt
is automatically back into the project when the mod is build the mod has been published to Steam.
Installation
A word of warning: I develop on Windows and have only tested this on Windows. It should be possible to tweak enough settings to get it working on other platforms, but I have not done so. If you are using Linux or Mac, please let me know if you want to help get it working for those platforms.
- Make sure you have at least a DotNet 6 SDK installed: https://dotnet.microsoft.com/en-us/download
- Open your IDE and create a new project, the specific project type does not matter, but I recommend a class library.
- Open the .csproj file and replace the content with the following:
<Project Sdk="Zlepper.RimWorld.ModSdk/0.0.6">
<PropertyGroup>
<RimWorldModName>Your mod name</RimWorldModName>
<RimWorldPackageId>Your.Mod.PackageId</RimWorldPackageId>
<Authors>Your Name</Authors>
<Description>
This is a good description.
It can even be multiline.
</Description>
</PropertyGroup>
</Project>
- Create a new class and add the following code:
namespace MyName.MyFancyMod;
[StaticConstructorOnStartup]
public static class MyMod
{
static MyMod()
{
Log.Message("Hello World from MyMod!");
}
}
- If you get compile errors at this point, the SDK might not be able to locate your RimWorld installation, please see the "Optional configuration" section
and try setting
<RimWorldPath>
to the path to your RimWorld installation. - Run the project and wait for RimWorld to load.
- Go into mod settings and enable your mod.
- Check the RimWorld dev tools for a message from your mod.
- Now, go and implement your mod! (Tip: Read the Tips and Tricks section)
Tip and tricks
- You don't need maintain your own structure for your mod, you can just add files to your project and
they will be copied to the mod folder for your current RimWorld version. For example: Add a
Defs
folder with aThingDefs
folder inside and add aMyThingDef.xml
file to it. It will be copied to the mod folder.- This also works for all the other "standard" folders RimWorld has:
About
,Defs
,Languages
,Textures
,Sounds
andPatches
. The "Assemblies" folder is generated automatically your assemblies when you build your project.
- This also works for all the other "standard" folders RimWorld has:
Configuration
The SDK contains several settings that can be configured in the .csproj file. Some of these are required to be set, while others are optional.
Required configuration:
<PropertyGroup>
<RimWorldModName>My Mod Name</RimWorldModName>
<RimWorldPackageId>My.Mod</RimWorldPackageId>
<Authors>My Name</Authors>
<Description>
This is a good description.
It can even be multiline.
</Description>
</PropertyGroup>
Optional configuration:
This shows the default values each parameter have, so if you are happy with those values, no need to tweak them.
<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<IncludeHugsLib>false</IncludeHugsLib>
<IncludeHarmony>false</IncludeHarmony>
<OutputFolder>../Mods</OutputFolder>
<RimWorldImplicitUsings>enable</RimWorldImplicitUsings>
<RimWorldPath>C:\Program Files (x86)\Steam\steamapps\common\RimWorld</RimWorldPath>
<RimWorldVersion>(infered based on your installation)</RimWorldVersion>
<RimWorldModUrl></RimWorldModUrl>
</PropertyGroup>
Adding a reference to a RimWorld assembly
By default the SDK references Assembly-CSharp
and UnityEngine.CoreModule
for you. If you need to reference
another assembly, you can do so by adding a reference to it in the project file. For example, if you want to
reference UnityEngine.IMGUIModule
, you can add the following to your project file:
<ItemGroup>
<RimWorldAssemblyReference Include="UnityEngine.IMGUIModule" />
</ItemGroup>
Adding a reference to another mod
The sdk makes it very easy to reference and use other mods in your mod. For example, if you want to reference the VanillaExpanded framework, you can do this:
<ItemGroup>
<RimWorldSteamModDependency Include="OskarPotocki.VanillaFactionsExpanded.Core" />
</ItemGroup>
This will add a reference to the mod in the About.xml
file, and also add a reference to the mod's assembly
in your project. You can then use the mod's API in your mod.
This does require that you actually subscribe to the mod in Steam, and it has been downloaded. If you don't have the mod installed, you will get a compile error.
Controlling mod loading order
The following project item tags are available to control mod loading order if you don't have an explicit dependency to the given mod:
<ItemGroup>
<RimWorldLoadBefore Include="Some.Mod" />
<RimWorldLoadAfter Include="Some.Mod" />
<RimWorldIncompatibleWith Include="Some.Mod" />
</ItemGroup>
These tags works like their counterparts in the About.xml
file, and will be added to the About.xml
file
when you build your project.
If you already reference the mod using <RimWorldSteamModDependency>
, then you do not need to add <RimWorldLoadAfter>
,
that is done automatically.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.