From d3b4ae6c6d779eb9e57968c602ba13875d02f17f Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Wed, 16 Oct 2024 21:04:28 +0200 Subject: [PATCH] Regression + test failure (#3728) Fixes #3727 --------- Co-authored-by: freddydk --- AppHandling/Compile-AppInNavContainer.ps1 | 4 ++-- .../Compile-AppWithBcCompilerFolder.ps1 | 4 ++-- ReleaseNotes.txt | 1 + Saas/Publish-PerTenantExtensionApps.ps1 | 9 +++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AppHandling/Compile-AppInNavContainer.ps1 b/AppHandling/Compile-AppInNavContainer.ps1 index 7963a10c5..8435c9861 100644 --- a/AppHandling/Compile-AppInNavContainer.ps1 +++ b/AppHandling/Compile-AppInNavContainer.ps1 @@ -431,11 +431,11 @@ try { else { (($_.Name -eq $dependency.name) -and ($_.Name -eq "Application" -or (($_.Publisher -eq $dependency.publisher) -and ([System.Version]$_.Version -ge [System.Version]$dependency.version)))) } - } + } | Sort-Object { [System.Version]$_.Version } -Descending | Select-Object -First 1 $addDependencies = @() if ($existingApp) { Write-Host "Dependency App exists" - if ($existingApp.PropagateDependencies) { + if ($existingApp.ContainsKey('PropagateDependencies') -and $existingApp.PropagateDependencies -and $existingApp.ContainsKey('Dependencies')) { $addDependencies += $existingApp.Dependencies } } diff --git a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 index 078f26ef5..f1094d96f 100644 --- a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 +++ b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 @@ -186,11 +186,11 @@ try { Write-Host "Processing dependency $($dependency.Publisher)_$($dependency.Name)_$($dependency.Version) ($($dependency.AppId))" $existingApp = $existingApps | Where-Object { ((($dependency.appId -ne '' -and $_.AppId -eq $dependency.appId) -or ($dependency.appId -eq '' -and $_.Name -eq $dependency.Name)) -and ([System.Version]$_.Version -ge [System.Version]$dependency.version)) - } + } | Sort-Object { [System.Version]$_.Version } -Descending | Select-Object -First 1 $addDependencies = $() if ($existingApp) { Write-Host "Dependency App exists" - if ($existingApp.ContainsKey('PropagateDependencies') -and $existingApp.PropagateDependencies) { + if ($existingApp.ContainsKey('PropagateDependencies') -and $existingApp.PropagateDependencies -and $existingApp.ContainsKey('Dependencies')) { $addDependencies += $existingApp.Dependencies } } diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index bbc077678..7acfddad0 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,5 +1,6 @@ 6.0.27 Issue 3538 Compile-AppWithBcCompilerFolder fails when dependency does propagateDependencies +Issue 3727 Regression - Release pipelines failing with SaaS environments due BcAuthContext 6.0.26 As minimum, always use the generic tag version which was available when shipping BcContainerHelper diff --git a/Saas/Publish-PerTenantExtensionApps.ps1 b/Saas/Publish-PerTenantExtensionApps.ps1 index 77f3e048c..268a8f1b8 100644 --- a/Saas/Publish-PerTenantExtensionApps.ps1 +++ b/Saas/Publish-PerTenantExtensionApps.ps1 @@ -51,8 +51,6 @@ function Publish-PerTenantExtensionApps { $telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @() try { - $script:authContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext - function GetAuthHeaders { $script:authContext = Renew-BcAuthContext -bcAuthContext $script:authContext return @{ "Authorization" = "Bearer $($script:authContext.AccessToken)" } @@ -69,16 +67,19 @@ try { if ($clientSecret -is [String]) { $clientSecret = ConvertTo-SecureString -String $clientSecret -AsPlainText -Force } if ($clientSecret -isnot [SecureString]) { throw "ClientSecret needs to be a SecureString or a String" } - $bcauthContext = New-BcAuthContext ` + $script:authContext = New-BcAuthContext ` -clientID $clientID ` -clientSecret $clientSecret ` -tenantID $tenantId ` -scopes "https://api.businesscentral.dynamics.com/.default" - if (-not ($bcAuthContext)) { + if (-not ($script:AuthContext)) { throw "Authentication failed" } } + else { + $script:authContext = Renew-BcAuthContext -bcAuthContext $bcAuthContext + } $appFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid().ToString()) try {