Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 63 additions & 33 deletions Build/Agent/Verify-FwDependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
- .NET Framework 4.8.1 SDK & Targeting Pack
- Windows SDK
- WiX Toolset v6 (installer builds restore via NuGet)
- NuGet CLI
- .NET SDK 8.x+

.PARAMETER FailOnMissing
Expand All @@ -21,6 +20,12 @@
.PARAMETER IncludeOptional
If specified, also checks optional dependencies like clangd for Serena.

.PARAMETER Detailed
If specified, prints the full per-dependency section headers and success details instead of the compact summary-only output.

.PARAMETER PassThru
If specified, returns the dependency result objects for scripting callers instead of writing them implicitly.

.EXAMPLE
# Quick check
.\Build\Agent\Verify-FwDependencies.ps1
Expand All @@ -32,12 +37,22 @@
.EXAMPLE
# Include Serena dependencies
.\Build\Agent\Verify-FwDependencies.ps1 -IncludeOptional

.EXAMPLE
# Show full dependency-by-dependency output
.\Build\Agent\Verify-FwDependencies.ps1 -IncludeOptional -Detailed

.EXAMPLE
# Capture structured results for automation
$results = .\Build\Agent\Verify-FwDependencies.ps1 -IncludeOptional -PassThru
#>

[CmdletBinding()]
param(
[switch]$FailOnMissing,
[switch]$IncludeOptional
[switch]$IncludeOptional,
[switch]$Detailed,
[switch]$PassThru
)

$ErrorActionPreference = 'Stop'
Expand All @@ -52,11 +67,13 @@ function Test-Dependency {
try {
$result = & $Check
if ($result) {
Write-Host "[OK] $Name" -ForegroundColor Green
if ($result -is [string] -and $result.Length -gt 0 -and $result.Length -lt 100) {
Write-Host " $result" -ForegroundColor DarkGray
if ($Detailed) {
Write-Host "[OK] $Name" -ForegroundColor Green
if ($result -is [string] -and $result.Length -gt 0 -and $result.Length -lt 100) {
Write-Host " $result" -ForegroundColor DarkGray
}
}
return @{ Name = $Name; Found = $true; Info = $result }
return @{ Name = $Name; Found = $true; IsRequired = ($Required -eq "Required"); Info = $result }
}
else {
throw "Check returned null/false"
Expand All @@ -67,7 +84,7 @@ function Test-Dependency {
$status = if ($Required -eq "Required") { "[FAIL]" } else { "[WARN]" }
Write-Host "$status $Name" -ForegroundColor $color
Write-Host " $_" -ForegroundColor DarkGray
return @{ Name = $Name; Found = $false; Required = ($Required -eq "Required"); Error = $_.ToString() }
return @{ Name = $Name; Found = $false; IsRequired = ($Required -eq "Required"); Error = $_.ToString() }
}
}

Expand Down Expand Up @@ -102,15 +119,19 @@ function Find-DotNetFrameworkSdkTool {
# MAIN SCRIPT
# ============================================================================

Write-Host "=== FieldWorks Dependency Verification ===" -ForegroundColor Cyan
Write-Host ""
if ($Detailed) {
Write-Host "=== FieldWorks Dependency Verification ===" -ForegroundColor Cyan
Write-Host ""
}

$results = @()

# ----------------------------------------------------------------------------
# Required Dependencies
# ----------------------------------------------------------------------------
Write-Host "--- Required Dependencies ---" -ForegroundColor Cyan
if ($Detailed) {
Write-Host "--- Required Dependencies ---" -ForegroundColor Cyan
}

# .NET Framework targeting pack (4.8+)
$results += Test-Dependency -Name ".NET Framework Targeting Pack (4.8+)" -Check {
Expand Down Expand Up @@ -177,16 +198,6 @@ $results += Test-Dependency -Name "al.exe (.NET Framework SDK)" -Check {
throw "al.exe not found in Windows SDK NETFX tool folders"
}

# NuGet CLI (legacy — build uses dotnet restore since CPM migration)
$results += Test-Dependency -Name "NuGet CLI (legacy)" -Required "Optional" -Check {
$nuget = Get-Command nuget.exe -ErrorAction SilentlyContinue
if ($nuget) {
$version = (& nuget.exe help 2>&1 | Select-Object -First 1)
return $version
}
throw "nuget.exe not found in PATH (no longer required; build uses dotnet restore)"
}

# .NET SDK
$results += Test-Dependency -Name ".NET SDK" -Check {
$dotnet = Get-Command dotnet.exe -ErrorAction SilentlyContinue
Expand All @@ -206,8 +217,22 @@ $results += Test-Dependency -Name "WiX Toolset (v6 via NuGet)" -Required "Option
throw "Installer project not found: $wixProj"
}

$wixProjText = Get-Content -LiteralPath $wixProj -Raw
if ($wixProjText -match "WixToolset\\.Sdk") {
[xml]$wixProjXml = Get-Content -LiteralPath $wixProj
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When casting file content to [xml], using Get-Content without -Raw returns an array of lines, which can be implicitly re-joined and is more error-prone than reading the file as a single string. Prefer Get-Content -Raw -LiteralPath $wixProj before the [xml] cast to make XML parsing behavior deterministic.

Suggested change
[xml]$wixProjXml = Get-Content -LiteralPath $wixProj
[xml]$wixProjXml = Get-Content -Raw -LiteralPath $wixProj

Copilot uses AI. Check for mistakes.
$projectNode = $wixProjXml.Project
$hasWixSdk = $false

if ($projectNode -and $projectNode.Sdk -match 'WixToolset\.Sdk') {
$hasWixSdk = $true
}

if (-not $hasWixSdk) {
$wixSdkReference = $wixProjXml.SelectSingleNode("//*[local-name()='PackageReference' and @Include='WixToolset.Sdk']")
if ($wixSdkReference) {
$hasWixSdk = $true
}
}

if ($hasWixSdk) {
return "Configured in $wixProj (restored during build)"
}

Expand All @@ -218,8 +243,10 @@ $results += Test-Dependency -Name "WiX Toolset (v6 via NuGet)" -Required "Option
# Optional Dependencies (for Serena MCP)
# ----------------------------------------------------------------------------
if ($IncludeOptional) {
Write-Host ""
Write-Host "--- Optional Dependencies (Serena MCP) ---" -ForegroundColor Cyan
if ($Detailed) {
Write-Host ""
Write-Host "--- Optional Dependencies (Serena MCP) ---" -ForegroundColor Cyan
}

# Python
$results += Test-Dependency -Name "Python" -Required "Optional" -Check {
Expand Down Expand Up @@ -265,22 +292,24 @@ if ($IncludeOptional) {
# ----------------------------------------------------------------------------
# Summary
# ----------------------------------------------------------------------------
Write-Host ""
Write-Host "=== Summary ===" -ForegroundColor Cyan
if ($Detailed) {
Write-Host ""
Write-Host "=== Summary ===" -ForegroundColor Cyan
}

$required = $results | Where-Object { $_.Required -ne $false }
$required = $results | Where-Object { $_.IsRequired -ne $false }
$missing = $required | Where-Object { -not $_.Found }
$optional = $results | Where-Object { $_.Required -eq $false }
$optional = $results | Where-Object { $_.IsRequired -eq $false }

$totalRequired = ($required | Measure-Object).Count
$foundRequired = ($required | Where-Object { $_.Found } | Measure-Object).Count

Write-Host "Required: $foundRequired / $totalRequired found"
Write-Host "Dependency preflight: required $foundRequired/$totalRequired found"

if ($IncludeOptional) {
$totalOptional = ($optional | Measure-Object).Count
$foundOptional = ($optional | Where-Object { $_.Found } | Measure-Object).Count
Write-Host "Optional: $foundOptional / $totalOptional found"
Write-Host "Dependency preflight: optional $foundOptional/$totalOptional found"
}

if ($missing.Count -gt 0) {
Expand All @@ -297,8 +326,9 @@ if ($missing.Count -gt 0) {
}
}
else {
Write-Host ""
Write-Host "All required dependencies are available!" -ForegroundColor Green
Write-Host "Dependency preflight: all required dependencies are available" -ForegroundColor Green
}

return $results
if ($PassThru) {
return $results
}
8 changes: 8 additions & 0 deletions Docs/core-developer-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ git --version

# Verify installer build prerequisites
.\Build\Agent\Setup-InstallerBuild.ps1 -ValidateOnly

# Compact dependency preflight summary
.\Build\Agent\Verify-FwDependencies.ps1

# Include optional Serena-related tools with detailed per-check output
.\Build\Agent\Verify-FwDependencies.ps1 -IncludeOptional -Detailed
```

For automation or scripted setup checks, add `-PassThru` to return structured dependency results instead of relying only on console output.

## Additional Setup

### 1. Register with Services
Expand Down
Loading