<#
.Synopsis
Use Nav Container to Compile App
.Description
.Parameter containerName
Name of the container which you want to use to compile the app
.Parameter tenant
tenant to use if container is multitenant
.Parameter credential
Credentials of the NAV SUPER user if using NavUserPassword authentication
.Parameter appProjectFolder
Location of the project. This folder (or any of its parents) needs to be shared with the container.
.Parameter appOutputFolder
Folder in which the output will be placed. This folder (or any of its parents) needs to be shared with the container. Default is $appProjectFolder\output.
.Parameter appSymbolsFolder
Folder in which the symbols of dependent apps will be placed. This folder (or any of its parents) needs to be shared with the container. Default is $appProjectFolder\symbols.
.Parameter UpdateSymbols
Add this switch to indicate that you want to force the download of symbols for all dependent apps.
.Parameter AzureDevOps
Add this switch to convert the output to Azure DevOps Build Pipeline compatible output
.Parameter EnableCodeCop
Add this switch to Enable CodeCop to run
.Parameter Failon
Specify if you want Compilation to fail on Error or Warning (Works only if you specify -AzureDevOps)
.Example
Compile-AppInNavContainer -containerName test -credential $credential -appProjectFolder "C:\Users\freddyk\Documents\AL\Test"
.Example
Compile-AppInNavContainer -containerName test -appProjectFolder "C:\Users\freddyk\Documents\AL\Test"

$containerProjectFolder=Get-NavContainerPath-containerName$containerName-path$appProjectFolderif("$containerProjectFolder"-eq""){throw"The appProjectFolder ($appProjectFolder) is not shared with the container."}

$containerOutputFolder=Get-NavContainerPath-containerName$containerName-path$appOutputFolderif("$containerOutputFolder"-eq""){throw"The appOutputFolder ($appOutputFolder) is not shared with the container."}

$containerSymbolsFolder=Get-NavContainerPath-containerName$containerName-path$appSymbolsFolderif("$containerSymbolsFolder"-eq""){throw"The appSymbolsFolder ($appSymbolsFolder) is not shared with the container."}

$authParam=@{}if($credential){if($auth-eq"Windows"){Throw"You should not specify credentials when using Windows Authentication"}$pair=("$($Credential.UserName):"+[System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)))$bytes=[System.Text.Encoding]::ASCII.GetBytes($pair)$base64=[System.Convert]::ToBase64String($bytes)$basicAuthValue="Basic $base64"$headers=@{Authorization=$basicAuthValue}$authParam+=@{"headers"=$headers}}else{if($auth-ne"Windows"){Throw"You need to specify credentials when you are not using Windows Authentication"}$authParam+=@{"usedefaultcredential"=$true}}