AL/Get-AppKeyValue.ps1

<#
 .Synopsis
  Retrieves a value from the app.json
 .Description
  Retrieves a value from the app.json of the project
 .Parameter SourcePath
  Path to the current project
 .Parameter KeyName
  Name of the key the value should be retrieved from
 .Example
  $value = Get-AppKeyValue -SourcePath "C:\Install" -KeyName "publisher"
#>

function Get-AppKeyValue {
    Param(
        [Parameter(Mandatory=$false)]
        [string]$SourcePath = (Get-Location),
        [Parameter(Mandatory=$true)]
        [string]$KeyName
    )

    if (!(Test-Path (Join-Path $SourcePath 'app.json') -PathType Leaf)) {
        switch ($KeyName) {
            'publisher' {
                return (Import-Config).publisher
            }
            default {
                return ''
            }
        }
    }
    $JsonContent = Get-Content (Join-Path $SourcePath 'app.json') -Raw
    $Json = ConvertFrom-Json $JsonContent

    try {
        if ($null -ne  $Json.PSObject.Properties.Item($KeyName)) {
            return $Json.PSObject.Properties.Item($KeyName).Value
        }
        else {
            return ''
        }
    } catch {
        throw "Could not find $KeyName in app.json"
    }
}