From 82d401bc438d10b4258d2ec3c7d2306eaf6b3d8d Mon Sep 17 00:00:00 2001 From: Refringe Date: Tue, 5 Mar 2024 08:33:31 +0000 Subject: [PATCH] Converts Build Script to PowerShell (!41) 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 help us 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: Tyler Brownell Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Launcher/pulls/41 Co-authored-by: Refringe Co-committed-by: Refringe --- README.md | 1 + project/Aki.Build/Aki.Build.csproj | 12 +++++----- project/build.bat | 38 ------------------------------ project/build.ps1 | 22 +++++++++++++++++ 4 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 project/build.bat create mode 100644 project/build.ps1 diff --git a/README.md b/README.md index 6a73b54..a0df28a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ git config --local user.email "USERNAME@SOMETHING.com" - Escape From Tarkov 28476 - .NET 6 SDK - Visual Studio Code +- [PowerShell v7](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows) ### For UI Development diff --git a/project/Aki.Build/Aki.Build.csproj b/project/Aki.Build/Aki.Build.csproj index f9c6177..90bb40f 100644 --- a/project/Aki.Build/Aki.Build.csproj +++ b/project/Aki.Build/Aki.Build.csproj @@ -1,13 +1,13 @@  - - net6.0 - win-x64 - + + net6.0 + win-x64 + - - + + diff --git a/project/build.bat b/project/build.bat deleted file mode 100644 index f08f3c2..0000000 --- a/project/build.bat +++ /dev/null @@ -1,38 +0,0 @@ -@echo off -:: Set some Vars to use -set buildFolder=..\Build -set akiDataFolder=..\Build\Aki_Data -set projReleaseFolder=.\bin\Release\net6.0\win-x64 -set launcherExeFolder=..\Aki.Launcher\bin\Release\net6.0\win-x64\publish -set launcherAssetFolder=..\Aki.Launcher\Aki_Data -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 %akiDataFolder% mkdir %akiDataFolder% - -echo --------------- Done Creating Output Build Folders --------------- - -echo --------------- Moving DLLs to %buildFolder% --------------- - -:: Move DLLs/exe/json project's bin\Release folder to the build folder -xcopy "%launcherExeFolder%\Aki.Launcher.exe" %buildFolder% -xcopy "%launcherAssetFolder%" "%buildFolder%\Aki_Data" /s /e - -:: 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-Launcher.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..83d465c --- /dev/null +++ b/project/build.ps1 @@ -0,0 +1,22 @@ +$buildFolder = "..\Build" +$akiDataFolder = "..\Build\Aki_Data" +$launcherExeFolder = "..\Aki.Launcher\bin\Release\net6.0\win-x64\publish" +$launcherAssetFolder = "..\Aki.Launcher\Aki_Data" +$licenseFile = "..\..\LICENSE.md" + +# Delete build folder and contents to ensure it's clean +if (Test-Path $buildFolder) { Remove-Item -Path $buildFolder -Recurse -Force } + +# Create build folder and subfolders +$foldersToCreate = @($buildFolder, $akiDataFolder) +foreach ($folder in $foldersToCreate) { + if (-not (Test-Path $folder)) { New-Item -Path $folder -ItemType Directory } +} + +# Move built files to the build folder +Copy-Item -Path "$launcherExeFolder\Aki.Launcher.exe" -Destination $buildFolder +Copy-Item -Path $launcherAssetFolder -Destination "$buildFolder\Aki_Data" -Recurse +# (If any new DLLs need to be copied, add here) + +# Write the contents of the license file to a txt in the build folder. +Get-Content $licenseFile | Out-File "$buildFolder\LICENSE-Launcher.txt"