Skip to content

Commit a399bbd

Browse files
authored
Hacky temp workaround for #3591 (#3756)
Fixes #3591 --------- Co-authored-by: freddydk <[email protected]>
1 parent 0a70669 commit a399bbd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

AppHandling/Publish-NavContainerApp.ps1

+17-3
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ try {
288288
}
289289
}
290290
else {
291-
[ScriptBlock] $scriptblock = { Param($appFile, $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists)
291+
[ScriptBlock] $scriptblock = { Param($appFile, $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists, $version)
292292
$prevPreference = $ProgressPreference; $ProgressPreference = "SilentlyContinue"
293293
$publishArgs = @{ "packageType" = $packageType }
294294
if ($scope) {
@@ -328,7 +328,21 @@ try {
328328

329329
if ($publishIt) {
330330
Write-Host "Publishing $appFile"
331-
Publish-NavApp -ServerInstance $ServerInstance -Path $appFile -SkipVerification:$SkipVerification @publishArgs
331+
$publishArgs += @{"serverInstance" = $serverInstance; "Path" = $appFile; "SkipVerification" = $skipVerification.IsPresent}
332+
if ($PSVersionTable.PSVersion.Major -lt 7 -and $version.Major -ge 24) {
333+
# GIANT HACK AHEAD...
334+
# To cope with this issue https://github.com/microsoft/navcontainerhelper/issues/3591 where the PS5 bridge to PS7 hangs when calling Publish-NavApp directly
335+
# and due to https://github.com/microsoft/navcontainerhelper/issues/3575 and https://github.com/PowerShell/PowerShell/issues/23982 we cannot use -usepwsh:$true
336+
$command = '$serviceTierFolder = (Get-Item ''C:\Program Files\Microsoft Dynamics NAV\*\Service'').FullName;Import-Module (Join-Path $serviceTierFolder ''Admin\Microsoft.Dynamics.Nav.Management.psm1'');Import-Module (Join-Path $serviceTierFolder ''Admin\Microsoft.BusinessCentral.Management.psd1'');Import-Module (Join-Path $serviceTierFolder ''Admin\Microsoft.BusinessCentral.Apps.Management.dll'');'
337+
$command += "Publish-NavApp $(($publishArgs.Keys | ForEach-Object { $v=$publishArgs."$_"; if($v -is [boolean]){"-$($_):`$$($publishArgs."$_")"}elseif($v -is [string]){"-$($_):'$($publishArgs."$_")'"}else{"-$($_):$($publishArgs."$_")"} }) -join ' ')"
338+
pwsh -command "$($command.Replace('"','""'))" | Out-Host
339+
if ($LASTEXITCODE -ne 0) {
340+
throw "Publish-NavApp failed"
341+
}
342+
}
343+
else {
344+
Publish-NavApp @publishArgs
345+
}
332346
}
333347

334348
if ($sync -or $install -or $upgrade) {
@@ -379,7 +393,7 @@ try {
379393
Invoke-ScriptInBcContainer `
380394
-containerName $containerName `
381395
-ScriptBlock $scriptblock `
382-
-ArgumentList (Get-BcContainerPath -containerName $containerName -path $appFile), $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists
396+
-ArgumentList (Get-BcContainerPath -containerName $containerName -path $appFile), $skipVerification, $sync, $install, $upgrade, $tenant, $syncMode, $packageType, $scope, $language, $PublisherAzureActiveDirectoryTenantId, $force, $ignoreIfAppExists, $version
383397
}
384398
Write-Host -ForegroundColor Green "App $([System.IO.Path]::GetFileName($appFile)) successfully published"
385399
}

ReleaseNotes.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
6.0.29
2+
Issue 3591 When using Publish-NAVApp to publish an app, which fails compilation in the service, the command might hang forever - the fix for this is a temporary hack put in place for the versions which doesn't work.
23

34
6.0.28
45
Set useApproximateVersion to true in settings to increase performance of Get-BcArtifactUrl when selecting latest artifact, by using an approximate filtering on blobs

0 commit comments

Comments
 (0)