There's a large try / finally block that cleans up the SDK from its temporarily invalid state from cooking. I/O errors during cleanup are reported in the middle of the log and then ignored because we need to clean up as much as possible, even when one individual cleanup step fails.
|
finally { |
|
Write-Host "Cleaning up the asset cooking hacks" |
|
|
|
# Revert ini |
|
try { |
|
$sdkEngineContentOriginal | Set-Content $sdkEnginePath -NoNewline |
|
Write-Host "Reverted $sdkEnginePath" |
|
} |
|
catch { |
|
FailureMessage "Failed to revert $sdkEnginePath" |
|
FailureMessage $_ |
|
} |
|
|
|
# Revert junctions |
|
|
|
try { |
|
Remove-Junction $cookOutputDir |
|
Write-Host "Removed $cookOutputDir junction" |
|
} |
|
catch { |
|
FailureMessage "Failed to remove $cookOutputDir junction" |
|
FailureMessage $_ |
|
} |
|
|
|
if ($sfStandaloneNames.Length -gt 0) { |
|
try { |
|
Remove-Junction $sdkContentModsOurStandaloneDir |
|
Write-Host "Removed $sdkContentModsOurStandaloneDir junction" |
|
} |
|
catch { |
|
FailureMessage "Failed to remove $sdkContentModsOurStandaloneDir junction" |
|
FailureMessage $_ |
|
} |
|
|
|
try { |
|
Remove-Item $sdkContentModsOurGuardDir -Recurse |
|
Write-Host "Removed $sdkContentModsOurGuardDir folder" |
|
} |
|
catch { |
|
FailureMessage "Failed to remove $sdkContentModsOurGuardDir folder" |
|
FailureMessage $_ |
|
} |
|
|
|
try { |
|
# Important: not recursive! |
|
# If we failed to undo the Standalone junction above, we will nuke the original |
|
# packages in the mod project if this is a recursive removal |
|
Remove-Item $sdkContentModsOurDir |
|
Write-Host "Removed $sdkContentModsOurDir folder" |
|
} |
|
catch { |
|
FailureMessage "Failed to remove $sdkContentModsOurDir folder" |
|
FailureMessage $_ |
|
} |
|
} |
|
|
|
# Restore the HL cook folder |
|
if (![string]::IsNullOrEmpty($previousCookOutputDirPath)) |
|
{ |
|
try { |
|
if (Test-Path $cookOutputDir) { |
|
ThrowFailure "$cookOutputDir still exists, cannot restore previous" |
|
} |
|
|
|
Rename-Item $previousCookOutputDirPath "CookedPCConsole" |
|
Write-Host "Restored previous $cookOutputDir" |
|
} |
|
catch { |
|
FailureMessage "Failed to restore previous $cookOutputDir" |
|
FailureMessage $_ |
|
} |
|
} |
|
} |
However, the SDK is still in a potentially invalid state. This should be reported at the end of the build and the build should fail so that users can investigate.
There's a large try / finally block that cleans up the SDK from its temporarily invalid state from cooking. I/O errors during cleanup are reported in the middle of the log and then ignored because we need to clean up as much as possible, even when one individual cleanup step fails.
X2ModBuildCommon/build_common.ps1
Lines 849 to 921 in 3fef85d
However, the SDK is still in a potentially invalid state. This should be reported at the end of the build and the build should fail so that users can investigate.