5. Build Instructions - BrettRyland/BDArmory GitHub Wiki

Currently the code should work with Visual Studio 2015 or 2017 in Windows or dotnet v8 (dotnet-sdk-8.0) in Linux. See the following documentation on configuring your environment for Debug

Note for debug, the current Unity version for KSP is 2019.2.2f1. Shader bundles need to be created with 2018.4.36f1 for backwards compatibility with older KSP versions.

LocalDev Configuration

  • Create the folder _LocalDev above the BDArmory folder (this is so that it can be common to multiple KSP mods). E.g.,
github
|-- _LocalDev
|   |-- ksp_dir.txt
|   |-- KSPRefs -> ~/Games/KSP/KSP_Data/Managed  (use a symlink or copy the KSP/KSP_Data/Managed to here)
|   |-- 7za_exe.txt                              (only needed on Windows)
|   |-- dist_dir.txt                             (only needed on Windows)
|-- BDArmory
|-- SomeOtherMod
  • Edit the text files with the local paths E.g., something like
    • ksp_dir.txt (Linux) — Multiple destinations can be specified.
    #/home/user/.steam/steam/steamapps/common/Kerbal Space Program  # It's recommended to make a copy of KSP and not modify the steam install.
    /home/user/Games/KSP
    
    • ksp_dir.txt (Windows) — Only a single destination can currently be specified.
    C:\<path to KSP>
    
    • 7za_exe.txt
    C:\<path to 7-zip executable>\7z.exe
    
    • dist_dir.txt
    C:\<path to BDA repo>\BDArmory\Distribution
    

Windows build instructions

  • Compile the BDArmory project in Visual Studio to build the DLL.
  • If the project compiles and the post-build instructions in the
    <PostBuildEvent Condition="'$(OS)' == 'Windows_NT' ">
    
    section of the BDArmory.csproj file works correctly, then
    • the newly built DLL should be copied to the Distribution\GameData\BDArmory\Plugins folder,
    • a new zip archive should be created in Distribution\BDArmory.VERSION_TIMESTAMP.zip,
    • the Distribution\GameData\BDArmory folder should get copied to the location in the ksp_dir.txt file.
  • If the post-build instructions don't work (due to incorrectly configured _LocalDev or similar), then copy the DLL and any modified files in Distribution\GameData\BDArmory manually to your KSP folder.
    • Any missing localization are typically due to forgetting to copy the Distribution/GameData/BDArmory/Localization/UI/en-us.cfg file (or equivalent for other languages).
Old build instructions in case the above doesn't work

The Following Pre and Post build code is currently in the project

Pre-Build

This will copy the appropriate KSP DLL's from the paths specified in the LocalDev folder

@echo $(Targetname)
SET ModName=BDArmory
@echo ...
@echo set lpath vars from LocalDev storage...
set /p KSP_DIR=<"$(ProjectDir)LocalDev\ksp_dir.txt"
set /p PDB2MDB_EXE=<"$(ProjectDir)LocalDev\pdb2mdb_exe.txt"
set /p ZA_DIR=<"$(ProjectDir)LocalDev\7za_dir.txt"
set /p DIST_DIR=<"$(ProjectDir)LocalDev\dist_dir.txt"

@echo Copying KSP assemblies from "%KSP_DIR%\KSP_x64_Data\Managed" to "$(ProjectDir)LocalDev\Refs" folder...
copy /Y "%KSP_DIR%\KSP_x64_Data\Managed\Assembly-CSharp.dll" "$(ProjectDir)LocalDev\Refs"
copy /Y "%KSP_DIR%\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll" "$(ProjectDir)LocalDev\Refs"
copy /Y "%KSP_DIR%\KSP_x64_Data\Managed\KSPAssets.dll" "$(ProjectDir)LocalDev\Refs"
copy /Y "%KSP_DIR%\KSP_x64_Data\Managed\UnityEngine.dll" "$(ProjectDir)LocalDev\Refs"
copy /Y "%KSP_DIR%\KSP_x64_Data\Managed\UnityEngine.UI.dll" "$(ProjectDir)LocalDev\Refs"

@echo KSP API references copying complete!

Post-Build

Will build and zip up for distribution

@echo $(Targetname)
SET ModName=BDArmory
@echo ...
@echo set lpath vars from LocalDev storage...
set /p KSP_DIR=<"$(ProjectDir)LocalDev\ksp_dir.txt"
set /p PDB2MDB_EXE=<"$(ProjectDir)LocalDev\pdb2mdb_exe.txt"
set /p ZA_DIR=<"$(ProjectDir)LocalDev\7za_dir.txt"
set /p DIST_DIR=<"$(ProjectDir)LocalDev\dist_dir.txt"

@echo Copying assemblies to Distribution $(Targetname) files...
copy /Y "$(TargetDir)"BDArmory*.dll "$(ProjectDir)Distribution\GameData\%ModName%\Plugins\"

if $(ConfigurationName) == Debug (
@echo building debug files and symbols...
FOR %%A IN ("$(TargetDir)"BDArmory*.dll) DO (
call "%PDB2MDB_EXE%" %%A
)
copy /Y "$(TargetDir)"BDArmory*.dll.mdb "%KSP_DIR%\GameData\%ModName%\Plugins\"
copy /Y "$(TargetDir)"BDArmory*.pdb "%KSP_DIR%\GameData\%ModName%\Plugins\"
)

@echo deleting previous build ...
if exist "%DIST_DIR%\%ModName%*.zip" del "%DIST_DIR%\%ModName%*.zip"
@echo packaging new build...
call "%ZA_DIR%\7za.exe" a -tzip -r  "%DIST_DIR%\%ModName%.@(VersionNumber)_%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%.zip" "$(ProjectDir)Distribution\*.*"

@echo Deploy $(ProjectDir) Distribution files to test env:  %KSP_DIR%\GameData...
@echo copying:"$(ProjectDir)Distribution\GameData" to "%KSP_DIR%\GameData" 
xcopy /E /Y "$(ProjectDir)Distribution\GameData" "%KSP_DIR%\GameData"

@echo Build/deploy complete!

Linux build instructions

  • The dotnet command from the dotnet SDK (dotnet-sdk-8.0) can be used to compile BDArmory.
  • In the BDArmory/BDArmory folder, run
export FrameWorkPathOverride=/usr/lib/mono/4.8-api/
dotnet build --configuration Debug  # Add "/p:PostBuildEvent=" to skip post-build events.
  • If everything builds correctly, it should output something similar to
MSBuild version 17.8.5+b5265ef37 for .NET
  Determining projects to restore...
  Nothing to do. None of the projects specified contain packages to restore.
  BDArmory -> /home/user/github/KSP/BDArmory/BDArmory/bin/Debug/BDArmory.dll
  BDArmory
  Copying Debug assemblies to Distribution BDArmory files...
  building debug files and symbols...
  deleting previous build ...
  packaging new build...
  
  7-Zip (a) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
   64-bit locale=en_US.UTF-8 Threads:32 OPEN_MAX:1048576
  
  Scanning the drive:
  642 files, 60097374 bytes (58 MiB)
  
  Creating archive: /home/user/github/KSP/BDArmory/BDArmory/Distribution/BDArmory.1.8.0.1_2025-01-17T09:55:47+00:00.zip
  
  Add new data to archive: 642 files, 60097374 bytes (58 MiB)
  
  
  Files read from disk: 642
  Archive size: 43390898 bytes (42 MiB)
  Everything is Ok
  Deploy /home/user/github/KSP/BDArmory/BDArmory/ Distribution files to test env: /home/user/Games/KSP/GameData...
  copying:/home/user/github/KSP/BDArmory/BDArmory/Distribution/GameData to /home/user/Games/KSP/GameData

  Build/deploy complete!

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.84

⚠️ **GitHub.com Fallback** ⚠️