Skip to content

Commit

Permalink
Nuget fixes (#3670)
Browse files Browse the repository at this point in the history
NuGet feeds didn't work when using Containers / FilesOnly Containers

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
  • Loading branch information
freddydk and freddydk committed Sep 18, 2024
1 parent 2995fcd commit 140595c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 57 deletions.
34 changes: 1 addition & 33 deletions AppHandling/Compile-AppInNavContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -263,39 +263,7 @@ try {
}

if ($CopySymbolsFromContainer) {
Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($appSymbolsFolder)
if (Test-Path "C:\Extensions\*.app") {
$paths = @(
"C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app"
"C:\Extensions\*.app"
)
}
else {
$paths = @(
"C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app"
"C:\Applications.*\Microsoft_Application_*.app,C:\Applications\Application\Source\Microsoft_Application.app"
"C:\Applications.*\Microsoft_Base Application_*.app,C:\Applications\BaseApp\Source\Microsoft_Base Application.app"
"C:\Applications.*\Microsoft_System Application_*.app,C:\Applications\System Application\source\Microsoft_System Application.app"
"C:\Applications.*\Microsoft_Business Foundation_*.app,C:\Applications\BusinessFoundation\source\Microsoft_Business Foundation.app"
)
}
$paths | ForEach-Object {
$appFiles = $_.Split(',')
$appFile = ""
if (Test-Path -Path $appFiles[0]) {
$appFile = $appFiles[0]
}
elseif (Test-Path -path $appFiles[1]) {
$appFile = $appFiles[1]
}
if ($appFile) {
Get-Item -Path $appFile | ForEach-Object {
Write-Host "Copying $([System.IO.Path]::GetFileName($_.FullName)) from Container"
Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force
}
}
}
} -argumentList $containerSymbolsFolder
CopySymbolsFromContainer -containerName $containerName -containerSymbolsFolder $containerSymbolsFolder
}

$GenerateReportLayoutParam = ""
Expand Down
48 changes: 25 additions & 23 deletions AppHandling/Run-AlPipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,17 @@ function GetInstalledAppIds {
$compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $compilerFolder 'symbols/*.app') | Select-Object -ExpandProperty FullName)
$installedApps += @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $compilerFolder 'symbols/cache_AppInfo.json'))
}
elseif (!$filesOnly) {
$installedApps = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters)
elseif ($filesOnly) {
$installedApps = Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | ForEach-Object {
$appJson = Get-AppJsonFromAppFile -appFile $_.FullName
return @{
"appId" = $appJson.id
"name" = $appJson.name
}
}
}
else {
$installedApps = @()
$installedApps = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters)
}
Write-GroupStart -Message "Installed Apps"
$installedApps | ForEach-Object {
Expand Down Expand Up @@ -967,7 +973,7 @@ $testCountry = $_.Trim()
$testToolkitInstalled = $false

if ($useCompilerFolder) {
Write-GroupStart -Message "Creating container"
Write-GroupStart -Message "Creating CompilerFolder"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ _ _ ______ _ _
Expand All @@ -981,7 +987,7 @@ if ($useCompilerFolder) {
'@
}
else {
if ($gitHubActions) { Write-Host "::group::Creating container" }
Write-GroupStart -Message "Creating Container"
Write-Host -ForegroundColor Yellow @'
_____ _ _ _____ _ _
Expand Down Expand Up @@ -1113,6 +1119,14 @@ Measure-Command {
}
}
}
if ($CopySymbolsFromContainer) {
$containerSymbolsFolder = Get-BcContainerPath -containerName $containerName -path $packagesFolder
if ("$containerSymbolsFolder" -eq "") {
throw "The appSymbolsFolder ($appSymbolsFolder) is not shared with the container."
}
CopySymbolsFromContainer -containerName $containerName -containerSymbolsFolder $containerSymbolsFolder
$CopySymbolsFromContainer = $false
}
}

} | ForEach-Object { Write-Host -ForegroundColor Yellow "`nCreating container took $([int]$_.TotalSeconds) seconds" }
Expand Down Expand Up @@ -1324,13 +1338,9 @@ Measure-Command {
$missingAppDependencies | ForEach-Object { Write-Host "- $_" }
$Parameters = @{
"missingDependencies" = @($unknownAppDependencies | Where-Object { $missingAppDependencies -contains "$_".Split(':')[0] })
"appSymbolsFolder" = $packagesFolder
}
if ($useCompilerFolder -or $filesOnly) {
$Parameters += @{
"appSymbolsFolder" = $packagesFolder
}
}
else {
if (!($useCompilerFolder -or $filesOnly)) {
$Parameters += @{
"containerName" = $containerName
"tenant" = $tenant
Expand Down Expand Up @@ -1477,13 +1487,9 @@ Measure-Command {
$missingTestAppDependencies | ForEach-Object { Write-Host "- $_" }
$Parameters = @{
"missingDependencies" = @($unknownTestAppDependencies | Where-Object { $missingTestAppDependencies -contains "$_".Split(':')[0] })
"appSymbolsFolder" = $packagesFolder
}
if ($useCompilerFolder -or $filesOnly) {
$Parameters += @{
"appSymbolsFolder" = $packagesFolder
}
}
else {
if (!($useCompilerFolder -or $filesOnly)) {
$Parameters += @{
"containerName" = $containerName
"tenant" = $tenant
Expand Down Expand Up @@ -1656,13 +1662,9 @@ Measure-Command {
$missingTestAppDependencies | ForEach-Object { Write-Host "- $_" }
$Parameters = @{
"missingDependencies" = @($unknownTestAppDependencies | Where-Object { $missingTestAppDependencies -contains "$_".Split(':')[0] })
"appSymbolsFolder" = $packagesFolder
}
if ($useCompilerFolder -or $filesOnly) {
$Parameters += @{
"appSymbolsFolder" = $packagesFolder
}
}
else {
if (!($useCompilerFolder -or $filesOnly)) {
$Parameters += @{
"containerName" = $containerName
"tenant" = $tenant
Expand Down
41 changes: 41 additions & 0 deletions HelperFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,44 @@ function Write-GroupEnd {
$bcContainerHelperConfig.IsAzureDevOps { Write-Host "##[endgroup]"; break }
}
}

function CopySymbolsFromContainer {
Param(
[string] $containerName,
[string] $containerSymbolsFolder
)

Invoke-ScriptInBcContainer -containerName $containerName -scriptblock { Param($appSymbolsFolder)
if (Test-Path "C:\Extensions\*.app") {
$paths = @(
"C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app"
"C:\Extensions\*.app"
)
}
else {
$paths = @(
"C:\Program Files\Microsoft Dynamics NAV\*\AL Development Environment\System.app"
"C:\Applications.*\Microsoft_Application_*.app,C:\Applications\Application\Source\Microsoft_Application.app"
"C:\Applications.*\Microsoft_Base Application_*.app,C:\Applications\BaseApp\Source\Microsoft_Base Application.app"
"C:\Applications.*\Microsoft_System Application_*.app,C:\Applications\System Application\source\Microsoft_System Application.app"
"C:\Applications.*\Microsoft_Business Foundation_*.app,C:\Applications\BusinessFoundation\source\Microsoft_Business Foundation.app"
)
}
$paths | ForEach-Object {
$appFiles = $_.Split(',')
$appFile = ""
if (Test-Path -Path $appFiles[0]) {
$appFile = $appFiles[0]
}
elseif (Test-Path -path $appFiles[1]) {
$appFile = $appFiles[1]
}
if ($appFile) {
Get-Item -Path $appFile | ForEach-Object {
Write-Host "Copying $([System.IO.Path]::GetFileName($_.FullName)) from Container"
Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force
}
}
}
} -argumentList $containerSymbolsFolder
}
8 changes: 7 additions & 1 deletion NuGet/Publish-BcNuGetPackageToContainer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Function Publish-BcNuGetPackageToContainer {
[string] $environment,
[Parameter(Mandatory=$false)]
[string] $tenant = "default",
[string] $appSymbolsFolder = "",
[string] $copyInstalledAppsToFolder = "",
[switch] $skipVerification
)
Expand All @@ -80,7 +81,12 @@ Function Publish-BcNuGetPackageToContainer {
New-Item $tmpFolder -ItemType Directory | Out-Null
try {
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
$appFiles = Get-Item -Path (Join-Path $tmpFolder '*.app') | ForEach-Object {
if ($appSymbolsFolder) {
Copy-Item -Path $_.FullName -Destination $appSymbolsFolder -Force
}
$_.FullName
}
Publish-BcContainerApp -containerName $containerName -bcAuthContext $bcAuthContext -environment $environment -tenant $tenant -appFile $appFiles -sync -install -upgrade -checkAlreadyInstalled -skipVerification -copyInstalledAppsToFolder $copyInstalledAppsToFolder
}
else {
Expand Down

0 comments on commit 140595c

Please sign in to comment.