diff --git a/AppHandling/Compile-AppInNavContainer.ps1 b/AppHandling/Compile-AppInNavContainer.ps1 index f7275e5f1..dae3acda0 100644 --- a/AppHandling/Compile-AppInNavContainer.ps1 +++ b/AppHandling/Compile-AppInNavContainer.ps1 @@ -263,39 +263,7 @@ try { } if ($CopySymbolsFromContainer) { - Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($appSymbolsFolder) - if (Test-Path "C:\Extensions\*.app") { - $paths = @( - "C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app" - "C:\Extensions\*.app" - ) - } - else { - $paths = @( - "C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app" - "C:\Applications.*\Microsoft_Application_*.app,C:\Applications\Application\Source\Microsoft_Application.app" - "C:\Applications.*\Microsoft_Base Application_*.app,C:\Applications\BaseApp\Source\Microsoft_Base Application.app" - "C:\Applications.*\Microsoft_System Application_*.app,C:\Applications\System Application\source\Microsoft_System Application.app" - "C:\Applications.*\Microsoft_Business Foundation_*.app,C:\Applications\BusinessFoundation\source\Microsoft_Business Foundation.app" - ) - } - $paths | ForEach-Object { - $appFiles = $_.Split(',') - $appFile = "" - if (Test-Path -Path $appFiles[0]) { - $appFile = $appFiles[0] - } - elseif (Test-Path -path $appFiles[1]) { - $appFile = $appFiles[1] - } - if ($appFile) { - Get-Item -Path $appFile | ForEach-Object { - Write-Host "Copying $([System.IO.Path]::GetFileName($_.FullName)) from Container" - Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force - } - } - } - } -argumentList $containerSymbolsFolder + CopySymbolsFromContainer -containerName $containerName -containerSymbolsFolder $containerSymbolsFolder } $GenerateReportLayoutParam = "" diff --git a/AppHandling/Run-AlPipeline.ps1 b/AppHandling/Run-AlPipeline.ps1 index 4c1932e79..db90de721 100644 --- a/AppHandling/Run-AlPipeline.ps1 +++ b/AppHandling/Run-AlPipeline.ps1 @@ -464,11 +464,17 @@ function GetInstalledAppIds { $compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $compilerFolder 'symbols/*.app') | Select-Object -ExpandProperty FullName) $installedApps += @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $compilerFolder 'symbols/cache_AppInfo.json')) } - elseif (!$filesOnly) { - $installedApps = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters) + elseif ($filesOnly) { + $installedApps = Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | ForEach-Object { + $appJson = Get-AppJsonFromAppFile -appFile $_.FullName + return @{ + "appId" = $appJson.id + "name" = $appJson.name + } + } } else { - $installedApps = @() + $installedApps = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters) } Write-GroupStart -Message "Installed Apps" $installedApps | ForEach-Object { @@ -967,7 +973,7 @@ $testCountry = $_.Trim() $testToolkitInstalled = $false if ($useCompilerFolder) { - Write-GroupStart -Message "Creating container" + Write-GroupStart -Message "Creating CompilerFolder" Write-Host -ForegroundColor Yellow @' _____ _ _ _____ _ _ ______ _ _ @@ -981,7 +987,7 @@ if ($useCompilerFolder) { '@ } else { - if ($gitHubActions) { Write-Host "::group::Creating container" } + Write-GroupStart -Message "Creating Container" Write-Host -ForegroundColor Yellow @' _____ _ _ _____ _ _ @@ -1113,6 +1119,14 @@ Measure-Command { } } } + if ($CopySymbolsFromContainer) { + $containerSymbolsFolder = Get-BcContainerPath -containerName $containerName -path $packagesFolder + if ("$containerSymbolsFolder" -eq "") { + throw "The appSymbolsFolder ($appSymbolsFolder) is not shared with the container." + } + CopySymbolsFromContainer -containerName $containerName -containerSymbolsFolder $containerSymbolsFolder + $CopySymbolsFromContainer = $false + } } } | ForEach-Object { Write-Host -ForegroundColor Yellow "`nCreating container took $([int]$_.TotalSeconds) seconds" } @@ -1324,13 +1338,9 @@ Measure-Command { $missingAppDependencies | ForEach-Object { Write-Host "- $_" } $Parameters = @{ "missingDependencies" = @($unknownAppDependencies | Where-Object { $missingAppDependencies -contains "$_".Split(':')[0] }) + "appSymbolsFolder" = $packagesFolder } - if ($useCompilerFolder -or $filesOnly) { - $Parameters += @{ - "appSymbolsFolder" = $packagesFolder - } - } - else { + if (!($useCompilerFolder -or $filesOnly)) { $Parameters += @{ "containerName" = $containerName "tenant" = $tenant @@ -1477,13 +1487,9 @@ Measure-Command { $missingTestAppDependencies | ForEach-Object { Write-Host "- $_" } $Parameters = @{ "missingDependencies" = @($unknownTestAppDependencies | Where-Object { $missingTestAppDependencies -contains "$_".Split(':')[0] }) + "appSymbolsFolder" = $packagesFolder } - if ($useCompilerFolder -or $filesOnly) { - $Parameters += @{ - "appSymbolsFolder" = $packagesFolder - } - } - else { + if (!($useCompilerFolder -or $filesOnly)) { $Parameters += @{ "containerName" = $containerName "tenant" = $tenant @@ -1656,13 +1662,9 @@ Measure-Command { $missingTestAppDependencies | ForEach-Object { Write-Host "- $_" } $Parameters = @{ "missingDependencies" = @($unknownTestAppDependencies | Where-Object { $missingTestAppDependencies -contains "$_".Split(':')[0] }) + "appSymbolsFolder" = $packagesFolder } - if ($useCompilerFolder -or $filesOnly) { - $Parameters += @{ - "appSymbolsFolder" = $packagesFolder - } - } - else { + if (!($useCompilerFolder -or $filesOnly)) { $Parameters += @{ "containerName" = $containerName "tenant" = $tenant diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index f9cfac2a4..b16873758 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -1354,3 +1354,44 @@ function Write-GroupEnd { $bcContainerHelperConfig.IsAzureDevOps { Write-Host "##[endgroup]"; break } } } + +function CopySymbolsFromContainer { + Param( + [string] $containerName, + [string] $containerSymbolsFolder + ) + + Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($appSymbolsFolder) + if (Test-Path "C:\Extensions\*.app") { + $paths = @( + "C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app" + "C:\Extensions\*.app" + ) + } + else { + $paths = @( + "C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app" + "C:\Applications.*\Microsoft_Application_*.app,C:\Applications\Application\Source\Microsoft_Application.app" + "C:\Applications.*\Microsoft_Base Application_*.app,C:\Applications\BaseApp\Source\Microsoft_Base Application.app" + "C:\Applications.*\Microsoft_System Application_*.app,C:\Applications\System Application\source\Microsoft_System Application.app" + "C:\Applications.*\Microsoft_Business Foundation_*.app,C:\Applications\BusinessFoundation\source\Microsoft_Business Foundation.app" + ) + } + $paths | ForEach-Object { + $appFiles = $_.Split(',') + $appFile = "" + if (Test-Path -Path $appFiles[0]) { + $appFile = $appFiles[0] + } + elseif (Test-Path -path $appFiles[1]) { + $appFile = $appFiles[1] + } + if ($appFile) { + Get-Item -Path $appFile | ForEach-Object { + Write-Host "Copying $([System.IO.Path]::GetFileName($_.FullName)) from Container" + Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force + } + } + } + } -argumentList $containerSymbolsFolder +} \ No newline at end of file diff --git a/NuGet/Publish-BcNuGetPackageToContainer.ps1 b/NuGet/Publish-BcNuGetPackageToContainer.ps1 index 9ff662138..6f6d8186f 100644 --- a/NuGet/Publish-BcNuGetPackageToContainer.ps1 +++ b/NuGet/Publish-BcNuGetPackageToContainer.ps1 @@ -56,6 +56,7 @@ Function Publish-BcNuGetPackageToContainer { [string] $environment, [Parameter(Mandatory=$false)] [string] $tenant = "default", + [string] $appSymbolsFolder = "", [string] $copyInstalledAppsToFolder = "", [switch] $skipVerification ) @@ -80,7 +81,12 @@ Function Publish-BcNuGetPackageToContainer { New-Item $tmpFolder -ItemType Directory | Out-Null try { if (Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $packageName -version $version -appSymbolsFolder $tmpFolder -installedApps $installedApps -installedPlatform $installedPlatform -installedCountry $installedCountry -verbose:($VerbosePreference -eq 'Continue') -select $select) { - $appFiles = Get-Item -Path (Join-Path $tmpFolder '*.app') | Select-Object -ExpandProperty FullName + $appFiles = Get-Item -Path (Join-Path $tmpFolder '*.app') | ForEach-Object { + if ($appSymbolsFolder) { + Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force + } + $_.FullName + } Publish-BcContainerApp -containerName $containerName -bcAuthContext $bcAuthContext -environment $environment -tenant $tenant -appFile $appFiles -sync -install -upgrade -checkAlreadyInstalled -skipVerification -copyInstalledAppsToFolder $copyInstalledAppsToFolder } else {