diff --git a/icinga-powershell-framework.psm1 b/icinga-powershell-framework.psm1 index 127179e..5068ad8 100644 --- a/icinga-powershell-framework.psm1 +++ b/icinga-powershell-framework.psm1 @@ -133,7 +133,18 @@ function Write-IcingaFrameworkCodeCache() function Copy-IcingaFrameworkCacheTemplate() { - Copy-Item -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\framework_cache.psm1.template') -Destination (Get-IcingaFrameworkCodeCacheFile) -Force; + Copy-ItemSecure -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\framework_cache.psm1.template') -Destination (Get-IcingaFrameworkCodeCacheFile) -Force | Out-Null; + + $WindowsModules = Get-Module -Name 'icinga-powershell-*' -ListAvailable; + + foreach ($entry in $WindowsModules) { + $ModulePath = $entry.Path.Replace([string]::Format('{0}.psd1', $entry.Name), ''); + $CacheFile = Join-Path -Path $ModulePath -ChildPath ([string]::Format('\compiled\{0}.ifw_compilation.psm1', $entry.Name)); + + if (Test-Path $CacheFile) { + Copy-ItemSecure -Path (Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\templates\compilation.psm1.template') -Destination $CacheFile -Force | Out-Null; + } + } } function Publish-IcingaEventLogDocumentation() diff --git a/templates/compilation.psm1.template b/templates/compilation.psm1.template index 531c7d1..4852084 100644 --- a/templates/compilation.psm1.template +++ b/templates/compilation.psm1.template @@ -17,3 +17,7 @@ if ($null -eq (Get-Command -Name 'Write-IcingaForWindowsComponentCompilationFile Write-IcingaForWindowsComponentCompilationFile ` -ScriptRootPath $PSScriptRoot ` -CompiledFilePath ($MyInvocation.MyCommand.Path); + +if ($null -ne $env:TERM_PROGRAM -Or $Global:Icinga.Protected.DeveloperMode) { + Copy-IcingaFrameworkCacheTemplate; +}