88 lines
2.9 KiB
PowerShell
88 lines
2.9 KiB
PowerShell
# Vollständig fehlerfrei - autonom
|
|
$ProjectDir = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
if (-not $ProjectDir) { $ProjectDir = (Get-Location).Path }
|
|
|
|
Write-Host "Suche ReadMe in: $ProjectDir"
|
|
|
|
$readmePath = Join-Path $ProjectDir "Verwaltung-ReadMe.txt"
|
|
|
|
# Datei automatisch erstellen
|
|
if (-not (Test-Path $readmePath)) {
|
|
@"
|
|
=====================================
|
|
NEUIGKEITEN - Version ##VERSION##
|
|
=====================================
|
|
|
|
Build-Info:
|
|
- Commit-Hash: ##COMMIT##
|
|
- Build-Typ: ##CUSTOM##
|
|
|
|
Änderungen:
|
|
- [ ] Neue Features
|
|
- [ ] Bugfixes
|
|
|
|
Erstellt: ##BUILD_DATE##
|
|
=====================================
|
|
"@ | Out-File $readmePath -Encoding UTF8
|
|
Write-Host "✅ ReadMe-Vorlage erstellt!"
|
|
}
|
|
|
|
# VERSION - * durch Buildnummer ersetzen
|
|
$version = "1.0.0.0"
|
|
$assemblyInfoPath = Join-Path $ProjectDir "Properties\AssemblyInfo.cs"
|
|
if (Test-Path $assemblyInfoPath) {
|
|
$assemblyContent = Get-Content $assemblyInfoPath -Raw -ErrorAction SilentlyContinue
|
|
if ($assemblyContent -match 'AssemblyVersion\s*\(\s*"([^"]+)"\s*\)') {
|
|
$rawVersion = $matches[1]
|
|
# * durch Datum/Uhrzeit ersetzen
|
|
$buildNumber = (Get-Date -Format "MMdd")
|
|
$revision = (Get-Date -Format "HHmm")
|
|
$version = $rawVersion -replace '\*', $buildNumber -replace '\*', $revision
|
|
Write-Host "✓ Rohe Version: $rawVersion → Finale: $version"
|
|
}
|
|
}
|
|
|
|
# Git Commit - 100% robust
|
|
$commit = "No Git"
|
|
try {
|
|
# Einfachster Weg: git von aktuellem Ort ausführen
|
|
$gitOutput = & git rev-parse --short HEAD 2>$null
|
|
if ($LASTEXITCODE -eq 0 -and $gitOutput -and $gitOutput.Trim()) {
|
|
$commit = $gitOutput.Trim()
|
|
} else {
|
|
# Fallback: suche .git Ordner und wechsle hin
|
|
$gitDir = Join-Path $ProjectDir ".git"
|
|
if (Test-Path $gitDir) {
|
|
Push-Location $ProjectDir
|
|
$gitOutput = & git rev-parse --short HEAD 2>$null
|
|
if ($LASTEXITCODE -eq 0 -and $gitOutput -and $gitOutput.Trim()) {
|
|
$commit = $gitOutput.Trim()
|
|
}
|
|
Pop-Location
|
|
}
|
|
}
|
|
} catch {
|
|
# Noch ein Versuch mit vollständigem Pfad
|
|
$gitExe = (Get-Command git -ErrorAction SilentlyContinue).Source
|
|
if ($gitExe) {
|
|
$gitOutput = & $gitExe rev-parse --short HEAD 2>$null
|
|
if ($LASTEXITCODE -eq 0 -and $gitOutput -and $gitOutput.Trim()) {
|
|
$commit = $gitOutput.Trim()
|
|
}
|
|
}
|
|
}
|
|
Write-Host "Git Commit gefunden: $commit"
|
|
|
|
$custom = "PostgreSQL optimiert - Build: Debug"
|
|
$buildDate = Get-Date -Format "dd.MM.yyyy HH:mm"
|
|
|
|
# Ersetzen (FEHLERFREI)
|
|
$content = Get-Content $readmePath -Raw -Encoding UTF8 -ErrorAction SilentlyContinue
|
|
$content = $content -replace "##VERSION##", $version `
|
|
-replace "##COMMIT##", $commit `
|
|
-replace "##CUSTOM##", $custom `
|
|
-replace "##BUILD_DATE##", $buildDate
|
|
|
|
Set-Content $readmePath $content -Encoding UTF8
|
|
Write-Host "✓ ReadMe aktualisiert: $version ($commit)"
|