[CmdletBinding()] param( [ValidateSet('Release','Debug')] [string]$Configuration = 'Release', [switch]$Clean ) $ErrorActionPreference = 'Stop' $Root = Split-Path -Parent $PSCommandPath $PluginProject = Join-Path $Root 'Plugin\PlandentMstscScriptHook.vcxproj' $ServerTriggerProject = Join-Path $Root 'ServerTrigger\PlandentRdpClientTrigger.vcxproj' $ConfiguratorProject = Join-Path $Root 'Configurator\Configurator.csproj' $Dist = Join-Path $Root 'dist' $Artifacts = Join-Path $Root 'artifacts' 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 } New-Item -ItemType Directory -Path $Dist -Force | Out-Null $MSBuild = Find-MSBuild Write-Host "[1/3] Native MSTSC Plugin-DLL bauen ($Configuration|x64)..." -ForegroundColor Cyan & $MSBuild $PluginProject /m /nologo "/p:Configuration=$Configuration" '/p:Platform=x64' if ($LASTEXITCODE -ne 0) { throw "Native DLL Build fehlgeschlagen (ExitCode $LASTEXITCODE)." } $PluginDll = Join-Path $Artifacts "x64\$Configuration\PlandentMstscScriptHook.dll" if (-not (Test-Path $PluginDll)) { throw "Erwartete DLL wurde nicht erzeugt: $PluginDll" } Write-Host "[2/3] Terminalserver-Trigger bauen ($Configuration|x64)..." -ForegroundColor Cyan & $MSBuild $ServerTriggerProject /m /nologo "/p:Configuration=$Configuration" '/p:Platform=x64' if ($LASTEXITCODE -ne 0) { throw "Server-Trigger Build fehlgeschlagen (ExitCode $LASTEXITCODE)." } $ServerTriggerExe = Join-Path $Artifacts "x64\$Configuration\PlandentRdpClientTrigger.exe" if (-not (Test-Path $ServerTriggerExe)) { throw "Erwartete Server-Trigger-EXE wurde nicht erzeugt: $ServerTriggerExe" } Copy-Item $ServerTriggerExe (Join-Path $Dist 'PlandentRdpClientTrigger.exe') -Force Write-Host "[3/3] Client-Konfigurations-EXE als x64 Single-File veröffentlichen..." -ForegroundColor Cyan & dotnet publish $ConfiguratorProject ` -c $Configuration ` -r win-x64 ` --self-contained true ` -p:Platform=x64 ` -p:PublishSingleFile=true ` -p:DebugType=embedded ` -p:DebugSymbols=false ` -o $Dist if ($LASTEXITCODE -ne 0) { throw "Configurator Publish fehlgeschlagen (ExitCode $LASTEXITCODE)." } $ConfiguratorExe = Join-Path $Dist 'PlandentMstscScriptHook.exe' if (-not (Test-Path $ConfiguratorExe)) { throw "Erwartete Konfigurations-EXE wurde nicht erzeugt: $ConfiguratorExe" } Write-Host '' Write-Host 'Build erfolgreich:' -ForegroundColor Green Write-Host " Client: $ConfiguratorExe" Write-Host " Server: $(Join-Path $Dist 'PlandentRdpClientTrigger.exe')" Write-Host '' Write-Host 'Die Client-EXE enthält die native MSTSC-Plugin-DLL als eingebettete Resource.' Write-Host 'Die Server-EXE sendet ausschließlich den festen START-Trigger über den RDP-DVC.'