diff --git a/src/Sharp/update-metadata.ps1 b/src/Sharp/update-metadata.ps1 new file mode 100644 index 0000000..709452d --- /dev/null +++ b/src/Sharp/update-metadata.ps1 @@ -0,0 +1,85 @@ +# Clean redundant metadata from all project files +# Projects will inherit from Directory.Build.props + +$ErrorActionPreference = "Stop" + +Write-Host "Cleaning Project Metadata..." -ForegroundColor Cyan + +# Get all .csproj files +$projectFiles = Get-ChildItem -Path "." -Filter "*.csproj" -Recurse | + Where-Object { $_.FullName -notmatch "\\obj\\" -and $_.FullName -notmatch "\\bin\\" } + +Write-Host "Found $($projectFiles.Count) project files" -ForegroundColor Yellow + +# Metadata properties to remove (will inherit from Directory.Build.props) +$metadataToRemove = @( + "Version", + "AssemblyVersion", + "FileVersion", + "Authors", + "Company", + "Product", + "Copyright", + "PackageId", + "PackageProjectUrl", + "RepositoryUrl", + "RepositoryType", + "PackageLicenseExpression" +) + +$totalModified = 0 + +foreach ($projectFile in $projectFiles) { + Write-Host "`nProcessing: $($projectFile.Name)" -ForegroundColor Cyan + + # Read file content + $lines = Get-Content -Path $projectFile.FullName -Encoding UTF8 + $newLines = New-Object System.Collections.ArrayList + $modified = $false + $removedCount = 0 + + # Filter out metadata lines + foreach ($line in $lines) { + $shouldSkip = $false + + # Check if line contains any metadata to remove + foreach ($metadata in $metadataToRemove) { + if ($line -match "<$metadata>.*") { + $shouldSkip = $true + $removedCount++ + Write-Host " Removed: $metadata" -ForegroundColor Gray + break + } + } + + # Skip comment lines + if ($line -match "") { + $shouldSkip = $true + } + + if (-not $shouldSkip) { + [void]$newLines.Add($line) + } else { + $modified = $true + } + } + + # Save if modified + if ($modified) { + $newLines | Set-Content -Path $projectFile.FullName -Encoding UTF8 + Write-Host " Updated ($removedCount properties removed)" -ForegroundColor Green + $totalModified++ + } else { + Write-Host " No changes needed" -ForegroundColor DarkGray + } +} + +Write-Host "`n========================================" -ForegroundColor Cyan +Write-Host "Done! Updated $totalModified project files" -ForegroundColor Green +Write-Host "========================================" -ForegroundColor Cyan +Write-Host "`nProjects now inherit from Directory.Build.props:" -ForegroundColor Yellow +Write-Host " - Version, Authors, Copyright" -ForegroundColor White +Write-Host " - Repository URLs, License" -ForegroundColor White +Write-Host "`nProject-specific properties retained:" -ForegroundColor Yellow +Write-Host " - Description" -ForegroundColor White +Write-Host " - PackageTags" -ForegroundColor White