浏览代码

Update build scripts

Ruben 11 月之前
父节点
当前提交
088e13c95a

+ 17 - 7
.github/workflows/TestSignWindows.yaml

@@ -21,7 +21,9 @@ jobs:
       # Step 4 (x64): Publish x64 version
       - name: Publish x64 version
         run: |
-          pwsh -File "${{ github.workspace }}\Build\Build WPF.ps1" -Platform "x64" -selfContained $true -outputPath "${{ github.workspace }}\Build\PicView-v${{steps.get-version.outputs.version}}-win-x64"
+          $projectPath = ".\src\PicView.WPF\PicView.WPF.csproj"
+          $tempPath = [System.IO.Path]::GetTempPath() + "PicView"
+          dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output $tempPath /p:PublishReadyToRun=true
         shell: pwsh
 
       # Step 5 (x64): Compile .ISS to .EXE Installer for x64
@@ -31,14 +33,22 @@ jobs:
           path: .\Build\install.iss
           options: /O+ /DMyAppVersion=${{steps.get-version.outputs.file-version}} /DMyAppOutputDir=${{ github.workspace }}\Build\install /DMyFileSource=${{ github.workspace }}\Build\PicView-v${{steps.get-version.outputs.version}}-win-x64 /DAppIcon=${{ github.workspace }}\src\PicView.WPF\Themes\Resources\img\icon__Q6k_icon.ico /DLicenseFile=${{ github.workspace }}\src\PicView.Core\Licenses\LICENSE.txt /DMyAppOutputName=Setup-PicView-v${{steps.get-version.outputs.version}}-win-x64
 
-      # Step 6 (arm64): Publish arm64 version
+      # Step 6 change to arm64 version
       - name: Publish arm64 version
         run: |
-          pwsh -File "${{ github.workspace }}\Build\Build WPF.ps1" -Platform "arm64" -selfContained $true -outputPath "${{ github.workspace }}\Build\PicView-v${{steps.get-version.outputs.version}}-win-arm64"
+          pwsh -File "${{ github.workspace }}\Build\ChangeX64-ARM64.ps1"
+        shell: pwsh
+
+    # Step 7 (arm64): Publish x64 version
+      - name: Publish arm64 version
+        run: |
+          $projectPath = ".\src\PicView.WPF\PicView.WPF.csproj"
+          $tempPath = [System.IO.Path]::GetTempPath() + "PicView"
+          dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output $tempPath /p:PublishReadyToRun=true
         shell: pwsh
 
 
-      # Step 7 (arm64): Compile .ISS to .EXE Installer for arm64
+      # Step 8 (arm64): Compile .ISS to .EXE Installer for arm64
       - name: Compile .ISS to .EXE Installer (arm64)
         uses: Minionguyjpro/[email protected]
         with:
@@ -46,7 +56,7 @@ jobs:
           options: /O+ /DMyAppVersion=${{steps.get-version.outputs.file-version}} /DMyAppOutputDir=${{ github.workspace }}\Build\install /DMyFileSource=${{ github.workspace }}\Build\PicView-v${{steps.get-version.outputs.version}}-win-arm64 /DAppIcon=${{ github.workspace }}\src\PicView.WPF\Themes\Resources\img\icon__Q6k_icon.ico /DLicenseFile=${{ github.workspace }}\src\PicView.Core\Licenses\LICENSE.txt /DMyAppOutputName=Setup-PicView-v${{steps.get-version.outputs.version}}-win-arm64
 
 
-      # Step 8: Upload unsigned artifact
+      # Step 9: Upload unsigned artifact
       - name: upload-unsigned-artifact
         id: upload-unsigned-artifact
         uses: actions/upload-artifact@v4
@@ -60,7 +70,7 @@ jobs:
             ${{ github.workspace }}\Build\install\Setup-PicView-v${{steps.get-version.outputs.version}}-win-arm64.exe
           retention-days: 1
             
-      # Step 9: Sign the binaries
+      # Step 10: Sign the binaries
       - name: Sign files
         uses: signpath/github-action-submit-signing-request@v1
         with:
@@ -72,7 +82,7 @@ jobs:
           wait-for-completion: true
           output-artifact-directory: 'PicView-${{steps.get-version.outputs.version}}-signed'
 
-      # Step 10: Upload signed binaries
+      # Step 11: Upload signed binaries
       - name: upload-signed-artifact
         uses: actions/upload-artifact@v4
         with:

+ 8 - 26
Build/Build WPF.ps1 → Build/Build WPF arm64 self contained.ps1

@@ -1,15 +1,4 @@
-param (
-    [Parameter(Mandatory=$True)]
-    [string]$platform,
-    
-    [Parameter(Mandatory=$True)]
-    [string]$outputPath,
-
-    [Parameter(Mandatory=$True)]
-    [string]$selfContained
-)
-
-# Define the core project path relative to the script's location
+# Define the core project path relative to the script's location
 $coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
 
 # Load the .csproj file as XML
@@ -23,31 +12,24 @@ $packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
 $packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
 if ($packageNodes) {
     foreach ($packageNode in $packageNodes) {
-        if ($platform -eq "arm64") {
+        if ($packageNode.Include -eq $packageRefX64) {
             $packageNode.Include = $packageRefArm64
-        } else {
-            $packageNode.Include = $packageRefX64
+
+            # Save the updated .csproj file
+            $coreCsproj.Save($coreProjectPath)
+
+            Write-Output "Switched x64 -> arm64"
         }
     }
 }
 
-# Save the updated .csproj file
-$coreCsproj.Save($coreProjectPath)
-
 # Define the project path for the actual build target
 $projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.WPF\PicView.WPF.csproj"
 
-# Ensure the output path exists
-if (-not (Test-Path $outputPath)) {
-    New-Item -Path $outputPath -ItemType Directory
-}
-
 # Run dotnet publish for the project
-dotnet publish $projectPath --runtime win-$platform --self-contained $selfContained --configuration Release --output $outputPath /p:PublishReadyToRun=true
+dotnet publish $projectPath --runtime win-arm64 --self-contained true --configuration Release --output "$PSScriptRoot/PicView-arm64-self-contained" /p:PublishReadyToRun=true
 
 #Remove unintended space
 if (-not [string]::IsNullOrEmpty($outputPath)) {
     Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
-} else {
-    Write-Host "Output path is null or empty."
 }

+ 35 - 0
Build/Build WPF arm64y.ps1

@@ -0,0 +1,35 @@
+# Define the core project path relative to the script's location
+$coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
+
+# Load the .csproj file as XML
+[xml]$coreCsproj = Get-Content $coreProjectPath
+
+# Define the package reference to replace
+$packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
+$packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
+
+# Find the Magick.NET package reference and update it based on the platform
+$packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
+if ($packageNodes) {
+    foreach ($packageNode in $packageNodes) {
+        if ($packageNode.Include -eq $packageRefX64) {
+            $packageNode.Include = $packageRefArm64
+
+            # Save the updated .csproj file
+            $coreCsproj.Save($coreProjectPath)
+
+            Write-Output "Switched x64 -> arm64"
+        }
+    }
+}
+
+# Define the project path for the actual build target
+$projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.WPF\PicView.WPF.csproj"
+
+# Run dotnet publish for the project
+dotnet publish $projectPath --runtime win-arm64 --self-contained false --configuration Release --output "$PSScriptRoot/PicView-arm64" /p:PublishReadyToRun=true
+
+#Remove unintended space
+if (-not [string]::IsNullOrEmpty($outputPath)) {
+    Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
+}

+ 35 - 0
Build/Build WPF x64 self contained.ps1

@@ -0,0 +1,35 @@
+# Define the core project path relative to the script's location
+$coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
+
+# Load the .csproj file as XML
+[xml]$coreCsproj = Get-Content $coreProjectPath
+
+# Define the package reference to replace
+$packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
+$packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
+
+# Find the Magick.NET package reference and update it based on the platform
+$packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
+if ($packageNodes) {
+    foreach ($packageNode in $packageNodes) {
+        if ($packageNode.Include -eq $packageRefArm64) {
+            $packageNode.Include = $packageRefX64
+
+            # Save the updated .csproj file
+            $coreCsproj.Save($coreProjectPath)
+
+            Write-Output "Switched arm64 -> x64"
+        }
+    }
+}
+
+# Define the project path for the actual build target
+$projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.WPF\PicView.WPF.csproj"
+
+# Run dotnet publish for the project
+dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output "$PSScriptRoot/PicView-x64-self-contained" /p:PublishReadyToRun=true
+
+#Remove unintended space
+if (-not [string]::IsNullOrEmpty($outputPath)) {
+    Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
+}

+ 35 - 0
Build/Build WPF x64.ps1

@@ -0,0 +1,35 @@
+# Define the core project path relative to the script's location
+$coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
+
+# Load the .csproj file as XML
+[xml]$coreCsproj = Get-Content $coreProjectPath
+
+# Define the package reference to replace
+$packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
+$packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
+
+# Find the Magick.NET package reference and update it based on the platform
+$packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
+if ($packageNodes) {
+    foreach ($packageNode in $packageNodes) {
+        if ($packageNode.Include -eq $packageRefArm64) {
+            $packageNode.Include = $packageRefX64
+
+            # Save the updated .csproj file
+            $coreCsproj.Save($coreProjectPath)
+
+            Write-Output "Switched arm64 -> x64"
+        }
+    }
+}
+
+# Define the project path for the actual build target
+$projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.WPF\PicView.WPF.csproj"
+
+# Run dotnet publish for the project
+dotnet publish $projectPath --runtime win-x64 --self-contained false --configuration Release --output "$PSScriptRoot/PicView-x64" /p:PublishReadyToRun=true
+
+#Remove unintended space
+if (-not [string]::IsNullOrEmpty($outputPath)) {
+    Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
+}

+ 28 - 0
Build/ChangeX64-ARM64.ps1

@@ -0,0 +1,28 @@
+# Define the core project path relative to the script's location
+$coreProjectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Core\PicView.Core.csproj"
+
+# Load the .csproj file as XML
+[xml]$coreCsproj = Get-Content $coreProjectPath
+
+# Define the package reference to replace
+$packageRefX64 = "Magick.NET-Q8-OpenMP-x64"
+$packageRefArm64 = "Magick.NET-Q8-OpenMP-arm64"
+
+# Find the Magick.NET package reference and update it based on the platform
+$packageNodes = $coreCsproj.Project.ItemGroup.PackageReference | Where-Object { $_.Include -eq $packageRefX64 -or $_.Include -eq $packageRefArm64 }
+if ($packageNodes) {
+    foreach ($packageNode in $packageNodes) {
+        if ($packageNode.Include -eq $packageRefArm64) {
+            $packageNode.Include = $packageRefX64
+            Write-Output "Switched arm64 -> x64"
+        } elseif ($packageNode.Include -eq $packageRefX64) {
+            $packageNode.Include = $packageRefArm64
+            Write-Output "Switched x64 -> arm64"
+        } else {
+            Write-Output "No matching PackageReference found."
+        }
+    }
+}
+
+# Save the updated .csproj file
+$coreCsproj.Save($coreProjectPath)