From 031d1a5914a869d71c4b9ca3ae286eee070ac931 Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Wed, 16 Oct 2024 10:41:49 +0200 Subject: [PATCH] Support propagateDependencies during compile (#3725) Fixes #3538 --------- Co-authored-by: freddydk --- AppHandling/Compile-AppInNavContainer.ps1 | 52 +++++++++++++------ .../Compile-AppWithBcCompilerFolder.ps1 | 35 +++++++------ ReleaseNotes.txt | 3 ++ Version.txt | 2 +- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/AppHandling/Compile-AppInNavContainer.ps1 b/AppHandling/Compile-AppInNavContainer.ps1 index dae3acda0..7963a10c5 100644 --- a/AppHandling/Compile-AppInNavContainer.ps1 +++ b/AppHandling/Compile-AppInNavContainer.ps1 @@ -318,8 +318,25 @@ try { if (!$updateSymbols) { $existingApps = Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock { Param($appSymbolsFolder) Get-ChildItem -Path (Join-Path $appSymbolsFolder '*.app') | ForEach-Object { - $appInfo = Get-NavAppInfo -Path $_.FullName - $appInfo + $alcPath = 'C:\build\vsix\extension\bin' + $alToolExe = Join-Path $alcPath 'win32\altool.exe' + $alToolExists = Test-Path -Path $alToolExe -PathType Leaf + if ($alToolExists) { + $manifest = & "$alToolExe" GetPackageManifest "$($_.FullName)" | ConvertFrom-Json + $dependencies = @() + $propagateDependencies = $false + if ($manifest.PSObject.Properties.Name -eq 'dependencies') { + $dependencies = @($manifest.dependencies | ForEach-Object { @{ "Publisher" = $_.publisher; "Name" = $_.name; "Version" = $_.version; "AppId" = $_.id } }) + } + if ($manifest.PSObject.Properties.Name -eq 'propagateDependencies') { + $propagateDependencies = $manifest.propagateDependencies + } + return @{ "AppId" = $manifest.id; "Publisher" = $manifest.publisher; "Name" = $manifest.name; "Version" = $manifest.version; "PropagateDependencies" = $propagateDependencies; "Dependencies" = $dependencies } + } + else { + $appInfo = Get-NavAppInfo -Path $_.FullName + return @{ "AppId" = $appInfo.AppId; "Publisher" = $appInfo.publisher; "Name" = $appInfo.name; "Version" = $appInfo.version; "PropagateDependencies" = $false; "Dependencies" = @() } + } } } -ArgumentList $containerSymbolsFolder } @@ -415,8 +432,12 @@ try { (($_.Name -eq $dependency.name) -and ($_.Name -eq "Application" -or (($_.Publisher -eq $dependency.publisher) -and ([System.Version]$_.Version -ge [System.Version]$dependency.version)))) } } + $addDependencies = @() if ($existingApp) { Write-Host "Dependency App exists" + if ($existingApp.PropagateDependencies) { + $addDependencies += $existingApp.Dependencies + } } if ($updateSymbols -or !$existingApp) { $publisher = $dependency.publisher @@ -536,23 +557,22 @@ try { } } } -ArgumentList (Get-BcContainerPath -containerName $containerName -path $symbolsFile), $platformversion - - $addDependencies | ForEach-Object { - $addDependency = $_ - $found = $false - $dependencies | ForEach-Object { - if ((($_.appId) -and ($_.appId -eq $addDependency.appId)) -or ($_.Publisher -eq $addDependency.Publisher -and $_.Name -eq $addDependency.Name)) { - $found = $true - } - } - if (!$found) { - Write-Host "Adding dependency to $($addDependency.Name) from $($addDependency.Publisher)" - $dependencies += $addDependency - } - } } } } + $addDependencies | ForEach-Object { + $addDependency = $_ + $found = $false + $dependencies | ForEach-Object { + if ((($_.appId) -and ($_.appId -eq $addDependency.appId)) -or ($_.Publisher -eq $addDependency.Publisher -and $_.Name -eq $addDependency.Name)) { + $found = $true + } + } + if (!$found) { + Write-Host "Adding dependency to $($addDependency.Name) from $($addDependency.Publisher)" + $dependencies += $addDependency + } + } $depidx++ } diff --git a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 index fc57086d0..078f26ef5 100644 --- a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 +++ b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 @@ -187,8 +187,12 @@ try { $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)) } + $addDependencies = $() if ($existingApp) { Write-Host "Dependency App exists" + if ($existingApp.ContainsKey('PropagateDependencies') -and $existingApp.PropagateDependencies) { + $addDependencies += $existingApp.Dependencies + } } else { Write-Host "Dependency App not found" @@ -208,20 +212,21 @@ try { if (!($dependencies | where-Object { $_.Name -eq 'System'})) { $dependencies += @{"publisher" = "Microsoft"; "name" = "System"; "appId" = ''; "version" = $copyCompilerFolderApp.Platform } } - $copyCompilerFolderApp.Dependencies | ForEach-Object { - $addDependency = $_ - try { - $appId = $addDependency.id - } - catch { - $appId = $addDependency.appid - } - $dependencyExists = $dependencies | Where-Object { $_.appId -eq $appId } - if (-not $dependencyExists) { - Write-Host "Adding dependency to $($addDependency.Name) from $($addDependency.Publisher)" - $dependencies += @($compilerFolderApps | Where-Object { $_.appId -eq $appId }) - } - } + $addDependencies += $copyCompilerFolderApp.Dependencies + } + } + $addDependencies | ForEach-Object { + $addDependency = $_ + try { + $appId = $addDependency.id + } + catch { + $appId = $addDependency.appid + } + $dependencyExists = $dependencies | Where-Object { $_.appId -eq $appId } + if (-not $dependencyExists) { + Write-Host "Adding dependency to $($addDependency.Name) from $($addDependency.Publisher)" + $dependencies += @($compilerFolderApps | Where-Object { $_.appId -eq $appId }) } } $depidx++ @@ -348,7 +353,7 @@ try { $alcCmd = "./$alcExe" } } - + if (!(Test-Path -Path (Join-Path $alcPath $alcExe))) { $alcCmd = "dotnet" $alcExe = 'alc.dll' diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index 2c5de4e12..bbc077678 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -1,3 +1,6 @@ +6.0.27 +Issue 3538 Compile-AppWithBcCompilerFolder fails when dependency does propagateDependencies + 6.0.26 As minimum, always use the generic tag version which was available when shipping BcContainerHelper Add awareness of Windows 11 24H2 diff --git a/Version.txt b/Version.txt index 288e8033e..365186458 100644 --- a/Version.txt +++ b/Version.txt @@ -1 +1 @@ -6.0.26-dev \ No newline at end of file +6.0.27-dev \ No newline at end of file