From c91cf1b826ccded1c1e32fd5336dd6a687bcc59b Mon Sep 17 00:00:00 2001 From: Jimmy Gatsby Date: Tue, 27 Oct 2026 19:17:39 +0800 Subject: [PATCH] build: add shared project metadata --- src/Sharp/Directory.Build.props | 49 +++++++++++++++++++ src/Sharp/update-metadata.ps1 | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/Sharp/Directory.Build.props create mode 100644 src/Sharp/update-metadata.ps1 diff --git a/src/Sharp/Directory.Build.props b/src/Sharp/Directory.Build.props new file mode 100644 index 0000000..3a1622c --- /dev/null +++ b/src/Sharp/Directory.Build.props @@ -0,0 +1,49 @@ + + + + duyl328 + duyl328 + Sharp-Basic Framework + 模块化.NET 8企业应用开发框架 + Copyright © 2024-2025 duyl328. All rights reserved. + + + 1.0.1 + 1.0.1.0 + 1.0.1.0 + + + https://gitea.duyl328.org/jimmy/sharp-basic + git + https://gitea.duyl328.org/jimmy/sharp-basic + + + AGPL-3.0-or-later + + + latest + enable + enable + true + + + true + wpf;mvvm;dotnet;framework;plc;industrial;iot;siemens;ef-core;serilog;configuration;csharp;enterprise;modular;iiot + README.md + + + true + true + true + snupkg + + + true + true + + + + + + + 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