-
Notifications
You must be signed in to change notification settings - Fork 5
/
clean.ps1
52 lines (41 loc) · 1.79 KB
/
clean.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
Param(
[string] $modName, # mod folder name
[string] $srcDirectory, # the path that contains your mod's .XCOM_sln
[string] $sdkPath, # the path to your SDK installation ending in "XCOM 2 War of the Chosen SDK"
[string] $gamePath # the path to your XCOM 2 installation ending in "XCOM2-WaroftheChosen"
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3.0
$scriptDirectory = Split-Path $MyInvocation.MyCommand.Path
$cleanCookerOutput = Join-Path -Path $scriptDirectory "clean_cooker_output.ps1"
Write-Host "Sourcing $cleanCookerOutput"
. $cleanCookerOutput
if ($null -eq $modName -or $modName -eq "") {
throw "`$modName empty???"
}
Write-Host "Deleting all cached build artifacts..."
# This needs to be before $srcDirectory\BuildCache is deleted - otherwise we will miss our collection maps
# This is dumb, yes, but to fix this we need to rework how BuildProject is used from build.ps1 (and here)
CleanModAssetCookerOutput $sdkPath $modName @("$srcDirectory\$modName\ContentForCook", "$srcDirectory\BuildCache\CollectionMaps")
$files = @(
"$sdkPath\XComGame\lastBuildDetails.json",
"$sdkPath\XComGame\Script\*.u",
"$sdkPath\XComGame\ScriptFinalRelease\*.u",
"$sdkPath\XComGame\Content\LocalShaderCache-PC-D3D-SM4.upk"
)
$folders = @(
"$srcDirectory\BuildCache",
"$sdkPath\Development\Src\*",
"$sdkPath\XComGame\Mods\*",
"$gamePath\XComGame\Mods\$modName"
)
$files | ForEach-Object {
Write-Host "Removing file(s) $($_)"
Remove-Item -Force $_ -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
$folders | ForEach-Object {
Write-Host "Removing folders(s) $($_)"
Remove-Item -Recurse -Force $_ -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
TryCleanHlCookerOutput $sdkPath "$srcDirectory\$modName\Src"
Write-Host "Cleaned."