[CmdletBinding()] param( [ValidateSet('Release','Debug')] [string]$Configuration = 'Release', [switch]$Clean ) $ErrorActionPreference = 'Stop' $Root = Split-Path -Parent $PSCommandPath $PluginProject = Join-Path $Root 'Plugin\PlandentMstscScriptHook.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/2] 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/2] 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)." } $Exe = Join-Path $Dist 'PlandentMstscScriptHook.exe' if (-not (Test-Path $Exe)) { throw "Erwartete EXE wurde nicht erzeugt: $Exe" } Write-Host '' Write-Host 'Build erfolgreich:' -ForegroundColor Green Write-Host " $Exe" Write-Host '' Write-Host 'Diese EXE enthält die native DLL als eingebettete Resource.'