Modding Toolchain - Cities Skylines 2 Wiki (2024)

Contents

  • 1 The Basics
    • 1.1 Modding Launch Parameters
  • 2 Modding Options
  • 3 Requirements
    • 3.1 IDE
    • 3.3 Unity Mod Project
    • 3.4 .Net SDK
    • 3.5 Node.js
  • 4 C# Mod Project Template
    • 4.1 Understanding the Template
    • 4.2 Project Variables
    • 4.3 Important to note
    • 4.4 Building the Mod
  • 5 How to publish a Code Mod
  • 6 UI Mod Project Template
  • 7 Local Mods Location
  • 8 External Documentation

Cities Skylines II enables the creation of Code Mods to add-on to or modify existing gameplay using the Modding Toolchain.

You do not need to install the Modding Toolchain if you only want to download and use mods from Paradox Mods

The Basics

Modding Launch Parameters

Add the following launch parameters to activate different modes to help with mod development.

  • --developerMode
    • Allows you to access the developer menu by pressing ⇆Tab
    • Allows you to access the add object panel in game by pressing 🏠 Home
See also: Developer mode

Modding Options

Modding Options

The Modding section of the Options menu assists the modder in setting up the Modding Toolchain; the necessary environment to develop mods - minimizing the amount of software installation hunting required by users.

Warning
  • The toolchain detection is not completely bulletproof due to the multiple ways one can install all the dependencies.
  • If you are a developer and already have set up a programming environment on your machine, you may want to upgrade the versions of your software first from their original source.
  • It is also recommended to use the Uninstall buttons with caution to avoid disrupting your previously installed development environment.

The toolchain acts as a minimalistic SDK and allows you to build mods, both C# and UI for Cities: Skylines II when all the entries show a green checkbox.

The user flow is intuitive - if a dependency is missing, you can install it, if it is installed you can uninstall it, if it is outdated or corrupted, you can upgrade or repair it. Additionally, the toolchain will use the main menu notification panel to inform the players of tasks that require attention.

Requirements

IDE

The Modding toolchain does not install any IDE for you, if you are not already familiar with one, you must download and install, and try to find which is the best fit for you.

A supported IDE is mandatory in order to execute the needed steps to build functional CSII mods.

For C# mods:Microsoft Visual Studio 2022 (17.8) or Jetbrains Rider (2021.3.3) are the minimum versions supported.You can use either one.Note: it may also be possible to use other software or earlier versions in some cases, but the source code generation feature from Visual studio 2022 and Rider 2021.3.3 is mandatory to successfully compile Entities and Burst code. Additionally, the template projects to start modding may not be compatible with earlier versions or other software.

For UI mods:Microsoft Visual Studio Code (1.86) or Jetbrains Rider (2021.3.3) are the minimum versions supported.You can use either one.Note 1: it may also be possible to use other software or earlier versions in some cases. These IDEs just act as convenience on top of Node.js npm and webpack.Note 2: the game UI is written in html, css and js. It is more or less a standard react project using typescript. Labs user interface library is used to execute javascript and render the UI. While it is quite close to web standards, it is important to remember some css features are not supported in a standard way.

Unity Editor & License

The Unity editor version 2022.3.7f1 is required to be installed.It acts more or less like an SDK and you do not have to use it but you must have it installed with at least a valid personal or commercial license if you have one already you wish to use.

The version of the editor must be updated to the same version used by the game with future updates. The toolchain will detect outdated versions.The license is a legal requirement we can not automate, so you must create a Unity account in the installation process and activate it in Unity hub. The toolchain will download the correct version of Unity from the official download link and silently run the installer with default settings.

Unity Mod Project

Unity alone does not install all the required dependencies in order to compile C# mods, it is also necessary to acquire packages such as Entities and Burst. The toolchain will copy a template Unity project to the user persistent folder and open it. This step will start Unity and open that project, it takes a while but needs to be done only once per version.

Once imported, the project will close itself and the dependency be marked as installed.

This mod project step will enable our compilation pipeline to access the Burst compiler, IL post processors and the source code generators required, as well as allow mods to reference Unity assemblies needed to compile the mods.

.Net SDK

.Net SDK is used for various things, tooling and helpers. The minimum version supported is 6 but 8 is recommended.

The toolchain will download .Net 8 from the official download link and install it in the background silently.Note: As .Net can be installed in several different ways, this dependency may fail to be uninstalled through the toolchain if it was, for example; installed as a Visual Studio installer package.

Node.js

Node.js is only necessary for UI mods development. Minimum supported version is 18.

The toolchain will download Node.js 20.11 from the official download link and install it in the background silently.Node.js runs as a background service so if you have it installed prior to running the toolchain, it is good to remember processes that are already started will not inherit new environment variables. Some dependencies will modify the user environment variables so if you have node.js previously installed, you may get errors about missing environment variables until the computer or at least the node processes restarted.

C# Mod Project Template

Understanding the Template

This template is embedded into the game installation. It is a nuget package deployed using dotnet new install/uninstall tooling. Once installed, it will enable both Visual Studio and Rider to create an empty solution compatible with CSII mods.

Rider new solution template

Visual Studio new project template

This project will set the following environment variables used with the tooling downstream. In some cases when using non-standard folders, you may have to edit some of these manually. While it appears some could easily be coalesced into less variables, they are split this way intentionally with future proofness in mind.

Project Variables

CSII_INSTALLATIONPATHThe installation path of the game.

For steam, default would be:C:\Program Files (x86)\Steam\steamapps\common\Cities Skylines IIwhile a typical installation on a different drive would be:E:\SteamLibrary\steamapps\common\Cities Skylines II

CSII_USERDATAPATHThe path to the user persistent folder used by the game.

Typically is C:\Users\<username>\AppData\LocalLow\Colossal Order\Cities Skylines II

CSII_TOOLPATHThe path to the user tooling (where the game deploy mutable toolchain data)

Typically CSII_USERDATAPATH\.cache\Modding

CSII_LOCALMODSPATHThe user path to local Mods.

Typically CSII_USERDATAPATH\Mods

CSII_UNITYMODPROJECTPATHThe path to the Unity mod project.

Typically CSII_TOOLPATH\UnityModsProject

CSII_UNITYVERSIONThe version of Unity currently in use by the toolchain

Typically Unity 2022.3.7f1

CSII_ENTITIESVERSIONThe version of Entities currently in user by the toolchain

Typically 1.0.14

CSII_MODPOSTPROCESSORPATHThe path to the Mod Post Processor helper tool

Typically CSII_INSTALLATIONPATH\Cities2_Data\StreamingAssets\~Tooling~\ModPostprocessor\ModPostProcessor.exe

CSII_MODPUBLISHERPATHThe path to the Mod Publisher helper tool

Typically CSII_INSTALLATIONPATH\Cities2_Data\StreamingAssets\~Tooling~\ModPublisher\ModPublisher.exe

CSII_MANAGEDPATHThe path to the game managed assemblies.

Typically CSII_INSTALLATIONPATHCities2_Data\Managed

CSII_ASSEMBLYSEARCHPATHA collection of additional paths to resolve assemblies, semicolon separated paths.

Typically empty or unset.

CSII_PATHSETTypically always Build

Important to note

When creating a new mod project from a template, there are a few important things to know:

You may be prompted to select a PDX account path if the IDE UI supports it, you can edit that path in YourProject.csproj later. It will default to a file called pdx_account.txt placed on your current user Desktop. Edit that path if necessary. The format of the file expects your Paradox Account username on the first line and your password on the second line. This file is used to identify you when you publish a mod on Paradox Mods.

<PDXAccountDataPath>$(USERPROFILE)\Desktop\pdx_account.txt</PDXAccountDataPath>

Security Warning
This file is private and should be in a safe location on your computer that is not part of a project so it will not be inadvertently shared along with your mod.

Mod.props and Mod.targets are automatically added to your solution and shared between all your solutions. Those are generic configurations that are aligned with the previously set environment variables. You should never have to manually edit the content of those files.

PublishConfiguration.xml – this is the file used to specific properties uploaded to Paradox Mods along with your mod. Edit this file according to your wishes.

The LongDescription and ChangeLog field supports multi-line and subset of markdown (headings, bullet lists and bold text), as the example below demonstrates:

 <LongDescription># Title## Subtitle* Bullet 1* Bullet 2**Bold thanks** </LongDescription>

Beware text editors are stubborn and will try to reformat your file with indentation. You must ensure there are no spaces at the beginning of the multi-line entries to avoid issues.

Building the Mod

Building a mod follows the standard MSBuild process, compilation is performed using Roslyn C# compiler, using the standard compiler mechanics for source generation and executes an AfterBuild step that will run ModPostProcessor.exe on the compiled assembly.

All build output goes to the usual console in your IDE.

ModPostProcessor interfaces with the Unity project that was previously installed to run various IL Post Processors on the assembly, patches method calls for source generation and finally executes the Burst compiler for you so that code marked as Burst gets compiled to native and heavily optimized.This will result in your assembly and 3 extra native dll next to it, one for Windows, one for Linux and one for Mac. Linux and Mac are currently unused, but shall Mac and Linux support come out one day, already existing mods will just work so we still compile to these platforms even if the game is not released there at this time.

At this point, your mod should be able to load in the game and will be copied to CSII_LOCALMODSPATH as a last step. (C:\Users\<username>\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods\).

Upon starting the game, your mod will be executed after the builtin game world has been created.

Mods subscribed through Paradox are delay-loaded to when the login is viable, for consistency, local mods are also delayed to about the same time. Due to this behaviour, you can not inject mod code super early in the game initialization process, while this may feel like a limitation, injection prior to that time would be rather unsafe and most of the time avoidable.

How to publish a Code Mod

Publishing a Code Mod to Paradox Mods is done directly through the mod project:You need to right click on your main mod project and select Publish (VS2022 only) or select the configuration from the top bar (Rider). This step will read the data from PublishConfiguration.xml and execute the helper tool ModPublisher.exe to upload the mod.

You are offered 3 options:

PublishNewModThis configuration uploads a new mod. At the end of the upload, the console log will show a ModID guid (typically 6 digit number).At this point you should copy that ModId into the PublishConfiguration.xml ModID field as it will be required for the 2 other publishing modes.

PublishNewVersionThis configuration updates an existing mod to a new version. This expects a new version number and a change log.

UpdatePublishedConfigurationThis configuration updates the metadata found in PublishConfiguration.xml on the server.

Publish in Visual Studio

Publish in Rider

UI Mod Project Template

This template is embedded into the game installation. Once installed, it is an npx template and can be deployed using npx create-csii-ui-mod'. It is added to your global node modules registry when installed using npm link.

npm install

The project will download the required dependencies and can be opened in your IDE using code <Project name> or rider <Project name>/

installing project dependencies

Rider and VSCode work roughly the same, index.tsx is used to define the injection points of your UI mod in the react DOM. Writing UI is much like writing react components.

installing project dependencies

You can use UI or shell to compile your mod:

  • npm run build will create a production build of the mod.
  • npm run dev will run the watch mode, used in parallel with –-uiDeveloperMode argument when starting the game, you can get the UI hot reload in the game as you change it. When the game is started with -–uiDeveloperMode, you can connect the Chrome Debugger using http://localhost:9444.

You will then be able to inspect the DOM, see the console and access pretty much all the dev tools you need to develop your UI mod.

Local Mods Location

For both UI and C# mods, the default output after compiling a project is in the user persistent folder under the Mods/ModName path: C:\Users\<username>\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods

The game will load local mods automatically. You can disable a mod temporarily by adding a "." before the folder name and start the game. E.g. Mods/.MyMod and it will be ignored.

External Documentation

Here are some relevant links that may help modders with the new game infrastructure.

Modding Toolchain - Cities Skylines 2 Wiki (2024)

FAQs

How do I import a Heightmap in Cities: Skylines 2? ›

Heightmaps created with external tools should be placed under Heightmaps/ folder in the game's appdata directory - typically C://Users/[username]/AppData/LocalLow/Colossal Order/Cities Skylines II/Heightmaps/ - after which they can be imported from the menu that opens from the Import Heightmap… button.

How do you trade water in Cities: Skylines 2? ›

How to Export Water in Cities: Skylines 2
  1. To export water, connect a water pipe from your freshwater network and then connect the pipe along the very edge of your city's border.
  2. Once connected, your city will automatically receive funds for all water exported to neighboring cities.
Oct 31, 2023

How to solve not enough buyers in city Skyline? ›

To resolve this problem, you have two options: either increase the number of commercial zones or reduce the number of industrial spaces in your city. Expanding the commercial zones will generate more demand for the materials produced in your city, effectively increasing the number of buyers.

How to unlock Lazaret Plaza? ›

The Lazaret Plaza is a Unique building unlocked by having health in your city be less than 20% for 3 weeks.

What is the maximum population in Cities Skylines 2? ›

Cities: Skylines 2 has no cap on the number of people it can track, and it's basically the Matrix.

Can you import sewage in Cities: Skylines 2? ›

They can also export any sewage they can't dump or treat in-city, but they can't import sewage to make use of local water treatment plants.

What is the groundwater deposit in Cities: Skylines 2? ›

The groundwater deposits are accessible through the Groundwater Pumping Station. The groundwater deposits have a replenishment rate which refills their water level over time. However, unlike surface water areas, groundwater deposits can temporarily dry up if their usage is higher than their replenishment rate.

How to solve not enough customers in Cities: Skylines 2? ›

Citizens in Cities: Skylines 2 feel this way too. A good strategy to provide enough customers for stores and vice versa is to place commercial zones near residential zones. Citizens don't have to travel too far, and the commercial buildings will get enough customers due to their proximity.

Why am I losing money so fast in city skylines? ›

If you are losing that much, you are building your city wrong. Start by placing a residential zone, and zone only a small patch of commercial and industrial. Don't place too many roads. You'll be in the positive easily.

How do you get rid of unlimited money in cities skylines? ›

Start the game and enter the Content Manager and click on Mods. Scroll down to Unlimited Money and uncheck it and exit the Content Manager. Load your city from the Load City menu. While it will show unlimited money, just start it, but do not be surprised if it shows a large deficit.

How do you not run out of money in city skylines? ›

How to Make Money in Cities: Skylines 2
  1. Sell Excess Electricity and Water to Neighboring Cities.
  2. Create Districts and Impose Parking Fees.
  3. Increase Zone Taxes.
  4. Reduce Service Budgets.
  5. Don't Invest in Services and Upgrades Unless They're Needed.
Nov 1, 2023

How to get eden project cities skylines? ›

The Eden Project requires the following unique buildings: Statue of Industry, Friendly Neighborhood Park, Official Park, Gateway Arch, Servicing Services Offices, and Cathedral of Plentitude.

How to unlock Posh Mall? ›

Posh Mall: Requires all tax rates at most 4% for 20 weeks. (Cut your taxes to 4% across the board and wait for 20 weeks. You should be fine as long as you have a few million. You can even run out of money, just keep refusing the bailout.)

How to get the Plaza of the Dead? ›

The Plaza of the Dead is a memorial park to honor the care and love given to the deceased of the city. Earned by achieving 3 completely filled cemeteries within one city.

How do I import a heightmap? ›

Importing Custom Heightmaps
  1. Open the Landscape tool and click the New button from the Manage Mode tab.
  2. Select Import from File.
  3. Click the button in the Heightmap File section and choose the example Heightmap you downloaded earlier.
  4. Now press the Import button to create a new Landscape based on your heightmap.

How to add maps to Cities Skylines 2? ›

Using Thunderstore APP or rModMan, installing maps is a breeze:
  1. Install MapInstaller: Obtain MapInstaller via your chosen mod manager. A one-time installation is required.
  2. Install Maps: Select and install your maps from the mod manager. MapInstaller will automatically install or update the maps when you start the game.

How do I import mods into cities skylines? ›

  1. Search a mod that you like in the workshop.
  2. Click the subscribe button. ...
  3. Start Cities: Skylines.
  4. Go to 'Content Manager'
  5. Go to 'Mods' (left frame)
  6. Look up the mod you downloaded and make sure it is enabled (tick the box)
  7. Load your city or start a new one.
  8. Have fun!
Jan 1, 2016

Top Articles
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 5453

Rating: 4.3 / 5 (74 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.