52 lines
2.4 KiB
PowerShell
52 lines
2.4 KiB
PowerShell
param([string]$Configuration = "Release")
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$projectRoot = Split-Path -Parent $PSScriptRoot
|
|
$dotnet = Join-Path $env:USERPROFILE ".dotnet10\dotnet.exe"
|
|
$androidSdk = Join-Path $env:LOCALAPPDATA "Android\Sdk"
|
|
$keyStore = Join-Path $env:LOCALAPPDATA "Xamarin\Mono for Android\debug.keystore"
|
|
$outputDirectory = Join-Path $projectRoot "artifacts\android-test"
|
|
$projectPath = Join-Path $projectRoot "LMEMappeCatastaliApp.csproj"
|
|
[xml]$projectXml = Get-Content -Raw -LiteralPath $projectPath
|
|
$appVersion = ($projectXml.Project.PropertyGroup | Where-Object ApplicationDisplayVersion | Select-Object -First 1).ApplicationDisplayVersion
|
|
|
|
foreach ($requiredPath in @($dotnet, $androidSdk, $keyStore)) {
|
|
if (-not (Test-Path -LiteralPath $requiredPath)) { throw "Componente richiesto non trovato: $requiredPath" }
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
|
|
$packages = [System.Collections.Generic.List[System.IO.FileInfo]]::new()
|
|
foreach ($format in @("apk", "aab")) {
|
|
$publishArguments = @(
|
|
"publish", $projectPath,
|
|
"-f", "net10.0-android",
|
|
"-c", $Configuration,
|
|
"-p:AndroidSdkDirectory=$androidSdk",
|
|
"-p:AndroidPackageFormat=$format",
|
|
"-p:AndroidKeyStore=true",
|
|
"-p:AndroidSigningKeyStore=$keyStore",
|
|
"-p:AndroidSigningKeyAlias=androiddebugkey",
|
|
"-p:AndroidSigningStorePass=android",
|
|
"-p:AndroidSigningKeyPass=android"
|
|
)
|
|
& $dotnet @publishArguments
|
|
if ($LASTEXITCODE -ne 0) { throw "Pubblicazione Android $format non riuscita." }
|
|
|
|
$publishDirectory = Join-Path $projectRoot "bin\$Configuration\net10.0-android\publish"
|
|
$package = Get-ChildItem -LiteralPath $publishDirectory -Filter "*-Signed.$format" -File |
|
|
Sort-Object LastWriteTime -Descending |
|
|
Select-Object -First 1
|
|
if ($null -eq $package) { throw "Nessun pacchetto $format firmato prodotto." }
|
|
|
|
$destination = Join-Path $outputDirectory "LME-Mappe-Catastali-$appVersion.$format"
|
|
Copy-Item -LiteralPath $package.FullName -Destination $destination -Force
|
|
$packages.Add((Get-Item -LiteralPath $destination))
|
|
}
|
|
|
|
$packages | ForEach-Object {
|
|
$hash = Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName
|
|
"$($hash.Hash.ToLowerInvariant()) $($_.Name)"
|
|
} | Set-Content -LiteralPath (Join-Path $outputDirectory "SHA256SUMS.txt") -Encoding ascii
|
|
|
|
$packages | Select-Object Name, Length, LastWriteTime
|