[CmdletBinding()] param( [ValidateSet('Release','Debug')] [string]$Configuration = 'Release', [switch]$Clean ) $ErrorActionPreference = 'Stop' $Root = Split-Path -Parent $PSCommandPath $Solution = Join-Path $Root 'PlandentMstscScriptHook.sln' $Dist = Join-Path $Root 'dist' $Artifacts = Join-Path $Root 'artifacts' $GeneratedPayload = Join-Path $Root 'Configurator\Generated' function Find-MSBuild { $cmd = Get-Command msbuild.exe -ErrorAction SilentlyContinue if ($cmd) { return $cmd.Source } $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' if (Test-Path $vswhere) { $found = & $vswhere -latest -products * ` -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` -find 'MSBuild\**\Bin\MSBuild.exe' | Select-Object -First 1 if ($found) { return $found } } throw 'MSBuild wurde nicht gefunden. Visual Studio 2022 bzw. Build Tools mit Desktopentwicklung mit C++ installieren.' } if ($Clean) { Remove-Item $Artifacts -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $Dist -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $GeneratedPayload -Recurse -Force -ErrorAction SilentlyContinue } New-Item -ItemType Directory -Path $Dist -Force | Out-Null $MSBuild = Find-MSBuild Write-Host "[1/2] Native x64-Projektmappe neu bauen ($Configuration|x64)..." -ForegroundColor Cyan & $MSBuild $Solution /t:Rebuild /m /nologo "/p:Configuration=$Configuration" '/p:Platform=x64' if ($LASTEXITCODE -ne 0) { throw "Build fehlgeschlagen (ExitCode $LASTEXITCODE)." } $PluginDll = Join-Path $Artifacts "x64\$Configuration\PlandentMstscScriptHook.dll" $ConfiguratorExe = Join-Path $Artifacts "x64\$Configuration\PlandentMstscScriptHook.exe" $ServerTriggerExe = Join-Path $Artifacts "x64\$Configuration\PlandentRdpClientTrigger.exe" $SiominTriggerExe = Join-Path $Artifacts "x64\$Configuration\PlandentSiominClientTrigger.exe" foreach ($file in @($PluginDll, $ConfiguratorExe, $ServerTriggerExe, $SiominTriggerExe)) { if (-not (Test-Path $file)) { throw "Erwartete Build-Datei wurde nicht erzeugt: $file" } } Write-Host '[2/2] Verteilbare Dateien nach dist kopieren...' -ForegroundColor Cyan Copy-Item $ConfiguratorExe (Join-Path $Dist 'PlandentMstscScriptHook.exe') -Force Copy-Item $ServerTriggerExe (Join-Path $Dist 'PlandentRdpClientTrigger.exe') -Force Copy-Item $SiominTriggerExe (Join-Path $Dist 'PlandentSiominClientTrigger.exe') -Force Write-Host '' Write-Host 'Build erfolgreich:' -ForegroundColor Green Write-Host " Client: $(Join-Path $Dist 'PlandentMstscScriptHook.exe')" Write-Host " Server: $(Join-Path $Dist 'PlandentRdpClientTrigger.exe')" Write-Host " SIOMIN: $(Join-Path $Dist 'PlandentSiominClientTrigger.exe')" Write-Host '' Write-Host 'Alle Komponenten sind native x64-C++-Binaries; .NET/NuGet wird nicht benötigt.' Write-Host 'Die Client-EXE enthält die native MSTSC-Plugin-DLL als RCDATA-Resource.' Write-Host 'Die generische Server-EXE sendet ausschließlich den festen START-Trigger über den RDP-DVC.' Write-Host 'Die SIOMIN-EXE fragt den Client-Hostname über den DVC ab, passt die SDX bytegenau an und sendet danach START.'