31 lines
1.1 KiB
PowerShell
31 lines
1.1 KiB
PowerShell
# PowerShell script to fix project file formatting issues
|
|
|
|
# Get all .csproj files
|
|
$projectFiles = Get-ChildItem -Path "." -Recurse -Name "*.csproj" | ForEach-Object { $_ }
|
|
|
|
foreach ($projectFile in $projectFiles) {
|
|
if (Test-Path $projectFile) {
|
|
Write-Host "Fixing $projectFile"
|
|
|
|
# Read the file content
|
|
$content = Get-Content $projectFile -Raw
|
|
|
|
# Fix the malformed LangVersion line
|
|
$content = $content -replace '<TargetFramework>([^<]+)</TargetFramework>`n\s*<LangVersion>8\.0</LangVersion>', '<TargetFramework>$1</TargetFramework>`n <LangVersion>8.0</LangVersion>'
|
|
|
|
# Remove extra empty lines at the end
|
|
$content = $content -replace '\n\n\n+$', "`n"
|
|
|
|
# Ensure proper line endings
|
|
$content = $content -replace '\r\n', "`n"
|
|
$content = $content -replace '\n', "`r`n"
|
|
|
|
# Write the updated content back to the file
|
|
Set-Content $projectFile -Value $content -Encoding UTF8 -NoNewline
|
|
|
|
Write-Host "Fixed $projectFile"
|
|
}
|
|
}
|
|
|
|
Write-Host "All project files have been fixed."
|