<# .SYNOPSIS Archive les preuves d'une session debug (journal, CSV, LLM, utrace, MemReport, CVD). .EXAMPLE .\Tools\CollectDebugArtifacts.ps1 -Lot Dbg-I4 -BuildDir D:\Game\LifePlay_Build_5.5_DebugGame -Session A #> param( [Parameter(Mandatory)][string]$Lot, [Parameter(Mandatory)][string]$BuildDir, [Parameter(Mandatory)][ValidateSet('A', 'B', 'C', 'bugs', 'gpu', 'collision')][string]$Session, [string]$BackupRoot = 'D:\Game\LifePlay_Backup_5.5' ) $ErrorActionPreference = 'Stop' function Resolve-SavedDir([string]$Root) { foreach ($rel in @( 'Windows\LifePlay\Saved', 'WindowsNoEditor\LifePlay\Saved', 'LifePlay\Saved', 'Saved')) { $p = Join-Path $Root $rel if (Test-Path $p) { return $p } } return $null } $saved = Resolve-SavedDir $BuildDir if (-not $saved) { Write-Error "Saved introuvable sous $BuildDir" } $dest = Join-Path $BackupRoot "$Lot\Session$Session" New-Item -ItemType Directory -Force $dest | Out-Null $copied = New-Object System.Collections.Generic.List[string] function Copy-Match([string]$RelativeDir, [string]$Filter) { $from = Join-Path $saved $RelativeDir if (-not (Test-Path $from)) { return } $target = Join-Path $dest $RelativeDir New-Item -ItemType Directory -Force $target | Out-Null Get-ChildItem $from -Filter $Filter -File -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item $_.FullName (Join-Path $target $_.Name) -Force $script:copied.Add((Join-Path $RelativeDir $_.Name)) } } Copy-Match 'Logs' '*.log' Copy-Match 'Profiling' '*.utrace' Copy-Match 'Profiling\CSV' '*.csv' Copy-Match 'Profiling\LLM' '*.csv' Copy-Match 'Profiling\LPDebug' '*.txt' $reportRoot = Join-Path $saved 'Profiling\MemReports' if (Test-Path $reportRoot) { Get-ChildItem $reportRoot -Recurse -Filter '*.memreport' -File | ForEach-Object { $rel = $_.FullName.Substring($saved.Length).TrimStart('\') $target = Join-Path $dest $rel New-Item -ItemType Directory -Force (Split-Path $target -Parent) | Out-Null Copy-Item $_.FullName $target -Force $copied.Add($rel) } } foreach ($dirName in @('ChaosVisualDebugger', 'ChaosVD')) { $from = Join-Path $saved $dirName if (Test-Path $from) { $target = Join-Path $dest $dirName Copy-Item $from $target -Recurse -Force $copied.Add($dirName) } } Get-ChildItem $saved -Recurse -Include '*.utrace', '*.cvd' -File -ErrorAction SilentlyContinue | ForEach-Object { $rel = $_.FullName.Substring($saved.Length).TrimStart('\') if ($copied -contains $rel) { return } $target = Join-Path $dest $rel New-Item -ItemType Directory -Force (Split-Path $target -Parent) | Out-Null Copy-Item $_.FullName $target -Force $copied.Add($rel) } $manifest = Join-Path $dest 'manifest.txt' @( "Lot=$Lot" "Session=$Session" "BuildDir=$BuildDir" "Saved=$saved" "Date=$(Get-Date -Format s)" "Files=$($copied.Count)" '' $copied ) | Set-Content $manifest -Encoding UTF8 Write-Host "dest=$dest fichiers=$($copied.Count)" if ($copied.Count -lt 1) { Write-Error "Aucun artefact copie depuis $saved" } exit 0