Build Avalonia.Win32 x64.ps1 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Define the project path relative to the script's location
  2. $projectPath = Join-Path -Path $PSScriptRoot -ChildPath "..\src\PicView.Avalonia.Win32\PicView.Avalonia.Win32.csproj"
  3. # Load the .csproj file as XML and extract the AssemblyVersion
  4. $projectFile = [xml](Get-Content $projectPath)
  5. $assemblyVersion = $projectFile.Project.PropertyGroup.AssemblyVersion
  6. # Define the temporary output path using the system's temp folder
  7. $tempPath = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath "PicView"
  8. # Define the final output path relative to the script's location
  9. $outputPath = Join-Path -Path $PSScriptRoot -ChildPath "PicView-v.$assemblyVersion-win-x64"
  10. # Ensure the temp directory exists
  11. if (-Not (Test-Path $tempPath)) {
  12. New-Item -Path $tempPath -ItemType Directory | Out-Null
  13. }
  14. # Run dotnet publish
  15. dotnet publish $projectPath --runtime win-x64 --self-contained true --configuration Release --output $tempPath /p:PublishReadyToRun=true
  16. # Ensure the output directory exists and is empty
  17. if (Test-Path $outputPath) {
  18. Remove-Item -Path $outputPath -Recurse -Force
  19. }
  20. New-Item -Path $outputPath -ItemType Directory | Out-Null
  21. # Copy the build output to the final destination
  22. Copy-Item -Path "$tempPath\*" -Destination $outputPath -Recurse -Force
  23. # Remove the license file
  24. $licensePath = Join-Path -Path $outputPath -ChildPath "Licenses\XamlAnimatedGif LICENSE.txt"
  25. if (Test-Path $licensePath) {
  26. Remove-Item -Path $licensePath -Force
  27. }
  28. # Remove the PDB file
  29. $pdbPath = Join-Path -Path $outputPath -ChildPath "PicView.Avalonia.pdb"
  30. if (Test-Path $pdbPath) {
  31. Remove-Item -Path $pdbPath -Force
  32. }
  33. #Remove uninstended space
  34. Rename-Item -path $outputPath -NewName $outputPath.Replace(" ","")
  35. # Clean up the temporary directory
  36. Start-Sleep -Seconds 2
  37. Remove-Item -Path $tempPath -Recurse -Force