Files
ResourceUsageAPI/build-and-deploy.ps1

52 lines
1.6 KiB
PowerShell

# Resource Monitor Service - Complete Build and Deploy Script
# Builds, packages, and optionally deploys to VM in one step
param(
[string]$VMAddress,
[string]$Version = "2.1.0",
[switch]$DeployToVM,
[switch]$UseWinRM,
[switch]$CopyOnly
)
Write-Host "=== Resource Monitor Service - Build & Deploy ===" -ForegroundColor Cyan
Write-Host
# Step 1: Package the release
Write-Host "Step 1: Building and packaging release..." -ForegroundColor Green
try {
& ".\package-release.ps1" -Version $Version
if ($LASTEXITCODE -ne 0) {
throw "Packaging failed"
}
} catch {
Write-Host "✗ Packaging failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
# Step 2: Deploy if requested
if ($DeployToVM -and $VMAddress) {
Write-Host
Write-Host "Step 2: Deploying to VM..." -ForegroundColor Green
$deployArgs = @("-VMAddress", $VMAddress)
if ($UseWinRM) { $deployArgs += "-UseWinRM" }
if ($CopyOnly) { $deployArgs += "-CopyOnly" }
try {
& ".\deploy-to-vm.ps1" @deployArgs
} catch {
Write-Host "✗ Deployment failed: $($_.Exception.Message)" -ForegroundColor Red
exit 1
}
} else {
Write-Host
Write-Host "Package created successfully!" -ForegroundColor Green
Write-Host "To deploy to VM, run:" -ForegroundColor Yellow
Write-Host " .\deploy-to-vm.ps1 -VMAddress YOUR_VM_IP" -ForegroundColor Cyan
Write-Host " .\deploy-to-vm.ps1 -VMAddress YOUR_VM_IP -UseWinRM" -ForegroundColor Cyan
}
Write-Host
Write-Host "=== Build & Deploy Complete ===" -ForegroundColor Cyan