ChangeX64-ARM64.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 references for x64 and arm64
  6. $packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
  7. $packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
  8. # Find the current package reference
  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 $packageRefArm64) {
  13. # Switch from arm64 to x64
  14. $packageNode.Include = $packageRefX64
  15. Write-Output "Switched arm64 -> x64"
  16. } elseif ($packageNode.Include -eq $packageRefX64) {
  17. # Switch from x64 to arm64
  18. $packageNode.Include = $packageRefArm64
  19. Write-Output "Switched x64 -> arm64"
  20. }
  21. }
  22. } else {
  23. Write-Output "No Magick.NET package references found. Adding a new one for arm64."
  24. # Add a new PackageReference if none exists
  25. $newNode = $coreCsproj.CreateElement("PackageReference")
  26. $newNode.SetAttribute("Include", $packageRefArm64)
  27. $coreCsproj.Project.ItemGroup[0].AppendChild($newNode) | Out-Null
  28. }
  29. # Save the updated .csproj file
  30. $coreCsproj.Save($coreProjectPath)