瀏覽代碼

Test dylib copying

Ruben 7 月之前
父節點
當前提交
aa1555fbd2
共有 2 個文件被更改,包括 114 次插入5 次删除
  1. 66 4
      .github/workflows/BuildMacOS.yml
  2. 48 1
      Build/Build Avalonia.MacOS.ps1

+ 66 - 4
.github/workflows/BuildMacOS.yml

@@ -40,12 +40,43 @@ jobs:
             -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64" `
             -appVersion "${{steps.get-version.outputs.version}}"
         shell: pwsh
-        
+      
+      # Add debug step to check the build output directories for arm64
+      - name: Debug - List build output directories for arm64
+        run: |
+          echo "Contents of build output directory:"
+          ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64"
+          echo "Contents of .app/Contents/MacOS:"
+          ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS"
+          echo "Finding Magick.Native files in the repository:"
+          find "${{ github.workspace }}" -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "No Magick.Native arm64 dylib found"
+      
+      # Add step to ensure Magick.Native libs are in the app bundle for arm64
+      - name: Copy Magick.Native libraries for arm64
+        run: |
+          # Find the Magick.Native dylibs
+          MAGICK_NATIVE_PATH=$(find "${{ github.workspace }}" -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "")
+          
+          if [ ! -z "$MAGICK_NATIVE_PATH" ]; then
+            echo "Found Magick.Native dylib at: $MAGICK_NATIVE_PATH"
+          
+            # Copy to the app's MacOS directory
+            cp "$MAGICK_NATIVE_PATH" "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS/"
+          
+            # Verify the copy
+            echo "After copying, MacOS directory contains:"
+            ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS/"
+          else
+            echo "WARNING: Could not find Magick.Native-Q8-arm64.dylib file to copy"
+            echo "Checking in the nuget cache directory:"
+            find ~/.nuget -name "Magick.Native*arm64*.dylib" 2>/dev/null || echo "Not found in nuget cache"
+          fi
+      
       # Step 6: Create DMG for arm64
       - name: Create DMG for arm64
         run: |
           hdiutil create -volname "PicView" -srcfolder "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -ov -format UDZO "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg"
-        
+      
       # Step 7: Upload arm64 artifacts
       - name: Upload arm64 artifacts
         uses: actions/upload-artifact@v4
@@ -64,7 +95,38 @@ jobs:
             -outputPath "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64" `
             -appVersion "${{steps.get-version.outputs.version}}"
         shell: pwsh
-        
+      
+      # Add debug step to check the build output directories for x64
+      - name: Debug - List build output directories for x64
+        run: |
+          echo "Contents of build output directory:"
+          ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64"
+          echo "Contents of .app/Contents/MacOS:"
+          ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS"
+          echo "Finding Magick.Native files in the repository:"
+          find "${{ github.workspace }}" -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "No Magick.Native x64 dylib found"
+      
+      # Add step to ensure Magick.Native libs are in the app bundle for x64
+      - name: Copy Magick.Native libraries for x64
+        run: |
+          # Find the Magick.Native dylibs
+          MAGICK_NATIVE_PATH=$(find "${{ github.workspace }}" -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "")
+          
+          if [ ! -z "$MAGICK_NATIVE_PATH" ]; then
+            echo "Found Magick.Native dylib at: $MAGICK_NATIVE_PATH"
+          
+            # Copy to the app's MacOS directory
+            cp "$MAGICK_NATIVE_PATH" "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS/"
+          
+            # Verify the copy
+            echo "After copying, MacOS directory contains:"
+            ls -la "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS/"
+          else
+            echo "WARNING: Could not find Magick.Native-Q8-x64.dylib file to copy"
+            echo "Checking in the nuget cache directory:"
+            find ~/.nuget -name "Magick.Native*x64*.dylib" 2>/dev/null || echo "Not found in nuget cache"
+          fi
+      
       # Step 9: Create DMG for x64
       - name: Create DMG for x64
         run: |
@@ -78,4 +140,4 @@ jobs:
           path: |
             ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app
             ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64.dmg
-          retention-days: 14
+          retention-days: 14

+ 48 - 1
Build/Build Avalonia.MacOS.ps1

@@ -116,6 +116,46 @@ if (Test-Path $iconSource) {
     Copy-Item -Path $iconSource -Destination $resourcesPath
 }
 
+# Find and ensure Magick.Native is properly copied
+$magickNativeFile = if ($Platform -eq "arm64") { "Magick.Native-Q8-arm64.dylib" } else { "Magick.Native-Q8-x64.dylib" }
+
+# Check for Magick.Native in the temp build output
+$magickNativePath = Get-ChildItem -Path $tempBuildPath -Filter $magickNativeFile -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
+
+# If found in temp build path, make sure it's copied to MacOS folder and check permissions
+if ($magickNativePath) {
+    Write-Host "Found Magick.Native at $magickNativePath, ensuring it's in MacOS directory"
+    Copy-Item -Path $magickNativePath -Destination $macOSPath -Force
+} else {
+    # Try to find it elsewhere in the repository
+    $magickNativePath = Get-ChildItem -Path $PSScriptRoot -Filter $magickNativeFile -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName
+    
+    if ($magickNativePath) {
+        Write-Host "Found Magick.Native at $magickNativePath, copying to MacOS directory"
+        Copy-Item -Path $magickNativePath -Destination $macOSPath -Force
+    } else {
+        Write-Warning "Could not find $magickNativeFile anywhere! App may not function correctly."
+        
+        # Last resort: try NuGet cache
+        $nugetCachePath = if ($env:HOME) { Join-Path $env:HOME ".nuget" } else { Join-Path $env:USERPROFILE ".nuget" }
+        if (Test-Path $nugetCachePath) {
+            $magickNativePaths = Get-ChildItem -Path $nugetCachePath -Filter $magickNativeFile -Recurse -ErrorAction SilentlyContinue
+            if ($magickNativePaths) {
+                $latestMagickNative = $magickNativePaths | Sort-Object LastWriteTime -Descending | Select-Object -First 1
+                Write-Host "Found Magick.Native in NuGet cache at $($latestMagickNative.FullName), copying to MacOS directory"
+                Copy-Item -Path $latestMagickNative.FullName -Destination $macOSPath -Force
+            }
+        }
+    }
+}
+
+# After copying, verify the file exists in the MacOS directory
+if (Test-Path (Join-Path $macOSPath $magickNativeFile)) {
+    Write-Host "$magickNativeFile successfully copied to MacOS directory"
+} else {
+    Write-Warning "$magickNativeFile not found in MacOS directory after copy attempt"
+}
+
 # Remove PDB files
 Get-ChildItem -Path $macOSPath -Filter "*.pdb" -Recurse | Remove-Item -Force
 
@@ -131,6 +171,13 @@ if ($IsLinux -or $IsMacOS) {
         }
     }
     
+    # Specifically check for Magick.Native and ensure it's executable
+    $magickNativeInMacOS = Join-Path -Path $macOSPath -ChildPath $magickNativeFile
+    if (Test-Path $magickNativeInMacOS) {
+        Write-Host "Setting executable permission on $magickNativeInMacOS"
+        chmod +x $magickNativeInMacOS
+    }
+    
     # Set proper ownership and permissions for the entire .app bundle
     chmod -R 755 $appBundlePath
-}
+}