core/sitefinity/web-app/web-app-misc.ps1
<#
.SYNOPSIS Generates and adds precompiled templates to selected sitefinity solution. .DESCRIPTION Precompiled templates give much faster page loads when web app is restarted (when building or rebuilding solution) on first load of the page. Useful with local sitefinity development. WARNING: Any changes to markup are ignored when precompiled templates are added to the project, meaning the markup at the time of precompilation is always used. In order to see new changes to markup you need to remove the precompiled templates and generate them again. .PARAMETER revert Reverts previous changes .OUTPUTS None #> function sf-app-addPrecompiledTemplates { param( [switch]$revert ) # path to sitefinity compiler tool $sitefinityCompiler = "$PSScriptRoot\external-tools\Telerik.Sitefinity.Compiler.exe" if (-not (Test-Path $sitefinityCompiler)) { Throw "Sitefinity compiler tool not found. You need to set the path to it inside the function" } $context = sf-proj-getCurrent $webAppPath = $context.webAppPath $appUrl = _getAppUrl if ($revert) { $dlls = Get-ChildItem -Force -Recurse "${webAppPath}\bin" | Where-Object { ($_.PSIsContainer -eq $false) -and (( $_.Name -like "Telerik.Sitefinity.PrecompiledTemplates.dll") -or ($_.Name -like "Telerik.Sitefinity.PrecompiledPages.Backend.0.dll")) } try { $dlls | Remove-Item -Force } catch { throw "Item could not be deleted: $dll.PSPath`nMessage:$_" } } else { & $sitefinityCompiler /appdir="${webAppPath}" /username="" /password="" /strategy="Backend" /membershipprovider="Default" /templateStrategy="Default" /url="${appUrl}" } } |