Skip to content

Commit c083763

Browse files
authored
NuGet changes (#3264)
Rename appinfo cache from AppInfo.json to cache_AppInfo.json (in order for it to be picked up by .gitignore) Proof of concept functionality for NuGet feeds: - Add trusted feeds to ContainerHelper settings. - Search all trusted feeds for packages in Get-BcNuGetPackage - Some refactoring of NuGet code - Allow searching for Earliest, Latest, Any or Exact version of NuGet package - Support NuGet Versioning schema --------- Co-authored-by: freddydk <[email protected]>
1 parent 943df1d commit c083763

20 files changed

+972
-342
lines changed

AppHandling/Publish-NavContainerApp.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ try {
140140
$force = $true
141141
if ($checkAlreadyInstalled) {
142142
if ($isCloudBcContainer) {
143-
$installedApps = Invoke-ScriptInAlpacaBcContainer -authContext $bcAuthContext -containerId $environment -scriptblock {
143+
$installedApps = Invoke-ScriptInCloudBcContainer -authContext $bcAuthContext -containerId $environment -scriptblock {
144144
Get-NAVAppInfo -ServerInstance $serverInstance -TenantSpecificProperties -tenant 'default' | Where-Object { $_.IsInstalled -eq $true } | ForEach-Object { Get-NAVAppInfo -ServerInstance $serverInstance -TenantSpecificProperties -tenant 'default' -id $_.AppId -publisher $_.publisher -name $_.name -version $_.Version }
145145
}
146146
}

AppHandling/Run-AlPipeline.ps1

+31-22
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,34 @@ Function UpdateLaunchJson {
439439

440440
}
441441

442+
function GetInstalledAppIds {
443+
Param(
444+
[bool] $useCompilerFolder,
445+
[string] $packagesFolder,
446+
[string] $compilerFolder,
447+
[bool] $filesOnly,
448+
[hashtable] $Parameters
449+
)
450+
if ($useCompilerFolder) {
451+
$existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | Select-Object -ExpandProperty FullName)
452+
$installedApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $packagesFolder 'cache_AppInfo.json'))
453+
$installedAppIds = @($installedApps | ForEach-Object { $_.AppId } )
454+
$compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $compilerFolder 'symbols/*.app') | Select-Object -ExpandProperty FullName)
455+
$installedAppIds += @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $compilerFolder 'symbols/cache_AppInfo.json') | ForEach-Object { $_.AppId } )
456+
457+
}
458+
elseif (!$filesOnly) {
459+
$installedAppIds = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters | ForEach-Object { $_.AppId })
460+
}
461+
else {
462+
$installedAppIds = @()
463+
}
464+
Write-Host "::group::Installed AppIds"
465+
$installedAppIds | ForEach-Object { Write-Host "- $_" }
466+
Write-Host "::endgroup::"
467+
return $installedAppIds
468+
}
469+
442470
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
443471
try {
444472

@@ -1222,16 +1250,7 @@ $Parameters = @{
12221250
"containerName" = $containerName
12231251
"tenant" = $tenant
12241252
}
1225-
if ($useCompilerFolder) {
1226-
$existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | Select-Object -ExpandProperty FullName)
1227-
$installedAppIds = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $packagesFolder 'AppInfoCache.json') | ForEach-Object { $_.AppId } )
1228-
}
1229-
elseif (!$filesOnly) {
1230-
$installedAppIds = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters | Select-Object -ExpandProperty 'AppId')
1231-
}
1232-
else {
1233-
$installedAppIds = @()
1234-
}
1253+
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
12351254
$missingAppDependencies = @($missingAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
12361255
if ($missingAppDependencies) {
12371256
if ($gitHubActions) { Write-Host "::group::Installing app dependencies" }
@@ -1378,17 +1397,7 @@ $Parameters = @{
13781397
"containerName" = $containerName
13791398
"tenant" = $tenant
13801399
}
1381-
if ($useCompilerFolder) {
1382-
$existingAppFiles = @(Get-ChildItem -Path (Join-Path $packagesFolder '*.app') | Select-Object -ExpandProperty FullName)
1383-
$installedApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $packagesFolder 'AppInfoCache.json'))
1384-
$installedAppIds = @($installedApps | ForEach-Object { $_.AppId } )
1385-
}
1386-
elseif (!$filesOnly) {
1387-
$installedAppIds = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters | ForEach-Object { $_.AppId })
1388-
}
1389-
else {
1390-
$installedAppIds = @()
1391-
}
1400+
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
13921401
$missingTestAppDependencies = @($missingTestAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
13931402
if ($missingTestAppDependencies) {
13941403
if ($gitHubActions) { Write-Host "::group::Installing test app dependencies" }
@@ -1561,7 +1570,7 @@ $Parameters = @{
15611570
"containerName" = $containerName
15621571
"tenant" = $tenant
15631572
}
1564-
$installedAppIds = @(Invoke-Command -ScriptBlock $GetBcContainerAppInfo -ArgumentList $Parameters | Select-Object -ExpandProperty 'AppId')
1573+
$installedAppIds = @(GetInstalledAppIds -useCompilerFolder $useCompilerFolder -filesOnly $filesOnly -compilerFolder $compilerFolder -packagesFolder $packagesFolder -Parameters $Parameters)
15651574
$missingTestAppDependencies = @($missingTestAppDependencies | Where-Object { $installedAppIds -notcontains $_ })
15661575
if ($missingTestAppDependencies) {
15671576
if ($gitHubActions) { Write-Host "::group::Installing test app dependencies" }

BC.HelperFunctions.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function Get-ContainerHelperConfig {
7979
"tt" = "br"
8080
"uy" = "br"
8181
"zw" = "w1"
82+
"im" = "gb"
83+
"gg" = "gb"
8284
}
8385
"mapNetworkSettings" = [PSCustomObject]@{
8486
}
@@ -108,6 +110,8 @@ function Get-ContainerHelperConfig {
108110
"OAuthHostName" = "b52e8b6a-2953-4a08-8e28-5cf45a2dffdc"
109111
"OAuthScopes" = "api://b52e8b6a-2953-4a08-8e28-5cf45a2dffdc/.default offline_access"
110112
}
113+
"TrustedNuGetFeeds" = @(
114+
)
111115
}
112116

113117
if ($isInsider) {

BC.NuGetHelper.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# NuGet specific functions
2+
if (-not (([System.Management.Automation.PSTypeName]"NuGetFeed").Type)) {
3+
. (Join-Path $PSScriptRoot "NuGet\NuGetFeedClass.ps1")
4+
}
25
. (Join-Path $PSScriptRoot "NuGet\New-BcNuGetPackage.ps1")
6+
. (Join-Path $PSScriptRoot "NuGet\Find-BcNuGetPackage.ps1")
37
. (Join-Path $PSScriptRoot "NuGet\Get-BcNuGetPackage.ps1")
48
. (Join-Path $PSScriptRoot "NuGet\Push-BcNuGetPackage.ps1")
59
. (Join-Path $PSScriptRoot "NuGet\Publish-BcNuGetPackageToContainer.ps1")
6-
. (Join-Path $PSScriptRoot "NuGet\Copy-BcNuGetPackageToFolder.ps1")
10+
. (Join-Path $PSScriptRoot "NuGet\Download-BcNuGetPackageToFolder.ps1")

BC.NuGetHelper.psd1

116 Bytes
Binary file not shown.

BcContainerHelper.psd1

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ FunctionsToExport = 'Add-FontsToBcContainer', 'Add-GitToAlProjectFolder',
7878
'Convert-ModifiedObjectsToAl', 'ConvertTo-HashTable',
7979
'ConvertTo-OrderedDictionary', 'Convert-Txt2Al', 'Copy-AlSourceFiles',
8080
'Copy-AppFilesToCompilerFolder', 'Copy-BcEnvironment',
81-
'Copy-BcNuGetPackageToFolder', 'Copy-CompanyInBcContainer',
81+
'Download-BcNuGetPackageToFolder', 'Copy-CompanyInBcContainer',
8282
'Copy-FileFromBcContainer', 'Copy-FileFromCloudBcContainer',
8383
'Copy-FileToBcContainer', 'Copy-FileToCloudBcContainer',
8484
'Copy-ItemFromBcContainer', 'Copy-ItemToBcContainer',
@@ -115,7 +115,7 @@ FunctionsToExport = 'Add-FontsToBcContainer', 'Add-GitToAlProjectFolder',
115115
'Get-BcEnvironmentOperations', 'Get-BcEnvironmentPublishedApps',
116116
'Get-BcEnvironments', 'Get-BcEnvironmentScheduledUpgrade',
117117
'Get-BcEnvironmentUpdateWindow', 'Get-BcEnvironmentUsedStorage',
118-
'Get-BcNotificationRecipients', 'Get-BcNuGetPackage',
118+
'Get-BcNotificationRecipients', 'Find-BcNuGetPackage', 'Get-BcNuGetPackage',
119119
'Get-BestBcContainerImageName', 'Get-BestGenericImageName',
120120
'Get-CloudBcContainerEventLog',
121121
'Get-CloudBcContainerServerConfiguration',
@@ -195,7 +195,7 @@ AliasesToExport = 'Add-FontsToNavContainer', 'Backup-NavContainerDatabases',
195195
'Convert-AlcOutputToAzureDevOps', 'Copy-CompanyInNavContainer',
196196
'Copy-FileFromAlpacaBcContainer', 'Copy-FileFromNavContainer',
197197
'Copy-FileToAlpacaBcContainer', 'Copy-FileToNavContainer',
198-
'Create-AadAppsForBC', 'Create-AadUsersInNavContainer',
198+
'Copy-BcNuGetPackageToFolder', 'Create-AadAppsForBC', 'Create-AadUsersInNavContainer',
199199
'Create-AlProjectFolderFromNavContainer', 'Enter-NavContainer',
200200
'Export-NavContainerDatabasesAsBacpac',
201201
'Extract-FilesFromNavContainerImage',

CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ try {
174174

175175
Write-Host "Enumerating Apps in CompilerFolder $symbolsPath"
176176
$compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName)
177-
$compilerFolderApps = @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'AppInfoCache.json'))
177+
$compilerFolderApps = @(GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'cache_AppInfo.json'))
178178

179179
Write-Host "Enumerating Apps in Symbols Folder $appSymbolsFolder"
180180
$existingAppFiles = @(Get-ChildItem -Path (Join-Path $appSymbolsFolder '*.app') | Select-Object -ExpandProperty FullName)
181-
$existingApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $appSymbolsFolder 'AppInfoCache.json'))
181+
$existingApps = @(GetAppInfo -AppFiles $existingAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $appSymbolsFolder 'cache_AppInfo.json'))
182182

183183
$depidx = 0
184184
while ($depidx -lt $dependencies.Count) {

CompilerFolderHandling/Copy-AppFilesToCompilerFolder.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Copy-AppFilesToCompilerFolder {
3131
Write-Host "Copy app files to compiler folder"
3232
$symbolsPath = Join-Path $compilerFolder 'symbols'
3333
$compilerFolderAppFiles = @(Get-ChildItem -Path (Join-Path $symbolsPath '*.app') | Select-Object -ExpandProperty FullName)
34-
$compilerFolderApps = GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'AppInfoCache.json')
34+
$compilerFolderApps = GetAppInfo -AppFiles $compilerFolderAppFiles -compilerFolder $compilerFolder -cacheAppinfoPath (Join-Path $symbolsPath 'cache_AppInfo.json')
3535
if ($checkAlreadyInstalled) {
3636
$appFiles = @(Sort-AppFilesByDependencies -appFiles $appFiles -includeOnlyAppIds $includeOnlyAppIds -excludeInstalledApps $compilerFolderApps -WarningAction SilentlyContinue)
3737
}

ContainerHandling/Restart-NavContainer.ps1

+12-9
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,21 @@ function Restart-BcContainer {
2626
$telemetryScope = InitTelemetryScope -name $MyInvocation.InvocationName -parameterValues $PSBoundParameters -includeParameters @()
2727
try {
2828

29-
if ($renewBindings) {
30-
if ((docker inspect -f '{{.State.Running}}' $containerName) -eq "true") {
31-
Invoke-ScriptInBcContainer -containerName $containerName -ScriptBlock {
32-
Set-Content -Path "c:\run\PublicDnsName.txt" -Value ""
33-
}
34-
}
35-
else {
36-
$tempFile = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
29+
if ((docker inspect -f '{{.State.Running}}' $containerName) -eq "true") {
30+
Invoke-ScriptInBcContainer -containerName $containerName -useSession:$false -ScriptBlock { Param( $renewBindings )
31+
if ($renewBindings) { Set-Content -Path "c:\run\PublicDnsName.txt" -Value "" }
32+
Set-Content -Path "c:\run\startcount.txt" -Value "0"
33+
} -argumentList $renewBindings.IsPresent
34+
}
35+
else {
36+
$tempFile = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
37+
if ($renewBindings) {
3738
Set-Content -Path $tempFile -Value ""
3839
docker cp $tempFile "$($containerName):c:\run\PublicDnsName.txt"
39-
Remove-Item -Path $tempFile
4040
}
41+
Set-Content -Path $tempFile -Value "0"
42+
docker cp $tempFile "$($containerName):c:\run\startcount.txt"
43+
Remove-Item -Path $tempFile
4144
}
4245

4346
Write-Host "Removing Session $containerName"

HelperFunctions.ps1

+7-5
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ function Expand-7zipArchive {
363363
[Parameter(Mandatory = $true)]
364364
[string] $Path,
365365
[string] $DestinationPath,
366-
[switch] $use7zipIfAvailable = $bcContainerHelperConfig.use7zipIfAvailable
366+
[switch] $use7zipIfAvailable = $bcContainerHelperConfig.use7zipIfAvailable,
367+
[switch] $silent
367368
)
368369

369370
$7zipPath = "$env:ProgramFiles\7-Zip\7z.exe"
@@ -378,7 +379,7 @@ function Expand-7zipArchive {
378379
}
379380

380381
if ($use7zip) {
381-
Write-Host "using 7zip"
382+
if (!$silent) { Write-Host "using 7zip" }
382383
Set-Alias -Name 7z -Value $7zipPath
383384
$command = '7z x "{0}" -o"{1}" -aoa -r' -f $Path, $DestinationPath
384385
$global:LASTEXITCODE = 0
@@ -388,7 +389,7 @@ function Expand-7zipArchive {
388389
}
389390
}
390391
else {
391-
Write-Host "using Expand-Archive"
392+
if (!$silent) { Write-Host "using Expand-Archive" }
392393
if ([System.IO.Path]::GetExtension($path) -eq '.zip') {
393394
Expand-Archive -Path $Path -DestinationPath "$DestinationPath" -Force
394395
}
@@ -1114,7 +1115,7 @@ function GetAppInfo {
11141115
$appInfoCache = @{}
11151116
}
11161117
}
1117-
Write-Host "Getting .app info"
1118+
Write-Host "::group::Getting .app info $cacheAppInfoPath"
11181119
$binPath = Join-Path $compilerFolder 'compiler/extension/bin'
11191120
if ($isLinux) {
11201121
$alcPath = Join-Path $binPath 'linux'
@@ -1185,7 +1186,7 @@ function GetAppInfo {
11851186
}
11861187
}
11871188
Write-Host " (succeeded)"
1188-
if ($appInfoCache) {
1189+
if ($cacheAppInfoPath) {
11891190
$appInfoCache | Add-Member -MemberType NoteProperty -Name $path -Value $appInfo
11901191
$cacheUpdated = $true
11911192
}
@@ -1224,6 +1225,7 @@ function GetAppInfo {
12241225
$packageStream.Dispose()
12251226
}
12261227
}
1228+
Write-Host "::endgroup::"
12271229
}
12281230

12291231
function GetLatestAlLanguageExtensionUrl {

NuGet/Copy-BcNuGetPackageToFolder.ps1

-37
This file was deleted.

0 commit comments

Comments
 (0)