-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport.Project.To.File.ps1
More file actions
52 lines (38 loc) · 2.12 KB
/
Copy pathExport.Project.To.File.ps1
File metadata and controls
52 lines (38 loc) · 2.12 KB
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
# Export-Project.ps1
# Run this in your project root directory
$outputFile = ".\BedrockServerManager_FullSource.txt"
$extensions = @("*.cs", "*.xaml", "*.csproj", "*.manifest")
$excludeDirs = @("bin", "obj", ".vs")
Write-Host "Starting project export..." -ForegroundColor Cyan
Write-Host "Scanning directory: $(Get-Location)" -ForegroundColor DarkGray
Write-Host "Looking for extensions: $($extensions -join ', ')" -ForegroundColor DarkGray
Write-Host "Excluding directories: $($excludeDirs -join ', ')" -ForegroundColor DarkGray
Write-Host "---------------------------------------------------------"
if (Test-Path $outputFile) {
Write-Host "Removing old output file..." -ForegroundColor Yellow
Remove-Item $outputFile -Force
}
Write-Host "Searching for files..." -ForegroundColor Cyan
# Build a regex pattern to match any excluded directory anywhere in the full path
$excludePattern = '\\(' + (($excludeDirs | ForEach-Object { [regex]::Escape($_) }) -join '|') + ')\\'
$files = Get-ChildItem -Recurse -Include $extensions | Where-Object {
$_.FullName -notmatch $excludePattern
} | Sort-Object FullName
Write-Host "Found $($files.Count) files to process." -ForegroundColor Green
Write-Host "---------------------------------------------------------"
$delimiter = "========================================================="
foreach ($file in $files) {
# Calculate path relative to the current directory
$relativePath = $file.FullName.Replace((Get-Location).Path + "\", "")
Write-Host " -> Processing: $relativePath" -ForegroundColor White
Add-Content -Path $outputFile -Value $delimiter
Add-Content -Path $outputFile -Value "FILE: $relativePath"
Add-Content -Path $outputFile -Value $delimiter
Add-Content -Path $outputFile -Value ""
# Read content as a single string to preserve exact formatting
$content = Get-Content $file.FullName -Raw
Add-Content -Path $outputFile -Value $content
Add-Content -Path $outputFile -Value "`n`n"
}
Write-Host "---------------------------------------------------------"
Write-Host "Project successfully exported to $outputFile" -ForegroundColor Green