@echo off setlocal set "TARGET_DIR=%PROGRAMDATA%\Autodesk\Navisworks Manage 2026\plugins\TransportPlugin" set "BUILD_DIR=%~dp0bin\x64\Release" powershell -NoProfile -ExecutionPolicy Bypass -Command ^ "$ErrorActionPreference = 'Stop';" ^ "$targetDir = [System.IO.Path]::GetFullPath('%TARGET_DIR%');" ^ "$buildDir = [System.IO.Path]::GetFullPath('%BUILD_DIR%');" ^ "" ^ "Get-Process Roamer -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue;" ^ "$deadline = (Get-Date).AddSeconds(15);" ^ "while (Get-Process Roamer -ErrorAction SilentlyContinue) {" ^ " if ((Get-Date) -ge $deadline) { throw 'Roamer.exe still running after 15 seconds.' }" ^ " Start-Sleep -Milliseconds 500;" ^ "}" ^ "" ^ "New-Item -ItemType Directory -Force -Path $targetDir | Out-Null;" ^ "Copy-Item (Join-Path $buildDir '*.dll') $targetDir -Force;" ^ "if (Test-Path (Join-Path $buildDir 'resources')) {" ^ " New-Item -ItemType Directory -Force -Path (Join-Path $targetDir 'resources') | Out-Null;" ^ " Copy-Item (Join-Path $buildDir 'resources\\*') (Join-Path $targetDir 'resources') -Recurse -Force;" ^ "}" ^ "" ^ "$sourceFiles = @();" ^ "$sourceFiles += Get-ChildItem $buildDir -File -Filter '*.dll';" ^ "if (Test-Path (Join-Path $buildDir 'resources')) {" ^ " $sourceFiles += Get-ChildItem (Join-Path $buildDir 'resources') -File;" ^ "}" ^ "" ^ "foreach ($sourceFile in $sourceFiles) {" ^ " $targetFile = if ($sourceFile.DirectoryName -eq $buildDir) { Join-Path $targetDir $sourceFile.Name } else { Join-Path (Join-Path $targetDir 'resources') $sourceFile.Name };" ^ " if (-not (Test-Path $targetFile)) { throw ('Deployment verification failed: missing target file ' + $targetFile) }" ^ " $targetInfo = Get-Item $targetFile;" ^ " if ($sourceFile.Length -ne $targetInfo.Length -or $sourceFile.LastWriteTime -ne $targetInfo.LastWriteTime) {" ^ " throw ('Deployment verification failed for ' + $sourceFile.Name + ': source=' + $sourceFile.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss.fff') + ' (' + $sourceFile.Length + '), target=' + $targetInfo.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss.fff') + ' (' + $targetInfo.Length + ')');" ^ " }" ^ " Write-Host ('Verified ' + $sourceFile.Name + ': ' + $targetInfo.LastWriteTime.ToString('yyyy-MM-dd HH:mm:ss.fff'));" ^ "}" ^ "" ^ "Write-Host 'Plugin deployed successfully!';" if errorlevel 1 exit /b 1 exit /b 0