Refactor app download logic for code reuse between UI and CLI

Moves the `Start-WingetAppDownloadTask` function from the UI module to the common module to enable parallel app downloads in both CLI and UI build paths. This eliminates code duplication and ensures consistent download behavior across build modes.

Updates the `Get-Apps` function to leverage parallel processing instead of sequential iteration, improving performance when downloading multiple applications. Adds support for `LogFilePath` and `ThrottleLimit` parameters to control logging and concurrency.

Introduces a `SkipWin32Json` parameter to differentiate behavior between UI mode (skips JSON generation) and CLI mode (creates JSON for installation). This allows the same download task to work correctly in both contexts.

Updates all callers of `Get-Apps` to pass the new parameters, ensuring proper logging and parallel execution configuration across the build pipeline.
This commit is contained in:
rbalsleyMSFT
2025-11-29 16:29:52 -08:00
parent 2273cffbc2
commit 8d84137a27
4 changed files with 378 additions and 362 deletions
@@ -156,7 +156,7 @@ function Invoke-ParallelProcessing {
# Execute the appropriate background task based on $localTaskType
switch ($localTaskType) {
'WingetDownload' {
# Pass the progress queue to the task function
# Pass the progress queue and SkipWin32Json to the task function
$wingetTaskArgs = @{
ApplicationItemData = $currentItem
AppListJsonPath = $localJobArgs['AppListJsonPath']
@@ -164,6 +164,7 @@ function Invoke-ParallelProcessing {
OrchestrationPath = $localJobArgs['OrchestrationPath']
ProgressQueue = $localProgressQueue
WindowsArch = $localJobArgs['WindowsArch']
SkipWin32Json = [bool]$localJobArgs['SkipWin32Json']
}
$taskResult = Start-WingetAppDownloadTask @wingetTaskArgs
if ($null -ne $taskResult) {