[CmdletBinding()] param([switch] $Test, [switch] $TestDatabase) $ErrorActionPreference = 'Stop' $source = $PSScriptRoot $dist = Join-Path $source 'dist' $package = Join-Path $dist 'SE-LTD-Setup' $archive = Join-Path $dist 'SE-LTD-Setup.zip' $framework = Join-Path $env:WINDIR 'Microsoft.NET' $csc = @('Framework64', 'Framework') | ForEach-Object { Join-Path $framework "$_\v4.0.30319\csc.exe" } | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1 if (-not $csc) { throw 'Der .NET-Framework-C#-Compiler fehlt.' } New-Item -ItemType Directory -Force -Path $package | Out-Null $exe = Join-Path $package 'SE-LTD-Setup.exe' $arguments = @( '/nologo', '/target:winexe', '/platform:anycpu', '/optimize+', '/codepage:65001', "/out:$exe", '/reference:System.Windows.Forms.dll', '/reference:System.Drawing.dll', '/reference:System.Web.Extensions.dll', (Join-Path $source 'SetupEngine.cs'), (Join-Path $source 'SetupWizard.cs') ) & $csc @arguments if ($LASTEXITCODE -ne 0) { throw 'SE-LTD Setup konnte nicht kompiliert werden.' } if ($Test -or $TestDatabase) { $testExe = Join-Path $dist 'SE-LTD-Setup-SmokeTests.exe' $testArguments = @( '/nologo', '/target:exe', '/codepage:65001', '/main:SeLtd.Setup.SetupSmokeTests', "/out:$testExe", '/reference:System.Windows.Forms.dll', '/reference:System.Drawing.dll', '/reference:System.Web.Extensions.dll', (Join-Path $source 'SetupEngine.cs'), (Join-Path $source 'SetupWizard.cs'), (Join-Path $source 'SetupSmokeTests.cs') ) & $csc @testArguments if ($LASTEXITCODE -ne 0) { throw 'Der Setup-Test konnte nicht kompiliert werden.' } if ($TestDatabase) { & $testExe $source --database } else { & $testExe $source } if ($LASTEXITCODE -ne 0) { throw 'Der Setup-Test ist fehlgeschlagen.' } } $files = 'setup.config.json', 'compose.override.template.yml', 'README.md' | ForEach-Object { Copy-Item -LiteralPath (Join-Path $source $_) -Destination $package -Force Join-Path $package $_ } Compress-Archive -Path (@($exe) + $files) -DestinationPath $archive -Force Get-Item -LiteralPath $exe, $archive