# # @description This powershell script for windows developer copies compiled files to (local/remote) server dir # @author Codename # @copyright (c) 2008 - 2019 Life of German # # set parameters param ( [string]$buildDirectory, [string]$buildFilename ) # set config path Set-Variable configPath -option Constant -value "$PSScriptRoot\post_build_config.xml" # set constant dirs Set-Variable serverRuntimeDir -option Constant -value "bridge\runtime" Set-Variable serverResourcesDir -option Constant -value "bridge\resources" Set-Variable serverGamemodeDir -option Constant -value "reallife-gamemode" # create default config file if not exist if (![System.IO.File]::Exists($configPath)) { # resolve default server path (default: .\..\..) $defaultServerPath = (Resolve-Path -Path "$PSScriptRoot\..\..") if (!$defaultServerPath) { Write-Error "resolving local server path failed" exit 1 } $defaultXmlContent = " true $defaultServerPath true true false 127.0.0.1 21 USERNAME PASSWORD . false false " # create default content New-Item $configPath Set-Content $configPath $defaultXmlContent } # load existing xml config file [xml]$xmlConfig = Get-Content -Path $configPath if (!$xmlConfig) { Write-Error "opening XML config file failed" exit 1 } # update local files if enabled in config file if ($xmlConfig.update.local.enabled -eq "true") { # get local server path from xml config file Set-Variable serverPath -option Constant -value $xmlConfig.update.local.rageMpServerPath if (!$serverPath) { Write-Error "empty local rage mp server path in config file" exit 1 } # check if local server path exists if (!(Test-Path $serverPath)) { Write-Error "local rage mp server path ($serverPath) not found. Have you moved your local rage mp directory?" exit 1 } # check if local server resources path exists Set-Variable serverResourcesPath -option Constant -value "$serverPath\$serverResourcesDir" if (!(Test-Path $serverResourcesPath)) { Write-Error "local server resources path ($serverResourcesPath) not found. Please set up C# Bridge locally first, see https://wiki.gtanet.work/index.php?title=Setting_up_the_Bridge_on_Linux/Windows" exit 1 } # create local gamemode dir if not exist Set-Variable serverGamemodePath -option Constant -value "$serverResourcesPath\$serverGamemodeDir" if (!(Test-Path $serverGamemodePath)) { New-Item -ItemType Directory -Force -Path $serverGamemodePath } # copy compiled gamemode to local server gamemode path Copy-Item "$buildDirectory\$buildFilename" $serverGamemodePath -Force # copy meta.xml to local server gamemode path if 'updateMetaXml' is set to 'true' in config file if ($xmlConfig.update.local.updateMetaXml -eq "true") { Copy-Item "$buildDirectory\meta.xml" $serverGamemodePath -Force } # check if local server runtime path exists Set-Variable serverRuntimePath -option Constant -value "$serverPath\$serverRuntimeDir" if (!(Test-Path $serverRuntimePath)) { Write-Error "local server runtime path ($serverRuntimePath) not found. Please set up C# Bridge locally first, see https://wiki.gtanet.work/index.php?title=Setting_up_the_Bridge_on_Linux/Windows" exit 1 } # copy dependencies to local server runtime path if 'updateAllDependencies' is set to 'true' in config file if ($xmlConfig.update.local.updateAllDependencies -eq "true") { Copy-Item "$buildDirectory\*.dll" $serverRuntimePath -Exclude "*$buildFilename*" -Force } } # update remote files if enabled in config file if ($xmlConfig.update.remote.enabled -eq "true") { # TODO: connect to remote ftp server and update files } exit 0