Editing Modding Tutorials/Setting up a solution

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 12: Line 12:
 
Setting up can be different for different IDE's. Feel free to add '''''complete''''' instructions for your IDE of choice.
 
Setting up can be different for different IDE's. Feel free to add '''''complete''''' instructions for your IDE of choice.
  
===Visual Studio Community 2022===
+
===Visual Studio Community 2017===
''NOTE: Visual Studio 2022 is a rather heavy application (2-3 GB for basic functionality) but works out of the box. It is strongly recommended if you are on Windows and have a PC that can handle it. This tutorial is similar for other versions of Visual Studio.''
+
''NOTE: Visual Studio 2017 is a rather heavy application (2-3 GB for basic functionality) but has a bit more functionality. Only Install if your computer can handle it! The tutorial is similar for Visual Studio 2015.''
  
  
Line 19: Line 19:
 
# Create a new class library project
 
# Create a new class library project
 
## Once loaded, go to File -> New -> Project...
 
## Once loaded, go to File -> New -> Project...
## Type "Class Library (.NET Framework)" in the search bar, and select the C# option. [[File:ClassLibrary.png|200px|thumb|right|Installing the .NET framework]]
+
## Go to Templates -> Visual C# -> Class Library (Be sure to select the *.NET Framework* version, not *.NET Standard*) [[File:Capture.png|200px|thumb|right|Installing the .NET framework]]
## Enter your project name.
+
## Enter your name and solution name in the lower pane.
 
## Choose a location, preferably:<br/><pre>(RimWorldInstallFolder)/Mods/(YourModName)/Source</pre>
 
## Choose a location, preferably:<br/><pre>(RimWorldInstallFolder)/Mods/(YourModName)/Source</pre>
## Enter a solution name (optionally, tick "Place solution and project in the same directory")
+
## ''Optional'': Untick "Create directory for solution"
## Make sure Framework is ".NET Framework 4.7.2"
+
# In your project, set target framework and various other porperties
# In your project, set target framework and various other properties
+
## In your Solution Explorer, right click your project -> Properties
## In your Solution Explorer (the panel usually located on the right), right click your project -> Properties (or expand your project and double click "Properties" with the wrench icon)
+
## Once in your properties, select Application -> Set Target Framework to .NET Framework 3.5 (No client profile)
## ''Optional'': Under Application, change your Assembly and Namespace names to anything of your choice
+
## ''Optional'': Change your Assembly and Namespace names to anything of your choice
 
## Go to Build -> Advanced... and set "Debugging information" to none
 
## Go to Build -> Advanced... and set "Debugging information" to none
## Leave Advanced..., and set the Output Path to "..\..\Assemblies\" (Or wherever the Assemblies folder is)
+
## Leave Advanced..., and set the Output Path to "..\..\Assemblies\" (The Assemblies folder in your mod folder)
 
# Add references to RimWorld code
 
# Add references to RimWorld code
## Expand your project in Solution Explorer. Then right click "References" -> Add Reference...
+
## Expand your project. Then right click "References" -> Add Reference...
 
## Click Browse...
 
## Click Browse...
## Navigate towards <pre>RimWorldInstallPath/RimWorld******_Data/Managed</pre> and select files: <br/><pre>Assembly-CSharp.dll&#10;UnityEngine.CoreModule.dll</pre>
+
## Navigate towards <pre>RimWorld******/RimWorld******_Data/Managed</pre> and select files: <br/><pre>Assembly-CSharp.dll&#10;UnityEngine.dll</pre>
 
## Click "Add"
 
## Click "Add"
 
## Click "OK" to close the Reference Manager.
 
## Click "OK" to close the Reference Manager.
## Right-click on both Assembly-CSharp.dll and UnityEngine.dll and set Copy Local to False (Properties pane).
+
## Right click on both Assembly-CSharp.dll and UnityEngine.dll and set Copy Local to False (Properties pane).
  
====Option 2 (Using Nuget):====
+
====Option 2 (Automatic Method):====
This option uses [https://www.nuget.org/packages/Krafs.Rimworld.Ref Krafs Rimworld Reference Package] it is less involved than using reference assemblies and is the recommended method.</br>
 
#Follow the above up till ''Add references to RimWorld code''
 
#From the Tools menu, select NuGet Package Manager -> Package Manager Settings.
 
##In the Settings dialog, under Package Management, change the ''Default package management format'' to '''PackageReference'''.
 
##Click OK to close the dialog.
 
#Open Nuget Manager and type ''Rimworld''
 
#Add Krafs Rimworld Reference
 
You can now continue as if you added the assemblies
 
Doing this makes your project portable, because RimRef can be downloaded by anyone and used from anywhere, unlike Rimworld's assemblies which can't be distributed.
 
 
 
====Option 3 (Using Rimworld Dotnet Template):====
 
This option uses [https://github.com/Zeta-of-the-rim/Rimwold-Dotnet-Template Rimworld Dotnet Template] it allows faster creation of mod files including Xml folders</br>
 
 
 
After installing the template.
 
#Open your mod folder
 
#create a new folder for your mod (It is best to use the name you want for your mod)
 
#Open a command prompt in that folder
 
#type ''dotnet new  RimMod'' (This will create a new mod with the name you specified)
 
#Open the About folder and edit the About.xml file
 
#Open the .sln file in your preferred IDE
 
#Add the rimworld assemblies using your preferred method
 
 
 
While this method is faster, it is still good to know how to do it manually.
 
 
 
====Option 4 (Using Cookiecutter):====
 
 
This option uses the [https://ludeon.com/forums/index.php?topic=39038.0 Rimworld Mod Development Cookiecutter] tool.</br>
 
This option uses the [https://ludeon.com/forums/index.php?topic=39038.0 Rimworld Mod Development Cookiecutter] tool.</br>
 
'''Note: despite being automatic and potentially taking away some of the tedium away, the environment it sets up is very particular and this tool is currently not recommended for newcomers.'''</br>
 
'''Note: despite being automatic and potentially taking away some of the tedium away, the environment it sets up is very particular and this tool is currently not recommended for newcomers.'''</br>
Line 92: Line 67:
 
## In your IDE project file browser, right-click the "References" folder and "Add reference";
 
## In your IDE project file browser, right-click the "References" folder and "Add reference";
 
## Choose the ".NET Assembly Browser" tab and "Browse...";
 
## Choose the ".NET Assembly Browser" tab and "Browse...";
## Navigate towards <pre>RimWorld******/RimWorld******_Data/Managed</pre> and select files: <br/><pre>Assembly-CSharp.dll&#10;UnityEngine.CoreModule.dll</pre>
+
## Navigate towards <pre>RimWorld******/RimWorld******_Data/Managed</pre> and select files: <br/><pre>Assembly-CSharp.dll&#10;UnityEngine.dll</pre>
 
## Click "Open" then "OK";
 
## Click "Open" then "OK";
 
## In the References folder, right-click Assembly-CSharp -> Properties and change "Local copy" to False. Do the same for UnityEngine,
 
## In the References folder, right-click Assembly-CSharp -> Properties and change "Local copy" to False. Do the same for UnityEngine,
# In your project properties, change the target framework to .NET 4.7.2:
+
# In your project properties, change the target framework to .NET 3.5:
 
## In your IDE project file browser, right-click "(YourSolutionName)";
 
## In your IDE project file browser, right-click "(YourSolutionName)";
 
## Choose Properties;
 
## Choose Properties;
## Go to the "Compiling" tab, "Output", "Target framework", "Change" and choose ".NET Framework 4.7.2",
+
## Go to the "Compiling" tab, "Output", "Target framework", "Change" and choose ".NET Framework 3.5",
 
# In your project properties, change the build events so only a single file is built:
 
# In your project properties, change the build events so only a single file is built:
 
## Go to the "Compiling" tab, "Output", "Debug info" and choose "No debug information";
 
## Go to the "Compiling" tab, "Output", "Debug info" and choose "No debug information";
Line 107: Line 82:
 
===Xamarin/MonoDevelop===
 
===Xamarin/MonoDevelop===
 
The setup is similar as the one above. A few special points to address:
 
The setup is similar as the one above. A few special points to address:
# Mono 4.X isn't backward compatible so you may need to install an older 3.X version of Mono in order to compile against .NET4.7.2 dlls.
+
# Mono 4.X isn't backward compatible so you may need to install an older 3.X version of Mono in order to compile against .NET3.5 dlls.
 
# Make sure you uncheck "Use MSBuild build engine (recommended for this project type)" under project > options > build > general  (You might find this by right-clicking on your project - not solution - name and selecting options)
 
# Make sure you uncheck "Use MSBuild build engine (recommended for this project type)" under project > options > build > general  (You might find this by right-clicking on your project - not solution - name and selecting options)
# Changing the framework to 4.7.2 can be found (for Linux anyway) in the same place.
+
# Changing the framework to 3.5 can be found (for Linux anyway) in the same place.
 
 
More detailed installation instructions for Linux can be found [https://blog.rubenwardy.com/2016/07/21/rimworld-setup-monodevelop/ here] and [https://spdskatr.github.io/RWModdingResources/mono-arch here]. Note that as of now (2021) these may be outdated, so if it doesn't work, you can try the steps described in the Mono section.
 
  
===Mono===
+
More detailed installation instructions for Linux can be found [https://blog.rubenwardy.com/2016/07/21/rimworld-setup-monodevelop/ here] and [https://spdskatr.github.io/RWModdingResources/mono-arch here].
On Linux and Mac(?) it is possible to use Mono regardless of IDE (from command line, or if your IDE/editor has build support).
 
# Install Mono (refer to your distribution's instructions);
 
# To build using .csproj files that other setups use, you need the ''dotnet'' tool, you can get it by installing the [https://dotnet.microsoft.com/download .NET SDK];
 
# If you're starting a new mod and want to use a .csproj file for compatibility with other modders, find e.g. a mod that has description pointing to its GitHub sources and copy from there;
 
# For building use a command like the following (substitute the proper .csproj file and 4.7.2 is the .NET version from the .csproj file):<br/><pre>FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.7.2-api/ dotnet build <project file>.csproj /property:Configuration=Release</pre>
 
# If you get errors, it is necessary to edit the .csproj file:
 
## You may need to fix paths (point them to .dll files in RimWorld/RimWorld*_Data/Managed);
 
## See other setups above for other settings (those IDEs write those settings to the .csproj files);
 
  
 
===Rider (good for Mac)===
 
===Rider (good for Mac)===
Line 131: Line 96:
 
## Set the Solution Directory to [your mod folder]/Source.
 
## Set the Solution Directory to [your mod folder]/Source.
 
## Optionally check "put solution and project in the same directory." This is probably a good idea.
 
## Optionally check "put solution and project in the same directory." This is probably a good idea.
## Change Framework to .Net Framework 4.7.2.
+
## Change Framework to .Net Framework 3.5.
 
## Click Create.
 
## Click Create.
 
# In the left side bar, expand your solution, right click your project (mod name with "C#" icon) and click Properties.
 
# In the left side bar, expand your solution, right click your project (mod name with "C#" icon) and click Properties.
Line 177: Line 142:
  
 
=Common issues=
 
=Common issues=
* Can't find the option to target .NET Framework 4.7.2? It may require additional installation steps. In Visual Studio, Tools => Get Tools and features => Individual Components => Select ''.NET Framework 4.7.2 development tools'' (or google installation instructions). Also make sure your project is a ''Class Library (.NET '''Framework''')''. Not .NET Core or .NET Standard.
+
* Can't find the option to target .NET Framework 3.5? Due to its age, it may require additional installation steps. In Visual Studio, Tools => Get Tools and features => Individual Components => Select ''.NET Framework 3.5 development tools'' (or google installation instructions). Also make sure your project is a ''Class Library (.NET '''Framework''')''. Not .NET Core or .NET Standard.  
  
 
=See also=
 
=See also=

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Templates used on this page: