This guide aims to get you setup in the repo and able to build the code.
- Clone / download this project
- IDE: Download Rider or Visual studio. Use Rider if you do not want to waste tons of time resizing things or trying to switch between folder paths and solution paths. Visual Studio is not intuitive or user friendly.
- (optional) Unity: Download Unity Hub
- Unity is only required if you are changing scripting related to the prefabs
- Running things
- Open the whole project with Rider. Typically you can double click on ValheimRAFT.sln to open it
- Unity -> Open the ValheimRaftUnity folder and install the Unity 2020 version
- copy paste https://github.com/Unity-Technologies/AssetBundles-Browser.git into the input under this interface in Unity. Window > Package Manager > (click plus arrow > click add package from giturl
- Compiling with the current branch libs folder
- You will not need to do anything. These libs are pre-built off the latest supported valheim, jotunn, bepinex.
- Skip this step If -
- you need to fix an issue after valheim updates, you will need to update, re-publicize, download newer bepinex and harmony references etc.
- Manual Compiling
- Do not reference the libs folder
- In the valheim.targets folder change the paths of PropertyGroup with "
LocalPaths" label. Make the paths match your install folders for
BepInExPlugins, BepInExPath to get to Harmony and BepInEx.dll and the
game folder
- alternatively just copy paste and override all the libs folders from the GameDirectory and download the new Jotunn and other required dependencies.
- Create a
.props
file at the top level of the project
Add the following data.
<!-- basically, this is needed to run valheim through the configuration -->
<PropertyGroup Label="ValheimPaths">
<!-- use GamePath property if the game is not located in the steam root folder -->
<GamePath>%Steam_Library_Path%\steamapps\common\Valheim</GamePath>
<ValheimServerPath>$(GamePath) dedicated server</ValheimServerPath>
<R2ModManPath>%APPDATA%\r2modmanPlus-local</R2ModManPath>
<R2ModManProfileName>profile-name</R2ModManProfileName>
<R2ModManProfile>Valheim\profiles\$(R2ModManProfileName)</R2ModManProfile>
<PluginDeployTarget>BepInEx\plugins\zolantris-ValheimRAFT</PluginDeployTarget>
<PluginDeployPath>$(R2ModManPath)\$(R2ModManProfile)\$(PluginDeployTarget)</PluginDeployPath>
</PropertyGroup>
<PropertyGroup Label="LocalPaths">
<BepInExPath>$(R2ModManPath)\$(R2ModManProfile)\BepInEx\core</BepInExPath>
<ManagedDataPath>$(GamePath)\valheim_Data\Managed</ManagedDataPath>
</PropertyGroup>
With SandboxieVm for running two games at same time with two steam users.
<PropertyGroup Label="SandBoxie">
<SandboxieVMPath>C:\Sandbox\%user%\steambox</SandboxieVMPath>
<SandboxieR2ModManPath>user\current\AppData\Roaming\r2modmanPlus-local</SandboxieR2ModManPath>
<SandboxieValheimPath>drive\D\steam\steamapps\common\Valheim</SandboxieValheimPath>
<SandboxiePluginDeployPath>$(SandboxieVMPath)\$(SandboxieR2ModManPath)\$(R2ModManProfile)\$(PluginDeployTarget)</SandboxiePluginDeployPath>
</PropertyGroup>
Alternatively copy pasting the Valheim\valheim_Data\Managed and other require dependencies into "libs" will make this step unnecessary.
Note: if you still see a lot of errors after importing all the libraries, this may be due to the fact that your IDE does not support the latest version of C#. Support depends on the version of the NET SDK (see).
Publicizing manually is not needed. There is a nuget package that handles this
for us. We can drop the valheim reference into the libs folder or map to the
game directory and the publicizer will automatically update the lib.
If nuget or your IDE Rider/Visual Studio do not install the provided nuget
package then you may need to run nuget restore
Publicizer for assembly_valheim steps.
- Alternatively to publicize, copy all the dependencies required into a separate folder.
- Install https://github.com/CabbageCrow/AssemblyPublicizer and run the GUI tool on that folder.
- Rename the __publicized assemblies back to their original names.
- Move those assemblies to the libs folder under ValheimRaft.
- Click compile. It should work.
use Rider and click nuget (should be bottom left panel, one of the items), and search for the package
- Install nuget.exe
- For installing sentry as an example run.
..\..\programs\nuget.exe install Sentry -Version 3.41.3 -OutputDirectory Packages`
The example above is if the path for nuget exists 2 directories above this repo and within programs folder.
Add this to your powershell profile. This will allow you to highlight only logs from ValheimVehicles and ValheimRAFT mods as well as errors. (about profiles)
These commands are for powershell users. If you are running things on linux there are simpler (and similar) commands for syntax highlighting. I advise googling them.
function Get-LogColor {
Param([Parameter(Position=0)]
[String]$LogEntry)
process {
if ($LogEntry.Contains("ValheimRAFT") -or $LogEntry.Contains("ValheimVehicles")){
if ($LogEntry.Contains("Debug")) {Return "Green"}
elseif ($LogEntry.Contains("Warn")) {Return "Yellow"}
elseif ($LogEntry.Contains("Error") -or $LogEntry.Contains("NullReferenceException")) {Return "Red"}
else {Return "White"}
}
if ($LogEntry.Contains("NullReferenceException")) {Return "Red"}
else {Return "White"}
}
}
When launching the game just run the following command to output the latest logs.
gc -wait -tail 10 C:\Users\__username__\AppData\LocalLow\IronGate\Valheim\Player.log | ForEach {Write-Host -ForegroundColor (Get-LogColor $_) $_}
Please reference ValheimDebugging