functions/appdev/Update-AppVersionAndRuntime.ps1

function Update-AppVersionAndRuntime {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$true)]
        [string]$AppJsonPath,

        [Parameter(Mandatory=$true)]
        [string]$Version,

        [Parameter(Mandatory=$false)]
        [string]$Runtime = ''
    )

    $jsonContent = Get-Content -Path $AppJsonPath -Raw | ConvertFrom-Json

    $jsonContent.version = $Version
    if ($Runtime -ne '')
    {
        $jsonContent.runtime = $Runtime
    }

    $jsonContent | ConvertTo-Json -Depth 10 | Set-Content -Path $AppJsonPath

    Write-Information "app.json updated to version: $($jsonContent.version) - runtime: $($jsonContent.runtime)"
}

# Example usage:
# Update-AppVersionAndRuntime -AppJsonPath path\to\your\app.json -Version '25.0.0.0' -Runtime '14.0'