$sourcePath = "."; $outputPath = "$sourcePath\ProjectDump.txt"; $excludeDirs = @(".git", ".vs", "bin", "obj", "packages", "TestResults"); $excludeExts = @(".dll", ".exe", ".pdb", ".zip", ".png", ".jpg", ".jpeg", ".ico", ".suo", ".user", ".cache", ".slnx"); Function Get-ProjectTree { param([string]$path, [string]$indent = "") $output = ""; $allItems = Get-ChildItem -Path $path -ErrorAction SilentlyContinue; $items = @(); for ($i = 0; $i -lt $allItems.Count; $i++) {$item = $allItems[$i]; $isDir =$item.PSIsContainer; $skipItem =$false; if ($isDir -and ($excludeDirs -contains $item.Name)) { $skipItem =$true; } if (-not $isDir -and ($excludeExts -contains $item.Extension)) { $skipItem =$true; } if (-not $skipItem) { $items +=$item; } } $count =$items.Count; for ($j = 0; $j -lt $count; $j++) { $item =$items[$j];$isLast = (($j + 1) -eq$count); $marker = if ($isLast) { "└── " } else { "├── " }; $output += "${indent}${marker}$($item.Name)`r`n"; if ($item.PSIsContainer) { $newIndent = if ($isLast) { $indent + " " } else { $indent + "│ " }; $output += Get-ProjectTree -path $item.FullName -indent$newIndent; } } return $output; } $rootPath = (Resolve-Path $sourcePath).Path; Set-Content -Path $outputPath -Value "=== ДЕРЕВО КАТАЛОГОВ ПРОЕКТА ===" -Encoding UTF8; $rootName = (Get-Item $rootPath).Name; Add-Content -Path $outputPath -Value $rootName -Encoding UTF8; $tree = Get-ProjectTree -path $rootPath; Add-Content -Path $outputPath -Value $tree -Encoding UTF8; Add-Content -Path $outputPath -Value "" -Encoding UTF8; Add-Content -Path $outputPath -Value "=== ЛИСТИНГИ КОДА ===" -Encoding UTF8; $allFiles = Get-ChildItem -Path $rootPath -Recurse -File -ErrorAction SilentlyContinue; $files = @(); for ($f = 0; $f -lt $allFiles.Count; $f++) {$file = $allFiles[$f]; if ($excludeExts -notcontains $file.Extension) { $files +=$file; } } for ($k = 0; $k -lt $files.Count; $k++) {$file = $files[$k]; $skip =$false; for ($d = 0; $d -lt $excludeDirs.Count; $d++) {$dir = $excludeDirs[$d]; $dirPattern = "[\\/]$dir[\\/]"; $checkPath = "\" + $file.FullName.Substring($rootPath.Length).Trim('\','/') + "\"; if ($checkPath -match $dirPattern) { $skip =$true; break; } } if ($skip) { continue; } $relPath = $file.FullName.Substring($rootPath.Length).TrimStart('\', '/'); Add-Content -Path $outputPath -Value "" -Encoding UTF8; Add-Content -Path $outputPath -Value ("=" * 80) -Encoding UTF8; Add-Content -Path $outputPath -Value "Файл: $($file.Name)" -Encoding UTF8; Add-Content -Path $outputPath -Value "Относительный путь: $relPath" -Encoding UTF8; Add-Content -Path $outputPath -Value ("=" * 80) -Encoding UTF8; try { $content = Get-Content -Path $file.FullName -Encoding UTF8 -Raw -ErrorAction Stop; if ($null -ne $content) { Add-Content -Path $outputPath -Value $content -Encoding UTF8; } } catch { Add-Content -Path $outputPath -Value "[Пропущен: бинарный или нечитаемый файл]" -Encoding UTF8; } } Write-Host "Готово! Дамп сохранен в $outputPath";