AL/Remove-ALTestDependencies.ps1

function Remove-ALTestDependencies {
    Param(
        [Parameter(Mandatory=$false)]
        [string] $sourcePath = (Get-Location)
    )

    $testapps = Get-EnvironmentKeyValue -SourcePath $sourcePath -KeyName "testapps"
    $dependencies = Get-AppKeyValue -SourcePath $sourcePath -KeyName "dependencies"

    [Version]$PlatformVersion = [Version]::Parse((Get-AppKeyValue -SourcePath (Get-Location) -KeyName 'platform'))
    if ($PlatformVersion -ge ([Version]::Parse('15.0.0.0'))) {
        try {
            $dependencies = $dependencies | Where-Object {$testapps.appId -notcontains $_.appId}
            Set-AppKeyValue -SourcePath $sourcePath -KeyName "dependencies" -KeyValue $dependencies #(ConvertTo-Json $dependencies -Compress)
        } catch {
            throw "Could not remove test dependencies"
        }
    }
    else {
        Set-AppKeyValue -KeyName test -KeyValue ''    
    }
}
Export-ModuleMember Remove-ALTestDependencies