diff --git a/AppHandling/Run-AlPipeline.ps1 b/AppHandling/Run-AlPipeline.ps1 index 7c6c5a92e..cd97975f9 100644 --- a/AppHandling/Run-AlPipeline.ps1 +++ b/AppHandling/Run-AlPipeline.ps1 @@ -1176,8 +1176,8 @@ $Parameters = @{ "tenant" = $tenant } if ($useCompilerFolder) { - $existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app')) - $installedAppIds = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfo | Select-Object -ExpandProperty 'AppId') + $existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | Select-Object -ExpandProperty FullName) + $installedAppIds = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $packagesFolder 'AppInfoCache.json') | Select-Object -ExpandProperty 'AppId') } else { $installedAppIds = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters | Select-Object -ExpandProperty 'AppId') @@ -1329,8 +1329,8 @@ $Parameters = @{ "tenant" = $tenant } if ($useCompilerFolder) { - $existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app')) - $installedApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfo) + $existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | Select-Object -ExpandProperty FullName) + $installedApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $packagesFolder 'AppInfoCache.json')) $installedAppIds = @($installedApps | ForEach-Object { $_.AppId } ) } else { diff --git a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 index fe2e99672..f49933c4e 100644 --- a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 +++ b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 @@ -175,11 +175,11 @@ try { Write-Host "Enumerating Apps in CompilerFolder $symbolsPath" $compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName) - $compilerFolderApps = @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppInfo) + $compilerFolderApps = @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'AppInfoCache.json')) Write-Host "Enumerating Apps in Symbols Folder $appSymbolsFolder" $existingAppFiles = @(Get-ChildItem -Path (Join-Path $appSymbolsFolder '*.app') | Select-Object -ExpandProperty FullName) - $existingApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder) + $existingApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $appSymbolsFolder 'AppInfoCache.json')) $depidx = 0 while ($depidx -lt $dependencies.Count) { diff --git a/CompilerFolderHandling/Copy-AppFilesToCompilerFolder.ps1 b/CompilerFolderHandling/Copy-AppFilesToCompilerFolder.ps1 index 086e18971..cc8fa626f 100644 --- a/CompilerFolderHandling/Copy-AppFilesToCompilerFolder.ps1 +++ b/CompilerFolderHandling/Copy-AppFilesToCompilerFolder.ps1 @@ -30,8 +30,8 @@ function Copy-AppFilesToCompilerFolder { Write-Host "Copy app files to compiler folder" $symbolsPath = Join-Path $compilerFolder 'symbols' - $compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app')) - $compilerFolderApps = GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppInfo + $compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName) + $compilerFolderApps = GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'AppInfoCache.json') if ($checkAlreadyInstalled) { $appFiles = @(Sort-AppFilesByDependencies -appFiles $appFiles -includeOnlyAppIds $includeOnlyAppIds -excludeInstalledApps $compilerFolderApps -WarningAction SilentlyContinue) } diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index 6de71502e..28856fa9b 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -1091,9 +1091,19 @@ function GetAppInfo { Param( [string[]] $appFiles, [string] $compilerFolder, - [switch] $cacheAppInfo + [string] $cacheAppInfoPath = '' ) + $appInfoCache = $null + $cacheUpdated = $false + if ($cacheAppInfoPath) { + if (Test-Path $cacheAppInfoPath) { + $appInfoCache = Get-Content -Path $cacheAppInfoPath -Encoding utf8 | ConvertFrom-Json + } + else { + $appInfoCache = @{} + } + } Write-Host "Getting .app info" $binPath = Join-Path $compilerFolder 'compiler/extension/bin' if ($isLinux) { @@ -1115,12 +1125,10 @@ function GetAppInfo { $packageStream = $null $package = $null try { - $appFiles | ForEach-Object { - $path = $_ + foreach($path in $appFiles) { Write-Host -NoNewline "- $([System.IO.Path]::GetFileName($path))" - $appInfoPath = "$_.json" - if ($cacheAppInfo -and (Test-Path -Path $appInfoPath)) { - $appInfo = Get-Content -Path $appInfoPath | ConvertFrom-Json + if ($appInfoCache -and $appInfoCache.PSObject.Properties.Name -eq $path) { + $appInfo = $appInfoCache."$path" Write-Host " (cached)" } else { @@ -1146,8 +1154,9 @@ function GetAppInfo { "propagateDependencies" = $manifest.PropagateDependencies } Write-Host " (succeeded)" - if ($cacheAppInfo) { - $appInfo | ConvertTo-Json -Depth 99 | Set-Content -Path $appInfoPath -Encoding UTF8 -Force + if ($appInfoCache) { + $appInfoCache | Add-Member -MemberType NoteProperty -Name $path -Value $appInfo + $cacheUpdated = $true } } @{ @@ -1163,6 +1172,9 @@ function GetAppInfo { "PropagateDependencies" = $appInfo.propagateDependencies } } + if ($cacheUpdated) { + $appInfoCache | ConvertTo-Json -Depth 99 | Set-Content -Path $cacheAppInfoPath -Encoding UTF8 -Force + } } catch [System.Reflection.ReflectionTypeLoadException] { Write-Host " (failed)"