fix: dev-start.ps1 Syntax-Fehler beheben (Backtick-Continuation + Unicode-Zeichen entfernt)
This commit is contained in:
116
dev-start.ps1
116
dev-start.ps1
@@ -3,55 +3,50 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Startet die NexusRMM Entwicklungsumgebung
|
Startet die NexusRMM Entwicklungsumgebung
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Startet Docker (Postgres + MeshCentral), führt DB-Migrationen aus,
|
Startet Docker (Postgres), fuehrt DB-Migrationen aus,
|
||||||
startet Backend und Frontend in separaten Fenstern.
|
startet Backend und Frontend in separaten Fenstern.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
$Root = "D:\001_Projekte\IT_Tool"
|
$Root = "D:\001_Projekte\IT_Tool"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
function Write-Step { param($msg) Write-Host "" ; Write-Host "==> $msg" -ForegroundColor Cyan }
|
||||||
# Helper-Funktionen
|
|
||||||
# ---------------------------------------------------------------------------
|
|
||||||
function Write-Step { param($msg) Write-Host "`n==> $msg" -ForegroundColor Cyan }
|
|
||||||
function Write-OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green }
|
function Write-OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green }
|
||||||
function Write-Warn { param($msg) Write-Host " [!] $msg" -ForegroundColor Yellow }
|
function Write-Warn { param($msg) Write-Host " [!] $msg" -ForegroundColor Yellow }
|
||||||
function Write-Fail { param($msg) Write-Host " [FEHLER] $msg" -ForegroundColor Red }
|
function Write-Fail { param($msg) Write-Host " [FEHLER] $msg" -ForegroundColor Red }
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# 1. Voraussetzungen prüfen
|
# 1. Voraussetzungen pruefen
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Step "Prüfe Voraussetzungen..."
|
Write-Step "Pruefe Voraussetzungen..."
|
||||||
|
|
||||||
$missing = $false
|
$missing = $false
|
||||||
|
|
||||||
$tools = @(
|
$tools = @(
|
||||||
@{ Name = "docker"; Desc = "Docker Desktop" },
|
@{ Name = "docker"; Desc = "Docker Desktop" },
|
||||||
@{ Name = "dotnet"; Desc = ".NET SDK" },
|
@{ Name = "dotnet"; Desc = ".NET SDK" },
|
||||||
@{ Name = "node"; Desc = "Node.js" },
|
@{ Name = "node"; Desc = "Node.js" },
|
||||||
@{ Name = "npm"; Desc = "npm" },
|
@{ Name = "npm"; Desc = "npm" }
|
||||||
@{ Name = "go"; Desc = "Go" }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach ($tool in $tools) {
|
foreach ($tool in $tools) {
|
||||||
$cmd = Get-Command $tool.Name -ErrorAction SilentlyContinue
|
$cmd = Get-Command $tool.Name -ErrorAction SilentlyContinue
|
||||||
if ($null -eq $cmd) {
|
if ($null -eq $cmd) {
|
||||||
Write-Fail "$($tool.Desc) ($($tool.Name)) nicht gefunden. Bitte installieren."
|
Write-Fail "$($tool.Desc) ($($tool.Name)) nicht gefunden."
|
||||||
$missing = $true
|
$missing = $true
|
||||||
} else {
|
} else {
|
||||||
Write-OK "$($tool.Desc): $($cmd.Source)"
|
Write-OK "$($tool.Desc): gefunden"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($missing) {
|
if ($missing) {
|
||||||
Write-Fail "Fehlende Voraussetzungen – Abbruch."
|
Write-Fail "Fehlende Voraussetzungen. Bitte installieren und erneut starten."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# dotnet-ef prüfen
|
# dotnet-ef pruefen
|
||||||
$efInstalled = dotnet tool list --global 2>$null | Select-String "dotnet-ef"
|
$efCheck = dotnet tool list --global 2>$null | Select-String "dotnet-ef"
|
||||||
if (-not $efInstalled) {
|
if (-not $efCheck) {
|
||||||
Write-Warn "dotnet-ef nicht global installiert. Installiere jetzt..."
|
Write-Warn "dotnet-ef nicht gefunden. Installiere..."
|
||||||
dotnet tool install --global dotnet-ef
|
dotnet tool install --global dotnet-ef
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Fail "dotnet-ef konnte nicht installiert werden."
|
Write-Fail "dotnet-ef konnte nicht installiert werden."
|
||||||
@@ -67,25 +62,20 @@ if (-not $efInstalled) {
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Step "Starte PostgreSQL..."
|
Write-Step "Starte PostgreSQL..."
|
||||||
|
|
||||||
Push-Location $Root
|
Set-Location $Root
|
||||||
try {
|
|
||||||
docker compose up -d nexusrmm-postgres
|
docker compose up -d nexusrmm-postgres
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Fail "docker compose up fehlgeschlagen."
|
Write-Fail "docker compose up fehlgeschlagen. Laeuft Docker Desktop?"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
Pop-Location
|
|
||||||
}
|
|
||||||
|
|
||||||
# Warte bis PostgreSQL bereit ist (max 30 Sekunden, Intervall 2 Sekunden)
|
|
||||||
Write-Host " Warte auf PostgreSQL..." -ForegroundColor Cyan
|
Write-Host " Warte auf PostgreSQL..." -ForegroundColor Cyan
|
||||||
$maxWait = 30
|
$maxWait = 30
|
||||||
$waited = 0
|
$waited = 0
|
||||||
$pgReady = $false
|
$pgReady = $false
|
||||||
|
|
||||||
while ($waited -lt $maxWait) {
|
while ($waited -lt $maxWait) {
|
||||||
$result = docker exec nexusrmm-postgres pg_isready -U nexusrmm -q 2>&1
|
docker exec nexusrmm-postgres pg_isready -U nexusrmm -q 2>$null
|
||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
$pgReady = $true
|
$pgReady = $true
|
||||||
break
|
break
|
||||||
@@ -101,37 +91,30 @@ if (-not $pgReady) {
|
|||||||
Write-OK "PostgreSQL bereit (Port 5433)."
|
Write-OK "PostgreSQL bereit (Port 5433)."
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# 3. EF Core Migrationen ausführen
|
# 3. EF Core Migrationen
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Step "Führe Datenbank-Migrationen aus..."
|
Write-Step "Fuehre Datenbank-Migrationen aus..."
|
||||||
|
|
||||||
Push-Location "$Root\Backend"
|
Set-Location "$Root\Backend"
|
||||||
try {
|
|
||||||
# --project: Migration-Projekt (Infrastructure enthält DbContext + Migrations)
|
$efResult = dotnet ef database update --project "src\NexusRMM.Infrastructure" --startup-project "src\NexusRMM.Api" --no-build 2>&1
|
||||||
# --startup-project: Startup-Projekt mit Verbindungsstring
|
|
||||||
dotnet ef database update `
|
|
||||||
--project "src\NexusRMM.Infrastructure" `
|
|
||||||
--startup-project "src\NexusRMM.Api" `
|
|
||||||
--no-build
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
# --no-build schlägt fehl wenn noch kein Build vorhanden – Build nachholen
|
Write-Warn "Migration mit --no-build fehlgeschlagen. Baue zuerst..."
|
||||||
Write-Warn "Migration mit --no-build fehlgeschlagen, baue zuerst..."
|
|
||||||
dotnet build "src\NexusRMM.Api" --configuration Debug -q
|
dotnet build "src\NexusRMM.Api" --configuration Debug -q
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Fail "dotnet build fehlgeschlagen."
|
Write-Fail "dotnet build fehlgeschlagen."
|
||||||
|
Set-Location $Root
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
dotnet ef database update `
|
dotnet ef database update --project "src\NexusRMM.Infrastructure" --startup-project "src\NexusRMM.Api"
|
||||||
--project "src\NexusRMM.Infrastructure" `
|
|
||||||
--startup-project "src\NexusRMM.Api"
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Fail "dotnet ef database update fehlgeschlagen."
|
Write-Fail "dotnet ef database update fehlgeschlagen."
|
||||||
|
Set-Location $Root
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
Pop-Location
|
Set-Location $Root
|
||||||
}
|
|
||||||
Write-OK "Migrationen erfolgreich."
|
Write-OK "Migrationen erfolgreich."
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -139,20 +122,14 @@ Write-OK "Migrationen erfolgreich."
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Step "Starte Backend..."
|
Write-Step "Starte Backend..."
|
||||||
|
|
||||||
$backendCmd = "Set-Location '$Root\Backend'; Write-Host 'NexusRMM Backend' -ForegroundColor Cyan; dotnet run --project src/NexusRMM.Api"
|
$backendCmd = "Set-Location '$Root\Backend'; Write-Host 'NexusRMM Backend gestartet' -ForegroundColor Cyan; dotnet run --project src/NexusRMM.Api"
|
||||||
|
Start-Process powershell -ArgumentList "-NoExit", "-Command", $backendCmd -WindowStyle Normal
|
||||||
Start-Process powershell -ArgumentList @(
|
Write-OK "Backend-Fenster geoeffnet."
|
||||||
"-NoExit",
|
|
||||||
"-Command",
|
|
||||||
$backendCmd
|
|
||||||
) -WindowStyle Normal
|
|
||||||
|
|
||||||
Write-OK "Backend-Fenster geöffnet."
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# 5. Kurz warten damit das Backend starten kann
|
# 5. Kurz warten
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Host "`n Warte 5 Sekunden damit das Backend hochfahren kann..." -ForegroundColor Cyan
|
Write-Host " Warte 5 Sekunden fuer Backend-Start..." -ForegroundColor Cyan
|
||||||
Start-Sleep -Seconds 5
|
Start-Sleep -Seconds 5
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -160,29 +137,24 @@ Start-Sleep -Seconds 5
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Step "Starte Frontend..."
|
Write-Step "Starte Frontend..."
|
||||||
|
|
||||||
$frontendCmd = "Set-Location '$Root\Frontend'; Write-Host 'NexusRMM Frontend' -ForegroundColor Cyan; npm run dev"
|
$frontendCmd = "Set-Location '$Root\Frontend'; Write-Host 'NexusRMM Frontend gestartet' -ForegroundColor Cyan; npm run dev"
|
||||||
|
Start-Process powershell -ArgumentList "-NoExit", "-Command", $frontendCmd -WindowStyle Normal
|
||||||
Start-Process powershell -ArgumentList @(
|
Write-OK "Frontend-Fenster geoeffnet."
|
||||||
"-NoExit",
|
|
||||||
"-Command",
|
|
||||||
$frontendCmd
|
|
||||||
) -WindowStyle Normal
|
|
||||||
|
|
||||||
Write-OK "Frontend-Fenster geöffnet."
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# 7. Zusammenfassung
|
# 7. Zusammenfassung
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "╔══════════════════════════════════════════╗" -ForegroundColor Green
|
Write-Host "+------------------------------------------+" -ForegroundColor Green
|
||||||
Write-Host "║ NexusRMM ist bereit! ║" -ForegroundColor Green
|
Write-Host "| NexusRMM ist bereit! |" -ForegroundColor Green
|
||||||
Write-Host "╠══════════════════════════════════════════╣" -ForegroundColor Green
|
Write-Host "+------------------------------------------+" -ForegroundColor Green
|
||||||
Write-Host "║ Frontend: http://localhost:5173 ║" -ForegroundColor Green
|
Write-Host "| Frontend: http://localhost:5173 |" -ForegroundColor Green
|
||||||
Write-Host "║ Backend: http://localhost:5000 ║" -ForegroundColor Green
|
Write-Host "| Backend: http://localhost:5000 |" -ForegroundColor Green
|
||||||
Write-Host "║ Swagger: http://localhost:5000/swagger ║" -ForegroundColor Green
|
Write-Host "| Swagger: http://localhost:5000/swagger |" -ForegroundColor Green
|
||||||
Write-Host "║ gRPC: http://localhost:5001 ║" -ForegroundColor Green
|
Write-Host "| gRPC: http://localhost:5001 |" -ForegroundColor Green
|
||||||
Write-Host "║ MeshCentral: https://localhost:4430 ║" -ForegroundColor Green
|
Write-Host "| MeshCentral: https://localhost:4430 |" -ForegroundColor Green
|
||||||
Write-Host "╚══════════════════════════════════════════╝" -ForegroundColor Green
|
Write-Host "+------------------------------------------+" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Agent starten: .\Agent\nexus-agent.exe" -ForegroundColor Yellow
|
Write-Host "Agent starten: .\Agent\nexus-agent.exe" -ForegroundColor Yellow
|
||||||
Write-Host "Alles stoppen: .\dev-stop.ps1" -ForegroundColor Yellow
|
Write-Host "Alles stoppen: .\dev-stop.ps1" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
|||||||
Reference in New Issue
Block a user