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