Files
AutopilotMonitor/build.ps1
T
Oliver Kieselbach 9f7b070e80 chore: remove legacy V1 agent and its backend ingest path
The V1 agent line is retired: no new V1 sessions since 2026-05-09, only
orphaned straggler traffic remained on /api/agent/ingest (last seen
2026-06-29, events for long-cleaned-up sessions). Bootstrap/Intune/CI
have deployed V2-only since the v2 cutover.

Agent:
- Delete AutopilotMonitor.Agent, .Agent.Core, .Agent.Core.Tests
  (projects + sln entries). V2 trio, SummaryDialog, DecisionCore.Tests
  and V2Isolation.targets stay.

Backend:
- Relocate the shared statics/DTOs V2 reused from the V1 partials
  (StampServerFields, SanitizeEventTimestamps, IsMaxLifetimeAgentShutdown,
  RecalculateAppDurations, EventClassification, AppInstallAggregationState)
  into EventIngestProcessor; IngestEventsOutput moves next to
  IngestTelemetryFunction (same namespace, zero ripple).
- Delete IngestEventsFunction (route agent/ingest), BootstrapIngestEvents
  (route bootstrap/ingest), NdjsonParser and their DI registration.
  EventDataNormalizer stays (used by TelemetryPayloadParser).
- Drop both routes from EndpointAccessPolicyCatalog and
  RequestTelemetryMiddleware.TenantHeaderTrustedPaths.
- Retire the V1 update-hash oracle: LatestAgentV1*/LatestBootstrapV1*
  fields + GetAgentLine case 1 (default arm returns empty hashes, so
  stragglers gracefully skip the integrity check; ParseAgentMajor keeps
  its default of 1 on purpose — defaulting to 2 would feed V2 hashes to
  V1 binaries). TableConfigRepository Store+Map updated in lockstep.
- Remove ApiEndpoints.IngestEvents/.BootstrapIngestEvents constants.

Tests: NdjsonParserTests deleted; timestamp/critical-path/max-lifetime
tests repointed to EventIngestProcessor; the two NDJSON pipeline tests
removed (coverage retained by direct-list siblings); catalog/no-store
InlineData rows updated.

Docs: architecture.md (endpoint tables, ingest flow diagram, solution
layout, test matrix), web SectionAgentInternals endpoint tables,
build.ps1 help text.

Azure: no config change needed — /api/agent is not in the client-cert
exclusion paths (agent/ingest was always cert-enforced) and the
/api/bootstrap prefix exclusion remains for the surviving bootstrap
routes (verified via ARM on autopilotmonitor-api).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 08:53:20 +02:00

167 lines
4.8 KiB
PowerShell

<#
.SYNOPSIS
Build script for Autopilot Monitor solution.
.DESCRIPTION
Builds all .NET projects and optionally the web UI.
Run this after cloning or when you want to rebuild everything.
.PARAMETER Configuration
Build configuration: Debug or Release (default: Debug)
.PARAMETER IncludeWeb
Also build the web UI (requires Node.js)
.PARAMETER Clean
Clean before building
.EXAMPLE
.\build.ps1
Builds all .NET projects in Debug mode
.EXAMPLE
.\build.ps1 -Configuration Release -IncludeWeb
Builds everything in Release mode including web UI
#>
[CmdletBinding()]
param(
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Debug",
[switch]$IncludeWeb,
[switch]$Clean
)
$ErrorActionPreference = "Stop"
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " Autopilot Monitor Build Script" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
$rootPath = $PSScriptRoot
$slnPath = Join-Path $rootPath "AutopilotMonitor.sln"
# Check prerequisites
Write-Host "[1/4] Checking prerequisites..." -ForegroundColor Yellow
# Check .NET SDK
try {
$dotnetVersion = & dotnet --version
Write-Host " ✓ .NET SDK version: $dotnetVersion" -ForegroundColor Green
}
catch {
Write-Host " ✗ .NET SDK not found. Please install .NET 8 SDK." -ForegroundColor Red
exit 1
}
# Check Node.js if building web
if ($IncludeWeb) {
try {
$nodeVersion = & node --version
Write-Host " ✓ Node.js version: $nodeVersion" -ForegroundColor Green
}
catch {
Write-Host " ✗ Node.js not found. Please install Node.js 18+." -ForegroundColor Red
exit 1
}
}
Write-Host ""
# Clean if requested
if ($Clean) {
Write-Host "[2/4] Cleaning solution..." -ForegroundColor Yellow
& dotnet clean $slnPath -c $Configuration
Write-Host " ✓ Clean completed" -ForegroundColor Green
Write-Host ""
}
else {
Write-Host "[2/4] Skipping clean (use -Clean to clean first)" -ForegroundColor Gray
Write-Host ""
}
# Restore packages
Write-Host "[3/4] Restoring NuGet packages..." -ForegroundColor Yellow
& dotnet restore $slnPath
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ Restore failed" -ForegroundColor Red
exit 1
}
Write-Host " ✓ Restore completed" -ForegroundColor Green
Write-Host ""
# Build solution
Write-Host "[4/4] Building solution ($Configuration)..." -ForegroundColor Yellow
& dotnet build $slnPath -c $Configuration --no-restore
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ Build failed" -ForegroundColor Red
exit 1
}
Write-Host " ✓ Build completed" -ForegroundColor Green
Write-Host ""
# Build web if requested
if ($IncludeWeb) {
Write-Host "[BONUS] Building web UI..." -ForegroundColor Yellow
$webPath = Join-Path $rootPath "src\Web\autopilot-monitor-web"
Push-Location $webPath
try {
Write-Host " Installing npm packages..." -ForegroundColor Gray
& npm install --silent
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ npm install failed" -ForegroundColor Red
exit 1
}
Write-Host " Building Next.js app..." -ForegroundColor Gray
& npm run build
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ Web build failed" -ForegroundColor Red
exit 1
}
Write-Host " ✓ Web build completed" -ForegroundColor Green
}
finally {
Pop-Location
}
Write-Host ""
}
# Summary
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " Build Completed Successfully!" -ForegroundColor Green
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Output locations:" -ForegroundColor White
Write-Host " Agent: src\Agent\AutopilotMonitor.Agent.V2\bin\$Configuration\net48\" -ForegroundColor Gray
Write-Host " Functions: src\Backend\AutopilotMonitor.Functions\bin\$Configuration\net8.0\" -ForegroundColor Gray
if ($IncludeWeb) {
Write-Host " Web UI: src\Web\autopilot-monitor-web\.next\" -ForegroundColor Gray
}
Write-Host ""
Write-Host "Next steps:" -ForegroundColor White
Write-Host " 1. Start Azurite: azurite --silent --location c:\azurite" -ForegroundColor Gray
Write-Host " 2. Start Functions: cd src\Backend\AutopilotMonitor.Functions && func start" -ForegroundColor Gray
if ($IncludeWeb) {
Write-Host " 3. Start Web UI: cd src\Web\autopilot-monitor-web && npm run dev" -ForegroundColor Gray
Write-Host " 4. Test Agent: cd src\Agent\AutopilotMonitor.Agent.V2\bin\$Configuration\net48 && .\AutopilotMonitor.Agent.exe --console" -ForegroundColor Gray
}
else {
Write-Host " 3. Test Agent: cd src\Agent\AutopilotMonitor.Agent.V2\bin\$Configuration\net48 && .\AutopilotMonitor.Agent.exe --console" -ForegroundColor Gray
}