functions/appdev/Invoke-CompileBcApp.ps1
function Invoke-CompileBcApp { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string]$AppSourcePath, [Parameter(Mandatory=$false)] [string]$SourceRepositoryUrl, [Parameter(Mandatory=$false)] [string]$SourceCommit, [Parameter(Mandatory=$false)] [string]$BuildBy, [Parameter(Mandatory=$false)] [string]$BuildUrl, [Parameter(Mandatory=$true)] [string]$AlpackagesDirectory, [Parameter(Mandatory=$true)] [string]$VsixPath, [switch]$EnableAppSourceCop, [switch]$EnablePerTenantExtensionCop, [Parameter(Mandatory=$false)] [string[]]$Features, [Parameter(Mandatory=$false)] [string[]]$PreprocessorSymbols = @(), [Parameter(Mandatory=$false)] [string]$RuleSetFilePath, [Parameter(Mandatory=$false)] [string[]]$AssemblyProbingPaths, [Parameter(Mandatory=$false)] [string]$ErrorLogFilePath ) $VsixBinPath = (Join-Path $VsixPath 'extension\bin') $AlcPath = Join-Path $VsixBinPath 'win32' if (-not (Test-Path $AlcPath)) { $AlcPath = $VsixBinPath } $AlcOutFile = (Join-Path $Env:TEMP 'app.app') if (Test-Path -Path $AlcOutFile -PathType Leaf) { Remove-Item -Path $AlcOutFile -Force } Set-Location -Path $AlcPath $AlcExe = Get-Item -Path (Join-Path $AlcPath 'alc.exe') $CompilerParameter = @("/project:""$($AppSourcePath.TrimEnd('/\'))""", "/packagecachepath:""$($AlpackagesDirectory.TrimEnd('/\'))""", "/out:""$AlcOutFile""") $CompilerParameter += @("/analyzer:$(Join-Path $VsixBinPath 'Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll')") $CompilerParameter += @("/analyzer:$(Join-Path $VsixBinPath 'Analyzers\Microsoft.Dynamics.Nav.UICop.dll')") if ($EnableAppSourceCop) { $CompilerParameter += @("/analyzer:$(Join-Path $VsixBinPath 'Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll')") } if ($EnablePerTenantExtensionCop) { $CompilerParameter += @("/analyzer:$(Join-Path $VsixBinPath 'Analyzers\Microsoft.Dynamics.Nav.PerTenantExtensionCop.dll')") } if ($RuleSetFilePath) { $CompilerParameter += @("/ruleset:$RuleSetFilePath") } $CompilerParameter += @("/enableexternalrulesets") $CompilerParameter += @("/reportsuppresseddiagnostics") if ($SourceRepositoryUrl) { $CompilerParameter += @("/SourceRepositoryUrl:""$SourceRepositoryUrl""") } if ($SourceCommit) { $CompilerParameter += @("/SourceCommit:""$SourceCommit""") } if ($BuildBy) { $CompilerParameter += @("/BuildBy:""$BuildBy""") } if ($BuildUrl) { $CompilerParameter += @("/BuildUrl:""$BuildUrl""") } if ($AssemblyProbingPaths) { $CompilerParameter += @("/assemblyprobingpaths:$AssemblyProbingPaths") } if ($Features) { $CompilerParameter +=@("/features:$($Features -join ',')") } $CompilerParameter += @("/generatecrossreferences") if ($ErrorLogFilePath) { $CompilerParameter += @("/errorLog:""$ErrorLogFilePath""") } $PreprocessorSymbols | Where-Object { $_ } | ForEach-Object { $CompilerParameter += @("/D:$_") } Invoke-Alc -AlcExe $AlcExe -CompilerParameter $CompilerParameter # Write-Output $LASTEXITCODE } |