param([string]$BuildFolder = 'Release', [switch]$ProtocolOnly) if ($PSVersionTable.PSEdition -ne 'Desktop') { # DCT_test is a .NET Framework/WPF binary. PowerShell 7 cannot reference # its mscorlib-based types from Add-Type, so transparently re-run this # verifier in the inbox Windows PowerShell 5.1 host. $legacyPowerShell = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' if (-not (Test-Path -LiteralPath $legacyPowerShell)) { throw 'Windows PowerShell 5.1 is required to run Verify-Transport.ps1.' } $arguments = @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', $PSCommandPath, '-BuildFolder', $BuildFolder) if ($ProtocolOnly) { $arguments += '-ProtocolOnly' } & $legacyPowerShell @arguments exit $LASTEXITCODE } $ErrorActionPreference = 'Stop' Add-Type -AssemblyName PresentationFramework $transportAssembly = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot "DCT_test/bin/$BuildFolder/DCT_test.exe")) $transportLoaded = [Reflection.Assembly]::LoadFrom($transportAssembly) # Add-Type resolves a full file path as an assembly *name* on Windows # PowerShell and reports 0x80131047 for this legacy .NET Framework EXE. # Reuse the already loaded assembly identity instead, along with the two # framework references used by the helper source. Add-Type -Path (Join-Path $PSScriptRoot 'Verify-Transport.cs') ` -ReferencedAssemblies @($transportLoaded.FullName, 'System.dll', 'System.Core.dll') if ($ProtocolOnly) { [DCT_test.TransportRegression]::RunCurrentAppCompatibility() } else { [DCT_test.TransportRegression]::Run() }