How to setup your modding environment on Linux(Tutorial)

Users who are viewing this thread

Alright since I have been struggling to set up my PC to make mods for M&B 2 Bannerlord I'm going to compile it down into this thread so someone doesn't have to waste the same amount of time as I did.

I'm using Fedora 39.


SDK

As you're going to use the TaleWorlds.*.dll files you're going to need to code in C#. For this you're going to need the sdk. Luckily it's rather easy to install the sdk as Microsoft has a nice comprehensive tutorial on how to do it here both manually and scripted. I recommend the scripted one. After the installation you're going to want to check if the PATH variable was set.
To do this type:
Bash:
which dotnet
If a path is printed to your console: congratulations! The sdk was successfully installed and the PATH variable was successfully added meaning you can now move on to your next task.
If not: something went wrong during the installation. Very straight forward.

EDIT:
Should the install script say the SDK was successfully installed but no path is printed to the console check if the directory /home/<YourName>/.dotnet exists. If it does you can manually add it by typing:
Bash:
export PATH=$PATH:/home/<YourName>/.dotnet
Now the path should be printed.

IDE

Since Visual Studio isn't supported on Linux you're going to want to use VSCode as it can be easily installed and I have no idea how to do it otherwise. You'll also want to install it using the command line. This will add VSCode to your environment variables and thus can be started from the command line. This is important as it is possible that VSCode won't be able to start a terminal instance otherwise which in turn will prevent it from finding the dotnet sdk. To install VSCode on your machine follow this tutorial which covers multiple distros like Ubuntu, Fedora, Arch, etc.
Once you have installed VSCode type
Bash:
code --version
This should give you a result similar to this
Bash:
1.88.1
e170252f762678dec6ca2cc69aba1570769a5d39
x64
This will confirm VSCode was installed.
Once done you're going to open VSCode by writing
Bash:
code
I know very intuitive naming by Microsoft right there.


FIRST MOD

Anyway in VSCode you're going to head to the extension tab(on the left side of the screen) and search for "C# Dev Kit" and "vscode-solution-explorer". These are both gonna be very helpful although you're still going to need to do alot of writing.
After they're installed head to the Visual Studio symbol underneath the extention tab and create a Solution. Name it whatever you want.
Once done create a new project by right clicking on the solution you just created. An input field will open up at the top of the window.
Here you're going to type:
Class Library->C#->[Your mod name]->[Your mod name(again)]
This will create a class library project with a single file named "Class1.cs". Now you're almost done.

To actually write a mod you're going to need to reference and use the TaleWorlds.*.dlls.
For this head to your M&B 2 Bannerlord folder(something like "/run/media/yourname/MyHarddrive/SteamLibrary/steamapps/common/Mount & Blade II Bannerlord").
If you're having trouble finding it open steam->right click M&B2 Bannerlord->Properties->Installed files->Browse. Now navigate through the folders bin->Win64_Shipping_Client and COPY, not cut, all *.dll's that start with "TaleWorlds".
Now head to your project folder and go to bin/Debug/net8.0 and paste the copied files. If the folder doesn't exist build your project and VSCode will create them.

Now you have all the dlls but VSCode has no idea they even exist. For this head back into VSCode and click on the little pencil on the right side of your project's name to edit the *.csproj file.
Here you're going to add a new section:
XML:
<Project Sdk="Microsoft.NET.Sdk">
  <ProjectGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </ProjectGroup>
  <ItemGroup>
    <Reference Include="bin/Debug/net8.0/TaleWorlds.DotNet.dll">
    <Reference Include="bin/Debug/net8.0/TaleWorlds.Library.dll">
    <Reference Include="bin/Debug/net8.0/TaleWorlds.Localization.dll">
    <Reference Include="bin/Debug/net8.0/TaleWorlds.MountAndBlade.dll">
  </ItemGroup>
</Project>
This will reference the DotNet, Library, Localization and MountAndBlade dlls and enable you to follow this starter tutorial.


FINALLY DONE

After all this you can somewhat easily create mods for M&B 2 Bannerlord on Linux. Of course just remember to reference the dlls or if you really want to torture yourself add them all in one go. Why is this torture? Well I'm glad you asked! Should you make a typo and the dll isn't found VSCode won't tell you anything! So I advice you to only add the dlls as you need to because then you won't have to pull your hairs out trying to figure out why it suddenly doesn't find an assembly reference.

Any way I hope all this helped and I still wish you lots of fun and luck making mods!


KEEP IN MIND
Since M&B 2 Bannerlord is written in the .Net Framework 4.7.2 you won't be able to do anything other than logical manipulation(adding menus, subscribing to events, etc) but not anything OS related like reading/writing files as there would be a version mismatch. I'm actively searching for a solution though and any help would be greatly appreciated.
 
Last edited:
good stuff, thanks for posting!

sidenote from someone modding on Windows: I think Jetbrains Rider runs on Linux - it is, of course, paid software (unless you're a student, then you can get a free license!). works super well for me (again, on windows) and also makes adding references far easier
 
Hello. I'm looking for help with using mods on Linux. Since you seem to know what you're doing with modding, I was hoping that maybe You could help me with my problem.

I have a Linux Mint with the gog version of Bannerlord insatlled via Lutris. The core game works just fine, no crashes or bugs. I wanted to play the Empires of Europe mod, but when I downloaded and put every required mod into the Modules folder and started the game it crashed at the start.
Well it crashes with all the mods selected, but doesn't crash with only Harmony selected.

I have logs that Lutris shows and also the logs located in the ProgramData/Mount and Blade II Bannerlord/logs and /crashes folders. I've been trying to go through them myself, but I'm not that good at understanding what the heck is going on.
My hunch tells me that it's something with missing dll files or with not being able to verify the dlls. At least from what the log is showing.

Could you please help me?

Here are links to some logs that I think are the most useful:
launcher_log_93015.txt -
Lutris log -
 
Back
Top Bottom