build.ps1 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. param([string]$rid = 'all')
  2. $ErrorActionPreference = 'Stop'
  3. Write-Host 'dotnet SDK info'
  4. dotnet --info
  5. $proj = 'NatTypeTester'
  6. $exe = "$proj.exe"
  7. $net_tfm = 'net6.0-windows10.0.22000.0'
  8. $configuration = 'Release'
  9. $output_dir = "$PSScriptRoot\$proj\bin\$configuration"
  10. $proj_path = "$PSScriptRoot\$proj\$proj.csproj"
  11. $dllpatcher_tfm = 'net6.0'
  12. $dllpatcher_dir = "$PSScriptRoot\Build\DotNetDllPathPatcher"
  13. $dllpatcher_exe = "$dllpatcher_dir\bin\$configuration\$dllpatcher_tfm\DotNetDllPathPatcher.exe"
  14. function Build-Generic
  15. {
  16. Write-Host 'Building generic'
  17. $outdir = "$output_dir\$net_tfm\generic"
  18. $publishDir = "$outdir\publish"
  19. Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore
  20. dotnet publish -c $configuration -f $net_tfm $proj_path -o $publishDir
  21. if ($LASTEXITCODE) { exit $LASTEXITCODE }
  22. & "$dllpatcher_exe" "$publishDir\$exe" bin
  23. if ($LASTEXITCODE) { exit $LASTEXITCODE }
  24. }
  25. function Build-SelfContained
  26. {
  27. param([string]$rid)
  28. Write-Host "Building $rid"
  29. $outdir = "$output_dir\$net_tfm\$rid"
  30. $publishDir = "$outdir\publish"
  31. Remove-Item $publishDir -Recurse -Force -Confirm:$false -ErrorAction Ignore
  32. dotnet publish -c $configuration -f $net_tfm -r $rid --self-contained true $proj_path
  33. if ($LASTEXITCODE) { exit $LASTEXITCODE }
  34. & "$dllpatcher_exe" "$publishDir\$exe" bin
  35. if ($LASTEXITCODE) { exit $LASTEXITCODE }
  36. }
  37. dotnet build -c $configuration -f $dllpatcher_tfm $dllpatcher_dir\DotNetDllPathPatcher.csproj
  38. if ($LASTEXITCODE) { exit $LASTEXITCODE }
  39. if($rid -eq 'all' -or $rid -eq 'generic')
  40. {
  41. Build-Generic
  42. }
  43. if($rid -eq 'all')
  44. {
  45. Build-SelfContained win-x86
  46. Build-SelfContained win-x64
  47. Build-SelfContained win-arm64
  48. }
  49. elseif($rid -ne 'generic')
  50. {
  51. Build-SelfContained $rid
  52. }