forked from Bannerlord-Coop-Team/BannerlordCoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ps1
60 lines (47 loc) · 2.02 KB
/
deploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# arguments
param([string]$SolutionDir,
[string]$TargetDir,
[string[]] $Libs);
$Libs = $Libs -split ','
Write-Output "*** deploy.ps1 ***"
Write-Output "SolutionDir: ${SolutionDir}"
Write-Output "TargetDir: ${TargetDir}"
Write-Output "3rdPartyLibs: ${Libs}"
# path to required files
$BaseDir = "${SolutionDir}..\"
$DeployDir = "${BaseDir}deploy\"
$ConfigPath = "${BaseDir}config.json"
$TemplateDir = "${BaseDir}template"
$UIMovieDir = "${BaseDir}UIMovies"
# create output directory structure
$DeployBinDir = "$DeployDir\bin\Win64_Shipping_Client"
Remove-Item ${DeployBinDir} -Recurse -ErrorAction Ignore
New-Item -ItemType Directory -Force -Path $DeployDir | Out-Null
New-Item -ItemType Directory -Force -Path $DeployBinDir | Out-Null
# read config
$config = Get-Content -Raw -Path $ConfigPath | ConvertFrom-Json
Write-Output $config
# write SubModule.xml
$subModuleContent = Get-Content -path $TemplateDir\SubModule.xml -Raw
$subModuleContent = $subModuleContent.replace('${name}', $config.name)
$subModuleContent = $subModuleContent.replace('${version}', $config.version)
$subModuleContent = $subModuleContent.replace('${game_version}', $config.game_version)
$subModuleContent | Out-File -Encoding utf8 -FilePath $DeployDir\SubModule.xml
# copy mod dll
$filesToCopy = ${Libs}
foreach ($file in $filesToCopy)
{
Copy-item -Force ${TargetDir}${file} -Destination $DeployBinDir
}
# copy to games mod folder
if(Test-Path (${BaseDir} + $config.modsDir))
{
$ModDir = ${BaseDir} + $config.modsDir + "\" + $config.name
Remove-Item ${ModDir} -Recurse -ErrorAction Ignore
New-Item -Force -ItemType Directory -Path ${ModDir} | Out-Null
Copy-item -Force -Recurse $DeployDir\* -Destination $ModDir\
}
# write Movie Prefabs
$MovieModDir = ${BaseDir} + $config.modsDir + "\" + $config.name + "\GUI\Prefabs"
New-Item -Force -ItemType Directory -Path ${MovieModDir} | Out-Null
Copy-Item -Force ${UIMovieDir}\* -Recurse -Destination ${MovieModDir}\