cookiecutter-rimworld-mod-development
A cookiecutter project that builds the basic Rimworld mod development file structure and sets up a sane build environment.
Table of Contents
Install/Setup
Windows Command Prompt
Required Programs
- git
- python
- cookiecutter (or
pip install cookiecutter
)
Usage (inside Rimworld/Mods folder)
cookiecutter gh:feldoh/cookiecutter-rimworld-mod-development
[Answer the prompts]
- Note that when it asks you
_visual_studio
you must respond{}
- Note that when it asks you
- Open the folder you just created and double-click the
ModName.sln
file - In the Solution Explorer view on the right, right click
RimWorldWin
and clickSet as Startup Project
Microsoft Visual Studio Integration
Required Programs
File -> New -> From Cookiecutter...
option is available)
Install (if no - Open up VS Installer (In Visual Studio -> Tools -> Gets Tools and Features)
- Click Modify
- Click Individual Components
- Scroll to Development activities
- Click the Cookiecutter template support checkbox
- Click Modify
Usage
- Open Visual Studio
File -> New -> From Cookiecutter...
- Search for
rimworld
- Double-click
feldoh/cookiecutter-rimworld-mod-development
- Change the Template Options:
Create To
=>[...]/RimWorld/Mods
Mod name
Author
(Use your Steam username for automatic linking of mod to profile) (can change later in About-Release.xml)Mod Description
(not required, can change later in About-Release.xml)- A few more options are available
Create and Open Project
Basic Features
Folder Structure
This cookiecutter builds the entire standard mod folder structure, with empty folders as the default. namespace_name
is automatically calculated.
- {{cookiecutter.mod_name}}
- About
- About-Debug.xml
- About-Release.xml
- Preview.png
- Assemblies
- Defs
- Languages
- Patches
- Sounds
- Source
- Properties
- AssemblyInfo.cs
namespace_name
.csnamespace_name
.csproj
- Properties
- Textures
namespace_name
.sln
- About
VS Setup Automation
- Links Rimworld and UnityEngine .dlls for importing in code
- Sets build events to automate file management of About-$Version.xml for tagging development versions.
- Clears the default set trace constant
- Creates a VS solution with correctly defined paths
- Clicking
Start ▶️
will preform the designated build sequence and start Rimworld.exe tied to a Visual Studio resource monitor.
Advanced Features
Debug/Release Versioning
This cookiecutter setup takes full advantage of VS debug/release versions
- Debug mode
- About-Debug.xml contains instructions on editing About-Release.xml and has a separate title for easy recognition from the Release version
- Building creates an About.xml from About-Debug.xml with a "- Dev Build" tag to be easily distinguishable in the mod list
- The resulting .dll is placed in "{{cookiecutter.mod_name}}/Assemblies"
- Release mode
- About-Release.xml is copied to "{{cookiecutter.mod_name}} - Release/About/About.xml" and does not include the "- Dev Mode" tag in its title
- Building creates or updates the Release version of the mod. Solely the essential files are copied into a separate Release mod folder for a clean version of the mod
Optional Debug Save Profile
Accident Forgiveness
- Edits in either generated temporary About.xml file (release or debug) won't get overwritten as long as the About-$Version.xml file it was copied from is not updated
- Items edited in the Release directory will not be overwritten with older data from the Debug/Dev directory
Issues
The imported project "C:\Program Files (x86)...\Microsoft.CSharp.Core.targets" was not found
If you're not using Visual Studio you may need to tell the project where your MS Build actually is.
- You can download MSBuild from Microsoft
- It will already be in your Rider directory and can be found under File -> Settings -> Build, Execution, Deployment -> Toolset and Build -> MSBuild Version
using HarmonyLib
is red)
Cannot Resolve Symbol HarmonyLib (Run dotnet restore
on the .csproj file for your code then try re-doing the nuget restore.