Build Avalonia.Win32.ps1 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. param (
  2. [Parameter()]
  3. [string]$Platform,
  4. [Parameter()]
  5. [string]$outputPath
  6. )
  7. # Define the core project path relative to the script's location
  8. $coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
  9. # Load the .csproj file as XML
  10. [xml]$coreCsproj = Get-Content $coreProjectPath
  11. # Define the package reference to replace
  12. $packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
  13. $packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
  14. # Find the Magick.NET package reference and update it based on the platform
  15. $packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
  16. if ($packageNodes) {
  17. foreach ($packageNode in $packageNodes) {
  18. if ($Platform -eq "arm64") {
  19. $packageNode.Include = $packageRefArm64
  20. } else {
  21. $packageNode.Include = $packageRefX64
  22. }
  23. }
  24. }
  25. # Save the updated .csproj file
  26. $coreCsproj.Save($coreProjectPath)
  27. # Define the project path for the actual build target
  28. $avaloniaProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj"
  29. # Run dotnet publish for the Avalonia project
  30. dotnet publish $avaloniaProjectPath --runtime "win-$Platform" --self-contained true --configuration Release --output $outputPath /p:PublishReadyToRun=true
  31. # Remove the PDB file
  32. $pdbPath = Join-Path -Path $outputPath -ChildPath "PicView.Avalonia.pdb"
  33. if (Test-Path $pdbPath) {
  34. Remove-Item -Path $pdbPath -Force
  35. }