From 2b3bf8864afca67b3c59a3147f73117931a52c45 Mon Sep 17 00:00:00 2001 From: Refringe Date: Mon, 4 Mar 2024 08:44:10 +0000 Subject: [PATCH] Converts Build Script to PowerShell (!87) In a push to automate project builds, this changes the build script from a BAT script to a PowerShell script. This is a cross-platform solution that should allow us to build the project within the `mcr.microsoft.com/dotnet/sdk:6.0` docker image (Debian). Also updates the README to list PowerShell 7 as a dependency as the `pwsh` tool is not available in Windows PowerShell (v5). Co-authored-by: Refringe Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/87 Co-authored-by: Refringe Co-committed-by: Refringe --- README.md | 1 + project/Aki.Build/Aki.Build.csproj | 10 +++--- project/build.bat | 52 ------------------------------ project/build.ps1 | 44 +++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 57 deletions(-) delete mode 100644 project/build.bat create mode 100644 project/build.ps1 diff --git a/README.md b/README.md index d6683d4..be9d152 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ git config --local user.email "USERNAME@SOMETHING.com" - Escape From Tarkov 28476 - Visual Studio Code -OR- Visual Studio 2022 - .NET 6 SDK +- [PowerShell v7](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows) ## Project Setup Copy-paste Live EFT's `EscapeFromTarkov_Data/Managed/` folder to into this project's `Project/Shared/Managed/` folder diff --git a/project/Aki.Build/Aki.Build.csproj b/project/Aki.Build/Aki.Build.csproj index 2b422d2..c4e1d46 100644 --- a/project/Aki.Build/Aki.Build.csproj +++ b/project/Aki.Build/Aki.Build.csproj @@ -1,8 +1,8 @@  - net471 - Release + net471 + Release @@ -22,12 +22,12 @@ - - + + - + diff --git a/project/build.bat b/project/build.bat deleted file mode 100644 index 03ff394..0000000 --- a/project/build.bat +++ /dev/null @@ -1,52 +0,0 @@ -@echo off -:: Set some Vars to use -set buildFolder=..\Build -set bepinexFolder=..\Build\BepInEx -set bepinexPatchFolder=..\Build\BepInEx\Patchers -set bepinexPluginFolder=..\Build\BepInEx\Plugins -set bepinexSptFolder=..\Build\BepInEx\Plugins\spt -set eftDataFolder=..\Build\EscapeFromTarkov_Data -set managedFolder=..\Build\EscapeFromTarkov_Data\Managed -set projReleaseFolder=.\bin\Release\net471 -set licenseFile=..\..\LICENSE.md - -echo --------------- Cleaning Output Build Folder --------------- - -:: Delete build folder and contents to make sure its clean -if exist %buildFolder% rmdir /s /q %buildFolder% - -echo --------------- Done Cleaning Output Build Folder --------------- -echo --------------- Creating Output Build Folders --------------- - -:: Create build folder if it doesn't exist -if not exist %buildFolder% mkdir %buildFolder% -if not exist %bepinexFolder% mkdir %bepinexFolder% -if not exist %bepinexPatchFolder% mkdir %bepinexPatchFolder% -if not exist %bepinexPluginFolder% mkdir %bepinexPluginFolder% -if not exist %bepinexSptFolder% mkdir %bepinexSptFolder% -if not exist %eftDataFolder% mkdir %eftDataFolder% -if not exist %managedFolder% mkdir %managedFolder% - -echo --------------- Done Creating Output Build Folders --------------- - -echo --------------- Moving DLLs to %buildFolder% --------------- - -:: Move DLLs from each project's bin\Release folder to the build folder -xcopy "%projReleaseFolder%\Aki.Common.dll" %managedFolder% -xcopy "%projReleaseFolder%\Aki.Reflection.dll" %managedFolder% - -xcopy "%projReleaseFolder%\aki_PrePatch.dll" %bepinexPatchFolder% - -xcopy "%projReleaseFolder%\aki-core.dll" %bepinexSptFolder% -xcopy "%projReleaseFolder%\aki-custom.dll" %bepinexSptFolder% -xcopy "%projReleaseFolder%\aki-debugging.dll" %bepinexSptFolder% -xcopy "%projReleaseFolder%\aki-singleplayer.dll" %bepinexSptFolder% -:: If any new Dll's need to be copied, add here - -echo --------------- Done Moving DLLs to %buildFolder% --------------- -echo --------------- Writing License File --------------- - -:: write the contents of the license file to a txt -type %licenseFile% > "%buildFolder%\LICENSE-Modules.txt" - -echo --------------- Done Writing License File --------------- \ No newline at end of file diff --git a/project/build.ps1 b/project/build.ps1 new file mode 100644 index 0000000..6f08f82 --- /dev/null +++ b/project/build.ps1 @@ -0,0 +1,44 @@ +$buildFolder = "..\Build" +$bepinexFolder = "..\Build\BepInEx" +$bepinexPatchFolder = "..\Build\BepInEx\Patchers" +$bepinexPluginFolder = "..\Build\BepInEx\Plugins" +$bepinexSptFolder = "..\Build\BepInEx\Plugins\spt" +$eftDataFolder = "..\Build\EscapeFromTarkov_Data" +$managedFolder = "..\Build\EscapeFromTarkov_Data\Managed" +$projReleaseFolder = ".\bin\Release\net471" +$licenseFile = "..\..\LICENSE.md" + +Write-Host "--------------- Cleaning Output Build Folder ---------------" + +# Delete build folder and contents to make sure it's clean +if (Test-Path $buildFolder) { Remove-Item -Path $buildFolder -Recurse -Force } + +Write-Host "--------------- Done Cleaning Output Build Folder ---------------" +Write-Host "--------------- Creating Output Build Folders ---------------" + +# Create build folder and subfolders if they don't exist +$foldersToCreate = @($buildFolder, $bepinexFolder, $bepinexPatchFolder, $bepinexPluginFolder, $bepinexSptFolder, $eftDataFolder, $managedFolder) +foreach ($folder in $foldersToCreate) { + if (-not (Test-Path $folder)) { New-Item -Path $folder -ItemType Directory } +} + +Write-Host "--------------- Done Creating Output Build Folders ---------------" +Write-Host "--------------- Moving DLLs to $buildFolder ---------------" + +# Move DLLs from project's bin\Release folder to the build folder +Copy-Item "$projReleaseFolder\Aki.Common.dll" -Destination $managedFolder +Copy-Item "$projReleaseFolder\Aki.Reflection.dll" -Destination $managedFolder +Copy-Item "$projReleaseFolder\aki_PrePatch.dll" -Destination $bepinexPatchFolder +Copy-Item "$projReleaseFolder\aki-core.dll" -Destination $bepinexSptFolder +Copy-Item "$projReleaseFolder\aki-custom.dll" -Destination $bepinexSptFolder +Copy-Item "$projReleaseFolder\aki-debugging.dll" -Destination $bepinexSptFolder +Copy-Item "$projReleaseFolder\aki-singleplayer.dll" -Destination $bepinexSptFolder +# If any new DLLs need to be copied, add here + +Write-Host "--------------- Done Moving DLLs to $buildFolder ---------------" +Write-Host "--------------- Writing License File ---------------" + +# Write the contents of the license file to a txt +Get-Content $licenseFile | Out-File "$buildFolder\LICENSE-Modules.txt" + +Write-Host "--------------- Done Writing License File ---------------"