AL/New-ALAppDependency.ps1
function New-ALAppDependency { Param( [Parameter(Mandatory = $false)] [string]$SourcePath = (Get-Location), [Parameter(Mandatory = $true)] [guid]$Id, [Parameter(Mandatory = $true)] [string]$Name, [Parameter(Mandatory = $true)] [string]$Publisher, [Parameter(Mandatory = $true)] [string]$Version ) $compiler = Get-AppKeyValue -SourcePath $TestPath -KeyName 'runtime' $Dependency = New-Object PSObject if ($compiler -ge '4.3') { $Dependency | Add-Member -MemberType NoteProperty -Name id -Value $Id } else { $Dependency | Add-Member -MemberType NoteProperty -Name appId -Value $Id } $Dependency | Add-Member -MemberType NoteProperty -Name name -Value $Name $Dependency | Add-Member -MemberType NoteProperty -Name publisher -Value $Publisher $Dependency | Add-Member -MemberType NoteProperty -Name version -Value $Version $AppJson = Get-Content (Join-Path $SourcePath 'app.json') -Raw | ConvertFrom-Json if (!$AppJson.dependencies) { $AppJson.dependencies = @() } $AppJson.dependencies += $Dependency Set-Content (Join-Path $SourcePath 'app.json') (ConvertTo-Json $AppJson) } Export-ModuleMember -Function New-ALAppDependency |