Add client files, see postbuild.config.xml to enable updating
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -339,4 +339,4 @@ tmp/
|
|||||||
index.js
|
index.js
|
||||||
|
|
||||||
# post build config
|
# post build config
|
||||||
ReallifeGamemode.Server/post_build_config.xml
|
postbuild.config.xml
|
||||||
@@ -42,6 +42,6 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' != 'ServerBuild' AND '$(OS)' == 'Windows_NT'">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' != 'ServerBuild' AND '$(OS)' == 'Windows_NT'">
|
||||||
<Exec Command="powershell -ExecutionPolicy ByPass -File .\post_build.ps1 -buildDirectory $(OutDir) -buildFilename $(TargetFileName)" />
|
<Exec Command="powershell -NonInteractive -ExecutionPolicy ByPass -File ..\postbuild.ps1 -buildDirectory $(OutDir) -buildFilename $(TargetFileName)" LogStandardErrorAsError="True" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
#
|
|
||||||
# @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 = "<?xml version=`"1.0`" encoding=`"UTF-8`"?>
|
|
||||||
<update>
|
|
||||||
<local>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
<rageMpServerPath>$defaultServerPath</rageMpServerPath>
|
|
||||||
<updateMetaXml>true</updateMetaXml>
|
|
||||||
<updateAllDependencies>true</updateAllDependencies>
|
|
||||||
</local>
|
|
||||||
<remote>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
<ftpServerAddress>127.0.0.1</ftpServerAddress>
|
|
||||||
<ftpServerPort>21</ftpServerPort>
|
|
||||||
<ftpServerUsername>USERNAME</ftpServerUsername>
|
|
||||||
<ftpServerPassword>PASSWORD</ftpServerPassword>
|
|
||||||
<rageMpServerPath>.</rageMpServerPath>
|
|
||||||
<updateMetaXml>false</updateMetaXml>
|
|
||||||
<updateAllDependencies>false</updateAllDependencies>
|
|
||||||
</remote>
|
|
||||||
</update>"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
@@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
.gitlab-ci.yml = .gitlab-ci.yml
|
.gitlab-ci.yml = .gitlab-ci.yml
|
||||||
readme.md = readme.md
|
readme.md = readme.md
|
||||||
|
postbuild.ps1 = postbuild.ps1
|
||||||
|
postbuild.config.xml = postbuild.config.xml
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
183
postbuild.ps1
Normal file
183
postbuild.ps1
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
#
|
||||||
|
# @author Codename
|
||||||
|
# @copyright (c) 2008 - 2019 Life of German
|
||||||
|
# @warning Start this script only once, after building server dll
|
||||||
|
# @description This powershell script copies necessary files to (local/remote) server dir for windows developers
|
||||||
|
#
|
||||||
|
|
||||||
|
# set parameters
|
||||||
|
param (
|
||||||
|
[string]$buildDirectory,
|
||||||
|
[string]$buildFilename
|
||||||
|
)
|
||||||
|
|
||||||
|
# set constant path
|
||||||
|
Set-Variable configPath -option Constant -value "$PSScriptRoot\postbuild.config.xml"
|
||||||
|
Set-Variable serverProjectPath -option Constant -value "$PSScriptRoot\ReallifeGamemode.Server"
|
||||||
|
Set-Variable clientProjectPath -option Constant -value "$PSScriptRoot\ReallifeGamemode.Client"
|
||||||
|
Set-Variable sourceAssetsPath -option Constant -value "$PSScriptRoot\ReallifeGamemode.Client\assets"
|
||||||
|
Set-Variable sourceIndexJsPath -option Constant -value "$PSScriptRoot\ReallifeGamemode.Client\index.js"
|
||||||
|
Set-Variable sourceDlcPacksPath -option Constant -value "$PSScriptRoot\ReallifeGamemode.Client\dlcpacks"
|
||||||
|
|
||||||
|
# set constant dirs
|
||||||
|
Set-Variable runtimeDir -option Constant -value "bridge\runtime"
|
||||||
|
Set-Variable resourcesDir -option Constant -value "bridge\resources"
|
||||||
|
Set-Variable gamemodeDir -option Constant -value "reallife-gamemode"
|
||||||
|
Set-Variable assetsDir -option Constant -value "client_packages\assets"
|
||||||
|
Set-Variable indexJsDir -option Constant -value "client_packages"
|
||||||
|
Set-Variable dlcPacksDir -option Constant -value "source_dlcpacks"
|
||||||
|
Set-Variable fullBuildDir -option Constant -value "$serverProjectPath\$buildDirectory"
|
||||||
|
|
||||||
|
# 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 = "<?xml version=`"1.0`" encoding=`"UTF-8`"?>
|
||||||
|
<config>
|
||||||
|
<local>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<rageMpServerPath>$defaultServerPath</rageMpServerPath>
|
||||||
|
<update>
|
||||||
|
<server>
|
||||||
|
<metaXml>true</metaXml>
|
||||||
|
<allDependencies>true</allDependencies>
|
||||||
|
</server>
|
||||||
|
<client>
|
||||||
|
<assets>false</assets>
|
||||||
|
<indexJs>false</indexJs>
|
||||||
|
<dlcPacks>false</dlcPacks>
|
||||||
|
</client>
|
||||||
|
</update>
|
||||||
|
</local>
|
||||||
|
<remote>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
<ftpServerAddress>127.0.0.1</ftpServerAddress>
|
||||||
|
<ftpServerPort>21</ftpServerPort>
|
||||||
|
<ftpServerUsername>USERNAME</ftpServerUsername>
|
||||||
|
<ftpServerPassword>PASSWORD</ftpServerPassword>
|
||||||
|
<rageMpServerPath>.</rageMpServerPath>
|
||||||
|
<update>
|
||||||
|
<server>
|
||||||
|
<metaXml>false</metaXml>
|
||||||
|
<allDependencies>false</allDependencies>
|
||||||
|
</server>
|
||||||
|
<client>
|
||||||
|
<assets>false</assets>
|
||||||
|
<indexJs>false</indexJs>
|
||||||
|
<dlcPacks>false</dlcPacks>
|
||||||
|
</client>
|
||||||
|
</update>
|
||||||
|
</remote>
|
||||||
|
</config>"
|
||||||
|
|
||||||
|
# create default content
|
||||||
|
New-Item $configPath
|
||||||
|
Set-Content $configPath $defaultXmlContent
|
||||||
|
}
|
||||||
|
|
||||||
|
# load existing xml config file
|
||||||
|
[xml]$xmlConfig = Get-Content -Path $configPath
|
||||||
|
if (!$xmlConfig) {
|
||||||
|
throw "opening XML config file failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
# first compile typescript files if enabled in config file
|
||||||
|
if (($xmlConfig.config.local.update.client.indexJs -eq "true" -and $xmlConfig.config.local.enabled -eq "true") -or
|
||||||
|
($xmlConfig.config.remote.update.client.indexJs -eq "true" -and $xmlConfig.config.remote.enabled -eq "true")) {
|
||||||
|
$path = $PSScriptRoot
|
||||||
|
Set-Location -Path $clientProjectPath
|
||||||
|
npx webpack --config webpack.config.build.js
|
||||||
|
Set-Location -Path $path
|
||||||
|
}
|
||||||
|
|
||||||
|
# update local files if enabled in config file
|
||||||
|
if ($xmlConfig.config.local.enabled -eq "true") {
|
||||||
|
# get local server path from xml config file
|
||||||
|
Set-Variable serverPath -option Constant -value $xmlConfig.config.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 resources path exists
|
||||||
|
Set-Variable resourcesPath -option Constant -value "$serverPath\$resourcesDir"
|
||||||
|
if (!(Test-Path $resourcesPath)) {
|
||||||
|
Write-Error "local resources path ($resourcesPath) 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 gamemodePath -option Constant -value "$resourcesPath\$gamemodeDir"
|
||||||
|
if (!(Test-Path $gamemodePath)) {
|
||||||
|
New-Item -ItemType Directory -Force -Path $gamemodePath
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy compiled gamemode to local gamemode path
|
||||||
|
Copy-Item "$fullBuildDir\$buildFilename" $gamemodePath -Force
|
||||||
|
|
||||||
|
# copy meta.xml to local gamemode path if 'local.update.server.metaXml' is set to 'true' in config file
|
||||||
|
if ($xmlConfig.config.local.update.server.metaXml -eq "true") {
|
||||||
|
Copy-Item "$fullBuildDir\meta.xml" $gamemodePath -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy dependencies to local runtime path if 'local.update.server.allDependencies' is set to 'true' in config file
|
||||||
|
if ($xmlConfig.config.local.update.server.allDependencies -eq "true") {
|
||||||
|
# check if local runtime path exists
|
||||||
|
Set-Variable runtimePath -option Constant -value "$serverPath\$runtimeDir"
|
||||||
|
if (!(Test-Path $runtimePath)) {
|
||||||
|
Write-Error "local runtime path ($runtimePath) 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-Item "$fullBuildDir\*.dll" $runtimePath -Exclude "*$buildFilename*" -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy assets to local client packages path if 'local.update.client.assets' is set to 'true' in config file
|
||||||
|
if ($xmlConfig.config.local.update.client.assets -eq "true") {
|
||||||
|
# create local assets path if not exist
|
||||||
|
Set-Variable assetsPath -option Constant -value "$serverPath\$assetsDir"
|
||||||
|
if (!(Test-Path $assetsPath)) {
|
||||||
|
New-Item -ItemType Directory -Force -Path $assetsPath
|
||||||
|
}
|
||||||
|
robocopy $sourceAssetsPath $assetsPath /MIR
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy index.js to local client packages path if 'local.update.client.indexJs' is set to 'true' in config file
|
||||||
|
if ($xmlConfig.config.local.update.client.indexJs -eq "true") {
|
||||||
|
# create local client packages if not exist
|
||||||
|
Set-Variable indexJsPath -option Constant -value "$serverPath\$indexJsDir"
|
||||||
|
if (!(Test-Path $indexJsPath)) {
|
||||||
|
New-Item -ItemType Directory -Force -Path $indexJsPath
|
||||||
|
}
|
||||||
|
Copy-Item $sourceIndexJsPath $indexJsPath -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# copy dlc packs to local dlc packs path if 'local.update.client.dlcPacks' is set to 'true' in config file
|
||||||
|
if ($xmlConfig.config.local.update.client.dlcPacks -eq "true") {
|
||||||
|
# create local dlc packs path if not exist
|
||||||
|
Set-Variable dlcPacksPath -option Constant -value "$serverPath\$dlcPacksDir"
|
||||||
|
if (!(Test-Path $dlcPacksPath)) {
|
||||||
|
New-Item -ItemType Directory -Force -Path $dlcPacksPath
|
||||||
|
}
|
||||||
|
robocopy $sourceDlcPacksPath $dlcPacksPath /MIR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# update remote files if enabled in config file
|
||||||
|
if ($xmlConfig.config.remote.enabled -eq "true") {
|
||||||
|
# TODO: connect to remote ftp server and update files
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user