Build WPF arm64y.ps1 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Define the core project path relative to the script's location
  2. $coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
  3. # Load the .csproj file as XML
  4. [xml]$coreCsproj = Get-Content $coreProjectPath
  5. # Define the package reference to replace
  6. $packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
  7. $packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
  8. # Find the Magick.NET package reference and update it based on the platform
  9. $packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
  10. if ($packageNodes) {
  11. foreach ($packageNode in $packageNodes) {
  12. if ($packageNode.Include -eq $packageRefX64) {
  13. $packageNode.Include = $packageRefArm64
  14. # Save the updated .csproj file
  15. $coreCsproj.Save($coreProjectPath)
  16. Write-Output "Switched x64 -> arm64"
  17. }
  18. }
  19. }
  20. # Define the project path for the actual build target
  21. $projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.WPF\PicView.WPF.csproj"
  22. # Run dotnet publish for the project
  23. dotnet publish $projectPath --runtime win-arm64 --self-contained false --configuration Release --output "$PSScriptRoot/PicView-arm64" /p:PublishReadyToRun=true
  24. #Remove unintended space
  25. if (-not [string]::IsNullOrEmpty($outputPath)) {
  26. Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
  27. }