Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Saas/Publish-PerTenantExtensionApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Azure DevOps doesn't update logs until a newline is added.
.Parameter hideInstalledExtensionsOutput
Add this parameter to hide the output that lists installed extensions on the specified environment before and after installation of new and updated PTE extensions.
.Parameter unpublishOldVersions
Add this switch to unpublish old versions of apps after upgrading to a new version.
#>
function Publish-PerTenantExtensionApps {
[CmdletBinding(DefaultParameterSetName="AC")]
Expand All @@ -45,7 +47,8 @@ function Publish-PerTenantExtensionApps {
[ValidateSet('','Current version','Next minor version','Next major version')]
[string] $schedule = '',
[switch] $useNewLine,
[switch] $hideInstalledExtensionsOutput
[switch] $hideInstalledExtensionsOutput,
[switch] $unpublishOldVersions
)

$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
Expand Down Expand Up @@ -146,6 +149,7 @@ try {
}
else {
Write-Host @newLine "upgrading"
$oldApp = $existingApp
$existingApp = $null
}
}
Expand Down Expand Up @@ -242,6 +246,13 @@ try {
Write-Host "Error: $($_.Exception.Message). Retrying in $sleepSeconds seconds"
}
}
if ($unpublishOldVersions -and $oldApp -and ($appDepVer -ge [System.Version]"25.4.0.0")) { # New unpublish API available from 25.4
Write-Host @newLine "Unpublishing old version"
Invoke-RestMethod `
-Method Post `
-Uri "$automationApiUrl/companies($companyId)/extensions($($oldApp.packageId))/Microsoft.NAV.unpublish" `
-Headers (GetAuthHeaders) | Out-Null
}
}
}
}
Expand Down