-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPostBuild.ps1
45 lines (35 loc) · 1.53 KB
/
PostBuild.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
[CmdletBinding()]
param (
[Parameter(Mandatory)][string]$Name,
[Parameter(Mandatory)][string]$Dll,
[Parameter(Mandatory)][string]$Game,
[string]$Config
)
# Set dist folder.
$dist = ".\dist"
$Version = (Get-ChildItem "$Dll").VersionInfo.FileVersion
# Clean dist folder.
Remove-Item "$dist\$Name" -Recurse
# Create final module folder in the `dist` directory.
Copy-Item ".\Module" -Destination "$dist\$Name" -Recurse -Exclude SubModule.xml, .gitkeep
# Copy the built assembly in place.
Copy-Item "$Dll" -Destination "$dist\$Name\bin\Win64_Shipping_Client"
# Evaluate macros and copy SubModule.xml.
(Get-Content ".\Module\SubModule.xml" -Raw) `
-Replace '\$\(Version\)', "$Version" `
-Replace '\$\(Name\)', "$Name" | Set-Content -Path "$dist\$Name\SubModule.xml"
# Install the module into the game directory.
Remove-Item "$Game\Modules\$Name" -Recurse
Copy-Item "$dist\$Name" -Destination "$Game\Modules" -Recurse
# Run the game with our module if we're debugging.
if ($Config -eq "Debug") {
Start-Process -FilePath "$Game\bin\Win64_Shipping_Client\Bannerlord.exe" -WorkingDirectory "$Game\bin\Win64_Shipping_Client" -ArgumentList "/singleplayer _MODULES_*Native*SandBoxCore*CustomBattle*SandBox*StoryMode*$Name*_MODULES_"
}
# Archive the final folder if we're releasing.
if ($Config -eq "Release") {
# Remove the archive if it already exists.
if (Test-Path "$dist\$Name-$Version.zip" -PathType Leaf) {
Remove-Item "$dist\$Name-$Version.zip"
}
Compress-Archive "$dist\$Name" "$dist\$Name-$Version.zip"
}