Build/Release-AppToFTP.ps1

function Release-AppToFTP{
    Param(
        [Parameter(Mandatory=$true)]
        [string]$AppName,    
        [Parameter(Mandatory=$true)]
        [string]$AppDirectory,
        [Parameter(Mandatory=$true)]
        [version]$PlatformVersion
    )
    $TargetFolder = Get-FolderForPlatformVersion $PlatformVersion
    $Apps = (Get-ChildItem $AppDirectory -Filter '*.app') -match $AppName
    foreach ($App in $Apps)
    {
        if (!$App.Name.Contains('Tests'))
        {
            Move-AppToArchive -AppName $AppName -PlatformVersion $PlatformVersion
            Write-Host 'Uploading ' $App ' to ' $TargetFolder
            Put-ItemFtp -LocalPath $App.FullName -FtpPath $TargetFolder
        }
    }   
}

function Move-AppToArchive{
    Param(
        [Parameter(Mandatory=$true)]
        [string]$AppName,
        [Parameter(Mandatory=$true)]
        [version]$PlatformVersion
    )
    $FolderName = Get-FolderForPlatformVersion $PlatformVersion
    $AppFiles = (Get-ChildItemFTP $FolderName) -match $AppName
    foreach($AppFile in $AppFiles){
        Write-Host 'Moving '$AppFile' to Archive'
        Rename-ItemFTP -OldPath $FolderName -Name $AppFile -NewPath 'Archive'       
    }
}

function Get-FolderForPlatformVersion{
    Param(
        [Parameter(Mandatory=$true)]
        [version]$PlatformVersion
    )

    'Business Central ' + $PlatformVersion.Major;
}

Export-ModuleMember -Function Release-AppToFTP