Skip to content

Commit

Permalink
Support propagateDependencies during compile (#3725)
Browse files Browse the repository at this point in the history
Fixes #3538

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk authored Oct 16, 2024
1 parent 3d959c0 commit 031d1a5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 32 deletions.
52 changes: 36 additions & 16 deletions AppHandling/Compile-AppInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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++
}

Expand Down
35 changes: 20 additions & 15 deletions CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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++
Expand Down Expand Up @@ -348,7 +353,7 @@ try {
$alcCmd = "./$alcExe"
}
}

if (!(Test-Path -Path (Join-Path $alcPath $alcExe))) {
$alcCmd = "dotnet"
$alcExe = 'alc.dll'
Expand Down
3 changes: 3 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.26-dev
6.0.27-dev

0 comments on commit 031d1a5

Please sign in to comment.