forked from blendermf/XLShredLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_build.ps1
51 lines (43 loc) · 2.33 KB
/
post_build.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
param(
[String]$TargetName = $(throw "-TargetName is required."),
[String]$TargetPath = $(throw "-TargetPath is required."),
[String]$TargetDir = $(throw "-TargetDir is required."),
[String]$ProjectDir = $(throw "-ProjectDir is required."),
[String]$SolutionDir = $(throw "-SolutionDir is required."),
[String]$ConfigurationName = $(throw "-ConfigurationName is required."),
[String]$LibNames,
[Switch]$LoadLib #Deprecated: Use above more generic parameter with argument "XLShredLib"
)
$configContent = Get-Content ([io.path]::combine($SolutionDir, "config.json")) | ConvertFrom-Json;
$infoContent = Get-Content ([io.path]::combine($ProjectDir, 'Resources\Info.json')) | ConvertFrom-Json;
$gameDirectory = $configContent.game_directory;
$targetModName = $infoContent.Id;
$modTargetDir = [io.path]::combine( $gameDirectory, "Mods\", $targetModName);
$modTargetDirTmpParent = $modTargetDir + 'Tmp'
$modTargetDirTmp = $modTargetDirTmpParent + '\' + $targetModName;
Get-ChildItem $modTargetDir -Recurse -Exclude 'Settings.xml', 'CustomObjects', 'mainmenu' | Remove-Item;
New-Item -ItemType directory -Path $modTargetDir -Force;
copy-item $TargetPath $modTargetDir -force;
if ($ConfigurationName -eq "Debug") {
copy-item ([io.path]::combine( $TargetDir, $TargetName + ".pdb" )) $modTargetDir -force;
}
copy-item ([io.path]::combine( $ProjectDir, "Resources\Info.json" )) $modTargetDir -force;
$libNamesArray = $libNames -split ',';
foreach ($libName in $libNamesArray) {
copy-item ([io.path]::combine( $TargetDir, $libName + ".dll" )) $modTargetDir -force;
if ($ConfigurationName -eq "Debug") {
copy-item ([io.path]::combine( $TargetDir, $libName + ".pdb" )) $modTargetDir -force;
}
}
#Deprecated; will be deleted at some point
If ($LoadLib) {
copy-item ([io.path]::combine( $TargetDir, "XLShredLib.dll" )) $modTargetDir -force;
if ($ConfigurationName -eq "Debug") {
copy-item ([io.path]::combine( $TargetDir, "XLShredLib.pdb" )) $modTargetDir -force;
}
}
if ($ConfigurationName -eq "Release") {
copy-item -Recurse -Force $modTargetDir $modTargetDirTmp -Exclude Settings.xml;
Compress-Archive -Force -Path $modTargetDirTmp -DestinationPath ([io.path]::combine($gameDirectory, "Mods\" + $TargetName + '-' + $infoContent.version + '.zip' ));
Remove-Item -Recurse -Force $modTargetDirTmpParent;
}