From 4e8cc51d34fcbb782ba5908412c6665412edee35 Mon Sep 17 00:00:00 2001 From: Freddy Kristiansen Date: Tue, 2 Jan 2024 08:39:59 +0100 Subject: [PATCH] Nuget (#3283) Compare normalized version numbers when locating nuget packages (ADO turns 4.4.3.0 into 4.4.3 when getting version numbers and a normal compare between 4.4.3 and 4.4.3.0 is not equal) Runtime packages can contain multiple localized versions of the runtime package. When installing or downloading nuget packages - grab the country subfolder (if it exists), else revert to the original version --------- Co-authored-by: freddydk --- AppHandling/Run-AlValidation.ps1 | 31 ------- AppSource/New-AppSourceSubmission.ps1 | 13 +-- HelperFunctions.ps1 | 30 ++++++- NuGet/Download-BcNuGetPackageToFolder.ps1 | 97 ++++++++++++++------- NuGet/Find-BcNuGetPackage.ps1 | 2 +- NuGet/New-BcNuGetPackage.ps1 | 49 ++++++++++- NuGet/NuGetFeedClass.ps1 | 28 +++++- NuGet/Publish-BcNuGetPackageToContainer.ps1 | 5 +- Saas/Publish-PerTenantExtensionApps.ps1 | 7 +- 9 files changed, 171 insertions(+), 91 deletions(-) diff --git a/AppHandling/Run-AlValidation.ps1 b/AppHandling/Run-AlValidation.ps1 index fb87d6ccd..708953974 100644 --- a/AppHandling/Run-AlValidation.ps1 +++ b/AppHandling/Run-AlValidation.ps1 @@ -176,37 +176,6 @@ Write-Host -ForegroundColor Yellow @' $artifactUrl } -function GetApplicationDependency( [string] $appFile, [string] $minVersion = "0.0" ) { - $tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) - try { - Extract-AppFileToFolder -appFilename $appFile -appFolder $tmpFolder -generateAppJson - $appJsonFile = Join-Path $tmpFolder "app.json" - $appJson = [System.IO.File]::ReadAllLines($appJsonFile) | ConvertFrom-Json - } - catch { - Write-Host -ForegroundColor Red "Cannot unpack app $([System.IO.Path]::GetFileName($appFile)), it might be a runtime package, ignoring application dependency check" - return $minVersion - } - finally { - if (Test-Path $tmpFolder) { - Remove-Item $tmpFolder -Recurse -Force - } - } - if ($appJson.PSObject.Properties.Name -eq "Application") { - $version = $appJson.application - } - else { - $version = $appJson.dependencies | Where-Object { $_.Name -eq "Base Application" -and $_.Publisher -eq "Microsoft" } | ForEach-Object { $_.Version } - if (!$version) { - $version = $minVersion - } - } - if ([System.Version]$version -lt [System.Version]$minVersion) { - $version = $minVersion - } - $version -} - function GetFilePath( [string] $path ) { if ($path -like "http://*" -or $path -like "https://*") { return $path diff --git a/AppSource/New-AppSourceSubmission.ps1 b/AppSource/New-AppSourceSubmission.ps1 index 91785f38c..15f44da37 100644 --- a/AppSource/New-AppSourceSubmission.ps1 +++ b/AppSource/New-AppSourceSubmission.ps1 @@ -99,17 +99,8 @@ try { $appVersionNumber = "" if ($appFile) { - try { - $tempFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) - Extract-AppFileToFolder -appFilename $appFile -appFolder $tempFolder -generateAppJson - $appJsonFile = Join-Path $tempFolder 'app.json' - $appJson = Get-Content $appJsonFile -Encoding UTF8 | ConvertFrom-Json - Remove-Item $tempFolder -Recurse -Force - $appVersionNumber = [System.Version]$appJson.version - } - catch { - throw "Unable to extract app file and determine version number" - } + $appJson = GetAppJsonFromAppFile -appFile $appFile + $appVersionNumber = [System.Version]$appJson.version } $tempFolder = "" diff --git a/HelperFunctions.ps1 b/HelperFunctions.ps1 index 91debdfdb..e9a3e1a64 100644 --- a/HelperFunctions.ps1 +++ b/HelperFunctions.ps1 @@ -1332,12 +1332,36 @@ function GetAppJsonFromAppFile { ) # ALTOOL is at the moment only available in prerelease $path = DownloadLatestAlLanguageExtension -allowPrerelease - if ($isWindows) { - $alToolExe = Join-Path $path 'extension/bin/win32/altool.exe' + if ($isLinux) { + $alToolExe = Join-Path $path 'extension/bin/linux/altool' } else { - $alToolExe = Join-Path $path 'extension/bin/linux/altool' + $alToolExe = Join-Path $path 'extension/bin/win32/altool.exe' } $appJson = CmdDo -Command $alToolExe -arguments @('GetPackageManifest', """$appFile""") -returnValue -silent | ConvertFrom-Json return $appJson } + +function GetApplicationDependency( [string] $appFile, [string] $minVersion = "0.0" ) { + try { + $appJson = GetAppJsonFromAppFile -appFile $appFile + } + catch { + Write-Host -ForegroundColor Red "Unable to read app $([System.IO.Path]::GetFileName($appFile)), ignoring application dependency check" + return $minVersion + } + $version = $minVersion + if ($appJson.PSObject.Properties.Name -eq "Application") { + $version = $appJson.application + } + elseif ($appJson.PSObject.Properties.Name -eq "dependencies") { + $baseAppDependency = $appJson.dependencies | Where-Object { $_.Name -eq "Base Application" -and $_.Publisher -eq "Microsoft" } + if ($baseAppDependency) { + $version = $baseAppDependency.Version + } + } + if ([System.Version]$version -lt [System.Version]$minVersion) { + $version = $minVersion + } + return $version +} diff --git a/NuGet/Download-BcNuGetPackageToFolder.ps1 b/NuGet/Download-BcNuGetPackageToFolder.ps1 index e845db63a..720a68396 100644 --- a/NuGet/Download-BcNuGetPackageToFolder.ps1 +++ b/NuGet/Download-BcNuGetPackageToFolder.ps1 @@ -30,7 +30,7 @@ .PARAMETER installedPlatform Version of the installed platform .PARAMETER installedCountry - Country of the installed application + Country of the installed application. installedCountry is used to determine if the NuGet package is compatible with the installed application localization .PARAMETER installedApps List of installed apps Format is an array of PSCustomObjects with properties Name, Publisher, id and Version @@ -67,7 +67,7 @@ Function Download-BcNuGetPackageToFolder { [Parameter(Mandatory=$false)] [System.Version] $installedPlatform, [Parameter(Mandatory=$false)] - [string] $installedCountry, + [string] $installedCountry = '', [Parameter(Mandatory=$false)] [PSCustomObject[]] $installedApps = @(), [ValidateSet('all','own','allButMicrosoft','allButApplication','allButPlatform','none')] @@ -75,6 +75,7 @@ Function Download-BcNuGetPackageToFolder { [switch] $allowPrerelease ) + $returnValue = $false $findSelect = $select if ($select -eq 'LatestMatching') { $findSelect = 'Latest' @@ -98,8 +99,10 @@ Function Download-BcNuGetPackageToFolder { foreach($dependency in $manifest.package.metadata.dependencies.GetEnumerator()) { $dependencyVersion = $dependency.Version $dependencyId = $dependency.Id + $dependencyCountry = '' $downloadIt = $false if ($dependencyId -eq 'Microsoft.Platform') { + $dependencyPublisher = 'Microsoft' # Dependency is to the platform if ($installedPlatform) { if (!([NuGetFeed]::IsVersionIncludedInRange($installedPlatform, $dependencyVersion))) { @@ -117,9 +120,10 @@ Function Download-BcNuGetPackageToFolder { if ($matches.Count -gt 2) { $dependencyCountry = $matches[2].TrimStart('.') } - else { - $dependencyCountry = '' - } + if ($installedCountry -and $dependencyCountry -and ($installedCountry -ne $dependencyCountry)) { + # The NuGet package found isn't compatible with the installed application + Write-Host "WARNING: NuGet package $packageId (version $packageVersion) requires $dependencyCountry application. You have $installedCountry application installed" + } $installedApp = $installedApps | Where-Object { $_ -and $_.Name -eq 'Application' } if ($installedApp) { if (!([NuGetFeed]::IsVersionIncludedInRange($installedApp.Version, $dependencyVersion))) { @@ -131,6 +135,14 @@ Function Download-BcNuGetPackageToFolder { } } else { + $dependencyPublisher = '' + if ($dependencyId -match '^([^\.]+)\.([^\.]+)\.([^\.]+\.)?([0-9A-Fa-f]{8}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{12})$') { + # Matches publisher.name.[country.].appId format (country section is only for microsoft apps) + $dependencyPublisher = $matches[1] + if ($dependencyPublisher -eq 'microsoft' -and $matches.Count -gt 3) { + $dependencyCountry = $matches[3].TrimEnd('.') + } + } $installedApp = $installedApps | Where-Object { $_ -and $_.id -and $dependencyId -like "*$($_.id)*" } if ($installedApp) { # Dependency is already installed, check version number @@ -139,29 +151,15 @@ Function Download-BcNuGetPackageToFolder { $dependenciesErr = "Dependency $dependencyId is already installed with version $($installedApp.Version), which is not compatible with the version $dependencyVersion required by the NuGet package $packageId (version $packageVersion))" } } - elseif ($downloadDependencies -eq 'all' -or $downloadDependencies -eq 'none' -or $downloadDependencies -eq 'allButPlatform' -or $downloadDependencies -eq 'allButMicrosoft' -or $downloadDependencies -eq 'allButApplication') { - $downloadIt = ($downloadDependencies -ne 'none') + elseif ($downloadDependencies -eq 'own') { + $downloadIt = ($dependencyPublisher -eq $manifest.package.authors) + } + elseif ($downloadDependencies -eq 'allButMicrosoft') { + # Download if publisher isn't Microsoft (including if publisher is empty) + $downloadIt = ($dependencyPublisher -ne 'Microsoft') } else { - # downloadDependencies is own or allButMicrosoft - # check publisher and name - if ($dependencyId -match '^(.*[^\.])\.(.*[^\.])\.("[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[0-9A-F]{12}")$') { - # Matches publisher.name.appId format - $dependencyPublisher = $matches[1] - $dependencyName = $matches[2] - $dependencyAppId = $matches[3] - if ($downloadDependencies -eq 'allButMicrosoft') { - $downloadIt = ($dependencyPublisher -ne 'Microsoft') - } - else { - $downloadIt = ($dependencyPublisher -eq $manifest.package.authors) - } - } - else { - # Could not match publisher.name.appId format - # All microsoft references should resolve - download it if we want allButMicrosoft - $downloadIt = ($downloadDependencies -eq 'allButMicrosoft') - } + $downloadIt = ($downloadDependencies -ne 'none') } } if ($dependenciesErr) { @@ -175,11 +173,36 @@ Function Download-BcNuGetPackageToFolder { } } if ($downloadIt) { + $checkPackageName = '' if ($dependencyId -match '^.*([0-9A-Fa-f]{8}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{4}\-[0-9A-Fa-f]{12})$') { # If dependencyId ends in a GUID (AppID) then use the AppId for downloading dependencies $dependencyId = $matches[1] + if ($dependencyCountry) { + # Dependency is to a specific country version - must find the country version of the dependency + $dependencyId = "$dependencyCountry.$dependencyId" + } + elseif ($installedCountry -and $dependencyPublisher -eq 'Microsoft') { + # Looking for a Microsoft package - check if it exists for the installed country (revert to appId if not) + $checkPackageName = "$installedCountry.$dependencyId" + } + } + elseif (($dependencyId -match '^Microsoft.Application(\.[^\.]+)?$') -and ($matches.Count -eq 1)) { + # If dependency is to the Application without a specific country, then check if a localization version of the application exists for the installed country + $checkPackageName = "Microsoft.Application.$installedCountry" + } + if ($checkPackageName) { + Write-Host -ForegroundColor Yellow $checkPackageName + if (Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $checkPackageName -version $dependencyVersion -folder $package -copyInstalledAppsToFolder $copyInstalledAppsToFolder -installedPlatform $installedPlatform -installedCountry $installedCountry -installedApps $installedApps -downloadDependencies $downloadDependencies -verbose:($VerbosePreference -eq 'Continue') -select $select -allowPrerelease:$allowPrerelease) { + $returnValue = $true + $downloadIt = $false + } + } + if ($downloadIt) { + Write-Host -ForegroundColor Yellow $dependencyId + if (Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $dependencyId -version $dependencyVersion -folder $package -copyInstalledAppsToFolder $copyInstalledAppsToFolder -installedPlatform $installedPlatform -installedCountry $installedCountry -installedApps $installedApps -downloadDependencies $downloadDependencies -verbose:($VerbosePreference -eq 'Continue') -select $select -allowPrerelease:$allowPrerelease) { + $returnValue = $true + } } - Download-BcNuGetPackageToFolder -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $dependencyId -version $dependencyVersion -folder $package -installedApps $installedApps -downloadDependencies $downloadDependencies -verbose:($VerbosePreference -eq 'Continue') -select $select } } if ($dependenciesErr) { @@ -188,17 +211,29 @@ Function Download-BcNuGetPackageToFolder { Remove-Item -Path $package -Recurse -Force continue } - $appFiles = (Get-Item -Path (Join-Path $package '*.app')).FullName - $appFiles | ForEach-Object { - Copy-Item $_ -Destination $folder -Force + if (Test-Path (Join-Path $package $installedCountry) -PathType Container) { + # NuGet packages of Runtime packages might exist in different versions for different countries + # The runtime package might contain C# invoke calls with different methodis for different countries + # if the installedCountry doesn't have a special version, then the w1 version is used (= empty string) + # If the package contains a country specific folder, then use that + Write-Host "Using country specific folder $installedCountry" + $appFiles = Get-Item -Path (Join-Path $package "$installedCountry/*.app") + } + else { + $appFiles = Get-Item -Path (Join-Path $package "*.app") + } + foreach($appFile in $appFiles) { + $returnValue = $true + Copy-Item $appFile.FullName -Destination $folder -Force if ($copyInstalledAppsToFolder) { - Copy-Item $_ -Destination $copyInstalledAppsToFolder -Force + Copy-Item $appFile.FullName -Destination $copyInstalledAppsToFolder -Force } } Remove-Item -Path $package -Recurse -Force break } } + return $returnValue } Set-Alias -Name Copy-BcNuGetPackageToFolder -Value Download-BcNuGetPackageToFolder Export-ModuleMember -Function Download-BcNuGetPackageToFolder -Alias Copy-BcNuGetPackageToFolder diff --git a/NuGet/Find-BcNuGetPackage.ps1 b/NuGet/Find-BcNuGetPackage.ps1 index b98be6f5c..4ccd57b30 100644 --- a/NuGet/Find-BcNuGetPackage.ps1 +++ b/NuGet/Find-BcNuGetPackage.ps1 @@ -82,7 +82,7 @@ Function Find-BcNuGetPackage { } elseif ($select -eq 'Exact') { # We only have a match if the version is exact - if ($packageVersion -eq $version) { + if ([NuGetFeed]::NormalizeVersionStr($packageVersion) -eq [NuGetFeed]::NormalizeVersionStr($version)) { $bestmatch = [PSCustomObject]@{ "Feed" = $nuGetFeed "PackageId" = $packageId diff --git a/NuGet/New-BcNuGetPackage.ps1 b/NuGet/New-BcNuGetPackage.ps1 index f08f66d3d..95d90d8fc 100644 --- a/NuGet/New-BcNuGetPackage.ps1 +++ b/NuGet/New-BcNuGetPackage.ps1 @@ -5,6 +5,8 @@ Create a new NuGet package containing a Business Central apps .Parameter appfile App file to include in the NuGet package + .Parameter countrySpecificAppFiles + Hashtable with country specific app files (runtime packages) to include in the NuGet package .Parameter packageId Id of the NuGet package (or template to generate the id, replacing {id}, {name} and {publisher} with the values from the app.json file) The default is '{publisher}.{name}.{id}' @@ -29,6 +31,8 @@ Template to calculate the id of the dependencies The template can contain {id}, {name} and {publisher} which will be replaced with the values from the corresponding dependency from app.json The default is '{publisher}.{name}.{id}' + .Parameter destinationFolder + Folder to create the NuGet package in. Defeault it to create a temporary folder and delete it after the NuGet package has been created .Example $package = New-BcNuGetPackage -appfile "C:\Users\freddyk\Downloads\MyBingMaps-main-Apps-1.0.3.0\Freddy Kristiansen_BingMaps.PTE_4.4.3.0.app" .Example @@ -40,6 +44,8 @@ Function New-BcNuGetPackage { [alias('appFiles')] [string] $appfile, [Parameter(Mandatory=$false)] + [hashtable] $countrySpecificAppFiles = @{}, + [Parameter(Mandatory=$false)] [string] $packageId = "{publisher}.{name}.{id}", [Parameter(Mandatory=$false)] [System.Version] $packageVersion = $null, @@ -64,6 +70,8 @@ Function New-BcNuGetPackage { [Parameter(Mandatory=$false)] [string] $runtimeDependencyId = '{publisher}.{name}.runtime-{version}', [switch] $isIndirectPackage, + [Parameter(Mandatory=$false)] + [string] $destinationFolder = '', [obsolete('NuGet Dependencies are always included.')] [switch] $includeNuGetDependencies ) @@ -80,11 +88,34 @@ Function New-BcNuGetPackage { throw "Unable to locate file: $_" } $appFile = (Get-Item $appfile).FullName - $rootFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([GUID]::NewGuid().ToString()) - New-Item -Path $rootFolder -ItemType Directory | Out-Null + if ($destinationFolder) { + $rootFolder = $destinationFolder + } + else { + $rootFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([GUID]::NewGuid().ToString()) + } + if (Test-Path $rootFolder) { + if (Get-ChildItem -Path $rootFolder) { + throw "Destination folder is not empty" + } + } + else { + New-Item -Path $rootFolder -ItemType Directory | Out-Null + } try { if (!$isIndirectPackage.IsPresent) { Copy-Item -Path $appFile -Destination $rootFolder -Force + if ($countrySpecificAppFiles) { + foreach($country in $countrySpecificAppFiles.Keys) { + $countrySpecificAppFile = $countrySpecificAppFiles[$country] + if (!(Test-Path $countrySpecificAppFile)) { + throw "Unable to locate file: $_" + } + $countryFolder = Join-Path $rootFolder $country + New-Item -Path $countryFolder -ItemType Directory | Out-Null + Copy-Item -Path $countrySpecificAppFile -Destination $countryFolder -Force + } + } } $appJson = GetAppJsonFromAppFile -appFile $appFile $packageId = $packageId.replace('{id}',$appJson.id).replace('{name}',[nuGetFeed]::Normalize($appJson.name)).replace('{publisher}',[nuGetFeed]::Normalize($appJson.publisher)).replace('{version}',$appJson.version.replace('.','-')) @@ -178,6 +209,16 @@ Function New-BcNuGetPackage { $XmlObjectWriter.WriteAttributeString("src", $appFileName ); $XmlObjectWriter.WriteAttributeString("target", $appFileName); $XmlObjectWriter.WriteEndElement() + if ($countrySpecificAppFiles) { + foreach($country in $countrySpecificAppFiles.Keys) { + $countrySpecificAppFile = $countrySpecificAppFiles[$country] + $XmlObjectWriter.WriteStartElement("file") + $appFileName = Join-Path $country ([System.IO.Path]::GetFileName($countrySpecificAppFiles[$country])) + $XmlObjectWriter.WriteAttributeString("src", $appFileName ); + $XmlObjectWriter.WriteAttributeString("target", $appFileName); + $XmlObjectWriter.WriteEndElement() + } + } $XmlObjectWriter.WriteEndElement() } $XmlObjectWriter.WriteEndElement() @@ -209,7 +250,9 @@ Function New-BcNuGetPackage { $nupkgFile } finally { - Remove-Item -Path $rootFolder -Recurse -Force -ErrorAction SilentlyContinue + if ($destinationFolder -ne $rootFolder) { + Remove-Item -Path $rootFolder -Recurse -Force -ErrorAction SilentlyContinue + } } } Export-ModuleMember -Function New-BcNuGetPackage diff --git a/NuGet/NuGetFeedClass.ps1 b/NuGet/NuGetFeedClass.ps1 index cb5bd1935..681aac76e 100644 --- a/NuGet/NuGetFeedClass.ps1 +++ b/NuGet/NuGetFeedClass.ps1 @@ -151,6 +151,19 @@ class NuGetFeed { return $name -replace '[^a-zA-Z0-9_\-]','' } + static [string] NormalizeVersionStr([string] $versionStr) { + $idx = $versionStr.IndexOf('-') + $version = [System.version]($versionStr.Split('-')[0]) + if ($version.Revision -eq -1) { $version = [System.Version]::new($version.Major, $version.Minor, $version.Build, 0) } + if ($version.Build -eq -1) { $version = [System.Version]::new($version.Major, $version.Minor, 0, $version.Revision) } + if ($idx -gt 0) { + return "$version$($versionStr.Substring($idx))" + } + else { + return "$version" + } + } + static [Int32] CompareVersions([string] $version1, [string] $version2) { $ver1 = $version1 -replace '-.+$' -as [System.Version] $ver2 = $version2 -replace '-.+$' -as [System.Version] @@ -227,12 +240,21 @@ class NuGetFeed { } [string] FindPackageVersion([string] $packageId, [string] $nuGetVersionRange, [string[]] $excludeVersions, [string] $select, [bool] $allowPrerelease) { - foreach($version in $this.GetVersions($packageId, ($select -ne 'Earliest'), $allowPrerelease)) { + $versions = $this.GetVersions($packageId, ($select -ne 'Earliest'), $allowPrerelease) + if ($excludeVersions) { + Write-Host "Exclude versions: $($excludeVersions -join ', ')" + } + foreach($version in $versions ) { if ($excludeVersions -contains $version) { continue } - if (($select -eq 'Exact' -and $nuGetVersionRange -eq $version) -or ($select -ne 'Exact' -and [NuGetFeed]::IsVersionIncludedInRange($version, $nuGetVersionRange))) { - Write-Host "$select version matching $nuGetVersionRange is $version" + if (($select -eq 'Exact' -and [NuGetFeed]::NormalizeVersionStr($nuGetVersionRange) -eq [NuGetFeed]::NormalizeVersionStr($version)) -or ($select -ne 'Exact' -and [NuGetFeed]::IsVersionIncludedInRange($version, $nuGetVersionRange))) { + if ($nuGetVersionRange -eq '0.0.0.0') { + Write-Host "$select version is $version" + } + else { + Write-Host "$select version matching '$nuGetVersionRange' is $version" + } return $version } } diff --git a/NuGet/Publish-BcNuGetPackageToContainer.ps1 b/NuGet/Publish-BcNuGetPackageToContainer.ps1 index 123706494..e6a49f191 100644 --- a/NuGet/Publish-BcNuGetPackageToContainer.ps1 +++ b/NuGet/Publish-BcNuGetPackageToContainer.ps1 @@ -89,9 +89,8 @@ Function Publish-BcNuGetPackageToContainer { $tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([GUID]::NewGuid().ToString()) New-Item $tmpFolder -ItemType Directory | Out-Null try { - 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 - if ($appFiles) { + 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 Publish-BcContainerApp -containerName $containerName -bcAuthContext $bcAuthContext -environment $environment -tenant $tenant -appFile $appFiles -sync -install -upgrade -checkAlreadyInstalled -skipVerification -copyInstalledAppsToFolder $copyInstalledAppsToFolder } else { diff --git a/Saas/Publish-PerTenantExtensionApps.ps1 b/Saas/Publish-PerTenantExtensionApps.ps1 index c4bf74a4e..1b87dcaad 100644 --- a/Saas/Publish-PerTenantExtensionApps.ps1 +++ b/Saas/Publish-PerTenantExtensionApps.ps1 @@ -122,11 +122,8 @@ try { try { Sort-AppFilesByDependencies -appFiles $appFiles -excludeRuntimePackages | ForEach-Object { Write-Host -NoNewline "$([System.IO.Path]::GetFileName($_)) - " - $tempFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([guid]::NewGuid().ToString()) - Extract-AppFileToFolder -appFilename $_ -appFolder $tempFolder -generateAppJson 6> $null - $appJsonFile = Join-Path $tempFolder "app.json" - $appJson = [System.IO.File]::ReadAllLines($appJsonFile) | ConvertFrom-Json - Remove-Item -Path $tempFolder -Force -Recurse + $appJson = GetAppJsonFromAppFile -appFile $_ + $existingApp = $extensions | Where-Object { $_.id -eq $appJson.id -and $_.isInstalled } if ($existingApp) { if ($existingApp.isInstalled) {