0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-12 17:10:44 -05:00

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 <brownelltyler@gmail.com>
Reviewed-on: SPT-AKI/Launcher#41
Co-authored-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
Co-committed-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
This commit is contained in:
Refringe 2024-03-05 08:33:31 +00:00 committed by chomp
parent fb661d46de
commit 82d401bc43
4 changed files with 29 additions and 44 deletions

View File

@ -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

View File

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="dotnet publish ..\Aki.Launcher\Aki.Launcher.csproj -c Release -f net6.0 -r win-x64 /p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true --self-contained false"/>
<Exec Command="../build.bat" WorkingDirectory="$(ProjectDir)" />
<Exec Command="dotnet publish ..\Aki.Launcher\Aki.Launcher.csproj -c Release -f net6.0 -r win-x64 /p:IncludeNativeLibrariesForSelfExtract=true -p:PublishSingleFile=true --self-contained false"/>
<Exec Command="pwsh -NoProfile -ExecutionPolicy Bypass ../build.ps1" WorkingDirectory="$(ProjectDir)" />
</Target>
</Project>

View File

@ -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 ---------------

22
project/build.ps1 Normal file
View File

@ -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"