Created
October 4, 2022 19:44
-
-
Save J-Swift/096d5425b8f2404c3beea0361ca98877 to your computer and use it in GitHub Desktop.
Generate an ipa/dsyms in Maui
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
param( | |
[Parameter(Mandatory = $true)][string] $AppName, | |
[Parameter(Mandatory = $true)][int] $BuildNumber | |
) | |
$ErrorActionPreference = 'Stop' | |
$outDir = Join-Path '.' 'artifacts' 'ios' | |
$projectDirs = Get-ChildItem . -Name *.csproj -Recurse | Split-Path | |
$formattedDate = (Get-Date -Format "yyyyMMdd_hhmmssZ").ToString() | |
######### | |
# Clean # | |
######### | |
if (Test-Path $outDir -PathType Container) { | |
Remove-Item (Join-Path $outDir '*') -Recurse -Force | |
} | |
dotnet clean | |
########### | |
# Restore # | |
########### | |
foreach ($dir in $projectDirs) { | |
$target = (Join-Path '.' $dir 'bin' 'Adhoc') | |
if (Test-Path $target -PathType Container) { | |
Remove-Item $target -Recurse -Force | |
} | |
$target = (Join-Path '.' $dir 'bin' 'Release') | |
if (Test-Path $target -PathType Container) { | |
Remove-Item $target -Recurse -Force | |
} | |
} | |
################## | |
# Build and copy # | |
################## | |
dotnet build (Join-Path 'Apps' $AppName) ` | |
-t:Build -c:Release -p:Adhoc=True -p:ApplicationVersion=$BuildNumber ` | |
-f:net6.0-ios -p:BuildIpa=True -p:Platform=iPhone -p:RuntimeIdentifier=ios-arm64 ` | |
-p:OutputPath='bin/Adhoc/' -p:TreatWarningsAsErrors=False | |
New-Item -ItemType "directory" (Join-Path $outDir 'adhoc') | |
$opts = @{ | |
CompressionLevel = "Fastest" | |
Path = Join-Path '.' 'Apps' $AppName 'bin' 'Adhoc' "$AppName.app" | |
DestinationPath = Join-Path $outDir 'adhoc' "${AppName}_${formattedDate}.zip" | |
DSymPath = Join-Path '.' 'Apps' $AppName 'bin' 'Adhoc' "$AppName.app.dSYM" | |
DSymDestinationPath = Join-Path $outDir 'adhoc' "${AppName}.app.dSYM" | |
} | |
Compress-Archive -CompressionLevel $opts.CompressionLevel -Path $opts.Path -DestinationPath $opts.DestinationPath | |
Copy-Item -Recurse -Path $opts.DSymPath -Destination $opts.DSymDestinationPath | |
Copy-Item -Path (Join-Path '.' 'Apps' $AppName 'bin' 'Adhoc' "$AppName.ipa") -Destination (Join-Path $outDir 'adhoc' "$AppName.ipa") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment