33 [string ]$Platform ,
44
55 [Parameter ()]
6- [string ]$outputPath
6+ [string ]$outputPath ,
7+
8+ [Parameter ()]
9+ [string ]$appVersion
710)
811
912# Define the core project path relative to the script's location
@@ -34,24 +37,81 @@ $coreCsproj.Save($coreProjectPath)
3437# Define the project path for the actual build target
3538$avaloniaProjectPath = Join-Path - Path $PSScriptRoot - ChildPath " ../src/PicView.Avalonia.MacOS/PicView.Avalonia.MacOS.csproj"
3639
40+ # Create temporary build output directory
41+ $tempBuildPath = Join-Path - Path $outputPath - ChildPath " temp"
42+ New-Item - ItemType Directory - Force - Path $tempBuildPath
43+
3744# Run dotnet publish for the Avalonia project
3845dotnet publish $avaloniaProjectPath `
3946 -- runtime " osx-$Platform " `
4047 -- self- contained true `
4148 -- configuration Release `
4249 - p:PublishSingleFile= false `
43- -- output $outputPath
50+ -- output $tempBuildPath
51+
52+ # Create .app bundle structure
53+ $appBundlePath = Join-Path - Path $outputPath - ChildPath " PicView.app"
54+ $contentsPath = Join-Path - Path $appBundlePath - ChildPath " Contents"
55+ $macOSPath = Join-Path - Path $contentsPath - ChildPath " MacOS"
56+ $resourcesPath = Join-Path - Path $contentsPath - ChildPath " Resources"
57+
58+ # Create directory structure
59+ New-Item - ItemType Directory - Force - Path $macOSPath
60+ New-Item - ItemType Directory - Force - Path $resourcesPath
61+
62+ # Create Info.plist
63+ $infoPlistContent = @"
64+ <?xml version="1.0" encoding="UTF-8"?>
65+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
66+ <plist version="1.0">
67+ <dict>
68+ <key>CFBundleName</key>
69+ <string>PicView</string>
70+ <key>CFBundleDisplayName</key>
71+ <string>PicView</string>
72+ <key>CFBundleIdentifier</key>
73+ <string>com.ruben2776.picview</string>
74+ <key>CFBundleVersion</key>
75+ <string>${appVersion} </string>
76+ <key>CFBundlePackageType</key>
77+ <string>APPL</string>
78+ <key>CFBundleSignature</key>
79+ <string>picview.org</string>
80+ <key>CFBundleExecutable</key>
81+ <string>PicView.Avalonia.MacOS</string>
82+ <key>CFBundleIconFile</key>
83+ <string>AppIcon.icns</string>
84+ <key>CFBundleShortVersionString</key>
85+ <string>${appVersion} </string>
86+ <key>LSMinimumSystemVersion</key>
87+ <string>10.15</string>
88+ <key>NSHighResolutionCapable</key>
89+ <true/>
90+ </dict>
91+ </plist>
92+ "@
93+
94+ # Save Info.plist
95+ $infoPlistPath = Join-Path - Path $contentsPath - ChildPath " Info.plist"
96+ $infoPlistContent | Out-File - FilePath $infoPlistPath - Encoding UTF8
4497
45- # Remove the PDB file
46- $pdbPath = Join-Path - Path $outputPath - ChildPath " PicView.Avalonia.pdb"
47- if (Test-Path $pdbPath ) {
48- Remove-Item - Path $pdbPath - Force
98+ # Copy build output to MacOS directory
99+ Copy-Item - Path " $tempBuildPath /*" - Destination $macOSPath - Recurse
100+
101+ # Copy icon if it exists (you'll need to create this)
102+ $iconSource = Join-Path - Path $PSScriptRoot - ChildPath " ../src/PicView.Avalonia.MacOS/Assets/AppIcon.icns"
103+ if (Test-Path $iconSource ) {
104+ Copy-Item - Path $iconSource - Destination $resourcesPath
49105}
50106
51- # Remove unintended space
52- if (Test-Path $outputPath ) {
53- $newPath = $outputPath.Replace (" " , " " )
54- if ($outputPath -ne $newPath ) {
55- Rename-Item - Path $outputPath - NewName $newPath - Force
56- }
107+ # Remove PDB files
108+ Get-ChildItem - Path $macOSPath - Filter " *.pdb" - Recurse | Remove-Item - Force
109+
110+ # Remove temporary build directory
111+ Remove-Item - Path $tempBuildPath - Recurse - Force
112+
113+ # Set executable permissions on the main binary
114+ if ($IsLinux -or $IsMacOS ) {
115+ $mainBinary = Join-Path - Path $macOSPath - ChildPath " PicView.Avalonia.MacOS"
116+ chmod + x $mainBinary
57117}
0 commit comments