Files
disco-ad-compare-plugin/Diagnose-InstalledPlugin.ps1
jessikitty 0057523323 feat: add standalone diagnostic script for installed plugin
Checks the installed manifest at App_Data\Plugins for Features array,
validates CategoryTypeName, scans Disco logs for plugin-related entries,
and shows file timestamps for the installed DLL.
2026-04-29 09:50:09 +10:00

108 lines
4.8 KiB
PowerShell

# Diagnose-InstalledPlugin.ps1
# Run this on the Disco server to check if the installed plugin has UIExtension features
#
# Usage:
# .\Diagnose-InstalledPlugin.ps1
# .\Diagnose-InstalledPlugin.ps1 -DiscoPath "D:\Disco\WebApp"
param(
[string]$DiscoPath = "C:\Program Files\Disco\WebApp"
)
$PluginName = "Disco.Plugins.ADCompare"
$pluginDir = Join-Path $DiscoPath "App_Data\Plugins\$PluginName"
Write-Host "=== Installed Plugin Diagnostics ===" -ForegroundColor Cyan
Write-Host "Checking: $pluginDir" -ForegroundColor Gray
if (-not (Test-Path $pluginDir)) {
Write-Host "`n Plugin directory NOT FOUND at $pluginDir" -ForegroundColor Red
Write-Host " The plugin may not be installed, or Disco may use a different path." -ForegroundColor Yellow
Write-Host " Try searching: Get-ChildItem 'C:\' -Recurse -Filter '$PluginName' -Directory -ErrorAction SilentlyContinue" -ForegroundColor Yellow
exit 1
}
Write-Host "`n--- Installed Files ---" -ForegroundColor Yellow
Get-ChildItem $pluginDir -File | ForEach-Object {
$size = [math]::Round($_.Length / 1KB, 1)
Write-Host " $($_.Name) ($size KB) - Modified: $($_.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss'))" -ForegroundColor Gray
}
# Check manifest
$manifestPath = Join-Path $pluginDir "manifest.json"
if (-not (Test-Path $manifestPath)) {
Write-Host "`n [CRITICAL] manifest.json NOT FOUND in installed plugin directory!" -ForegroundColor Red
exit 1
}
Write-Host "`n--- Installed Manifest ---" -ForegroundColor Yellow
$manifestContent = Get-Content $manifestPath -Raw
$manifestObj = $manifestContent | ConvertFrom-Json
Write-Host " Id: $($manifestObj.Id)" -ForegroundColor Gray
Write-Host " Version: $($manifestObj.Version)" -ForegroundColor Gray
Write-Host " TypeName: $($manifestObj.TypeName)" -ForegroundColor Gray
if (-not $manifestObj.Features -or $manifestObj.Features.Count -eq 0) {
Write-Host "`n [ROOT CAUSE] Features array is EMPTY or MISSING!" -ForegroundColor Red
Write-Host " This means Disco has no UIExtension features to load for this plugin." -ForegroundColor Red
Write-Host " The plugin will initialize but UIExtensions will never render." -ForegroundColor Red
Write-Host "`n FIX: Re-build with the updated Build-Plugin.ps1 and re-import the .discoPlugin file." -ForegroundColor Yellow
Write-Host " The new build script generates the Features array in manifest.json." -ForegroundColor Yellow
} else {
Write-Host " Features: $($manifestObj.Features.Count) found" -ForegroundColor Green
$expectedCategory = 'Disco.Services.Plugins.Features.UIExtension.UIExtensionFeature`1'
foreach ($feature in $manifestObj.Features) {
Write-Host "`n Feature: $($feature.Id)" -ForegroundColor Cyan
Write-Host " TypeName: $($feature.TypeName)" -ForegroundColor Gray
Write-Host " CategoryTypeName: $($feature.CategoryTypeName)" -ForegroundColor Gray
if ($feature.CategoryTypeName -eq $expectedCategory) {
Write-Host " CategoryTypeName: VALID" -ForegroundColor Green
} else {
Write-Host " CategoryTypeName: MISMATCH (expected: $expectedCategory)" -ForegroundColor Red
}
}
}
# Check Disco logs for plugin initialization
Write-Host "`n--- Disco Log Check ---" -ForegroundColor Yellow
$logDir = Join-Path $DiscoPath "App_Data\Logs"
if (Test-Path $logDir) {
$recentLog = Get-ChildItem $logDir -Filter "*.log" -ErrorAction SilentlyContinue |
Sort-Object LastWriteTime -Descending | Select-Object -First 1
if ($recentLog) {
Write-Host " Most recent log: $($recentLog.Name) ($($recentLog.LastWriteTime))" -ForegroundColor Gray
$pluginLines = Select-String -Path $recentLog.FullName -Pattern "ADCompare|$PluginName" -ErrorAction SilentlyContinue
if ($pluginLines) {
Write-Host " Plugin-related log entries:" -ForegroundColor Gray
$pluginLines | Select-Object -Last 20 | ForEach-Object {
$line = $_.Line.Trim()
if ($line -match 'error|exception|fail') {
Write-Host " $line" -ForegroundColor Red
} elseif ($line -match 'warn') {
Write-Host " $line" -ForegroundColor Yellow
} else {
Write-Host " $line" -ForegroundColor DarkGray
}
}
} else {
Write-Host " No plugin-related entries found in latest log." -ForegroundColor Yellow
}
} else {
Write-Host " No log files found in $logDir" -ForegroundColor Yellow
}
} else {
Write-Host " Log directory not found at $logDir" -ForegroundColor Yellow
}
# Dump raw manifest
Write-Host "`n--- Raw Installed manifest.json ---" -ForegroundColor DarkGray
$manifestContent -split "`n" | ForEach-Object {
Write-Host " $_" -ForegroundColor DarkGray
}
Write-Host "--- End ---" -ForegroundColor DarkGray