Public/New-CompiledALProjectApp.ps1
function New-CompiledALProjectApp { Param ( [Parameter(Mandatory=$true)] [String] $AppProjectFolder, [Parameter(Mandatory=$true)] [String] $AppOutputFile, $AppSymbolsFolder, $EnableCodeCop, $EnableAppSourceCop, $EnablePerTenantExtensionCop, $EnableUICop, $RulesetFile, $AssemblyProbingPaths, $NoWarn, $GenerateCrossReferences, $GenerateReportLayoutParam, $Features, $PreProcessorSymbols ) # TODO: Save the compiler on a cache folder in the root folder of C drive. $ALCompilerFolderName = "ALCompiler" $ALCPath = Join-Path (Get-Location) $ALCompilerFolderName if (!(Test-Path $ALCPath)) { Write-Error "AL Compiler folder doesn't exists. Please create it using the Get-ALCompilerFromArtifacts function." return } if (Test-Path -Path $AppOutputFile -PathType Leaf) { Remove-Item -Path $AppOutputFile -Force } $OriginalLocation = Get-Location try { Write-Host "Compiling..." Set-Location -Path $ALCPath $ALCParameters = @("/project:""$($AppProjectFolder.TrimEnd('/\'))""", "/packagecachepath:""$($AppSymbolsFolder.TrimEnd('/\'))""", "/out:""$AppOutputFile""") if ($GenerateReportLayoutParam) { $ALCParameters += @($GenerateReportLayoutParam) } if ($EnableCodeCop) { $ALCParameters += @("/analyzer:$(Join-Path $BinPath 'Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll')") } if ($EnableAppSourceCop) { $ALCParameters += @("/analyzer:$(Join-Path $BinPath 'Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll')") } if ($EnablePerTenantExtensionCop) { $ALCParameters += @("/analyzer:$(Join-Path $BinPath 'Analyzers\Microsoft.Dynamics.Nav.PerTenantExtensionCop.dll')") } if ($EnableUICop) { $ALCParameters += @("/analyzer:$(Join-Path $BinPath 'Analyzers\Microsoft.Dynamics.Nav.UICop.dll')") } if ($RulesetFile) { $ALCParameters += @("/ruleset:$Rulesetfile") } if ($NoWarn) { $ALCParameters += @("/nowarn:$Nowarn") } if ($GenerateCrossReferences) { $ALCParameters += @("/generatecrossreferences") } if ($AssemblyProbingPaths) { $ALCParameters += @("/assemblyprobingpaths:$AssemblyProbingPaths") } if ($Features) { $ALCParameters +=@("/features:$([string]::Join(',', $Features))") } $PreProcessorSymbols | where-Object { $_ } | ForEach-Object { $ALCParameters += @("/D:$_") } Write-Host ".\alc.exe $([string]::Join(' ', $ALCParameters))" & .\alc.exe $ALCParameters if ($lastexitcode -ne 0) { Write-Error "App generation failed with exit code $lastexitcode" } } finally { Set-Location $OriginalLocation } } Export-ModuleMember -Function New-CompiledALProjectApp |