From 62b481649893f236b8a088ec244384649de14cbd Mon Sep 17 00:00:00 2001
From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com>
Date: Thu, 17 Jul 2025 16:50:38 -0700
Subject: [PATCH] Improves application orchestration and BYO app handling
Enhances the orchestrator script to skip application installation steps if no corresponding app lists or files are present. This prevents unnecessary script executions and cleans up the output log.
Makes the 'Arguments' field optional when adding a 'Bring Your Own' application, simplifying the process for apps without arguments.
Ensures the 'Priority' field for applications is consistently saved as an integer to improve data integrity.
---
.../Apps/Orchestration/Orchestrator.ps1 | 25 +++++++++++++++++--
FFUDevelopment/BuildFFUVM_UI.xaml | 2 +-
.../FFUUI.Core/FFUUI.Core.Applications.psm1 | 10 ++++----
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/FFUDevelopment/Apps/Orchestration/Orchestrator.ps1 b/FFUDevelopment/Apps/Orchestration/Orchestrator.ps1
index 70badd8..ed02432 100644
--- a/FFUDevelopment/Apps/Orchestration/Orchestrator.ps1
+++ b/FFUDevelopment/Apps/Orchestration/Orchestrator.ps1
@@ -39,10 +39,31 @@ $scriptList = @(
"Install-StoreApps.ps1",
"Install-UserApps.ps1"
)
-# Check if each script exists and run it if it does
+# Check if each script exists and has content to process, then run it
foreach ($script in $scriptList) {
$scriptFile = Join-Path -Path $scriptPath -ChildPath $script
- if (Test-Path -Path $scriptFile) {
+ if (-not (Test-Path -Path $scriptFile)) {
+ continue
+ }
+
+ $shouldRun = $true # Default to run if script exists
+ switch ($script) {
+ "Install-Win32Apps.ps1" {
+ $wingetAppsJsonFile = Join-Path -Path $scriptPath -ChildPath "WinGetWin32Apps.json"
+ $userAppsJsonFile = Join-Path -Path (Split-Path -Parent $scriptPath) -ChildPath "UserAppList.json"
+ if (-not (Test-Path -Path $wingetAppsJsonFile) -and -not (Test-Path -Path $userAppsJsonFile)) {
+ $shouldRun = $false
+ }
+ }
+ "Install-StoreApps.ps1" {
+ $msStorePath = "D:\MSStore"
+ if (-not (Test-Path -Path $msStorePath) -or -not (Get-ChildItem -Path $msStorePath)) {
+ $shouldRun = $false
+ }
+ }
+ }
+
+ if ($shouldRun) {
Write-Host "`n" # Add a newline for spacing
Write-Host "---------------------------------------------------" -ForegroundColor Yellow
Write-Host " Running script: $script " -ForegroundColor Yellow
diff --git a/FFUDevelopment/BuildFFUVM_UI.xaml b/FFUDevelopment/BuildFFUVM_UI.xaml
index 8e10d0e..fecf2b0 100644
--- a/FFUDevelopment/BuildFFUVM_UI.xaml
+++ b/FFUDevelopment/BuildFFUVM_UI.xaml
@@ -356,7 +356,7 @@
-
+
diff --git a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Applications.psm1 b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Applications.psm1
index 2582cc7..02f25cf 100644
--- a/FFUDevelopment/FFUUI.Core/FFUUI.Core.Applications.psm1
+++ b/FFUDevelopment/FFUUI.Core/FFUUI.Core.Applications.psm1
@@ -52,8 +52,8 @@ function Add-BYOApplication {
$arguments = $State.Controls.txtAppArguments.Text
$source = $State.Controls.txtAppSource.Text
- if ([string]::IsNullOrWhiteSpace($name) -or [string]::IsNullOrWhiteSpace($commandLine) -or [string]::IsNullOrWhiteSpace($arguments)) {
- [System.Windows.MessageBox]::Show("Please fill in all fields (Name, Command Line, and Arguments)", "Missing Information", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
+ if ([string]::IsNullOrWhiteSpace($name) -or [string]::IsNullOrWhiteSpace($commandLine)) {
+ [System.Windows.MessageBox]::Show("Please fill in all fields (Name and Command Line)", "Missing Information", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
$listView = $State.Controls.lstApplications
@@ -150,8 +150,8 @@ function Save-BYOApplicationList {
try {
# Ensure items are sorted by current priority before saving
- # Exclude CopyStatus when saving
- $applications = $listView.Items | Sort-Object Priority | Select-Object Priority, Name, CommandLine, Arguments, Source
+ # Exclude CopyStatus when saving and ensure Priority is an integer
+ $applications = $listView.Items | Sort-Object Priority | Select-Object @{N = 'Priority'; E = { [int]$_.Priority } }, Name, CommandLine, Arguments, Source
$applications | ConvertTo-Json -Depth 5 | Set-Content -Path $Path -Force -Encoding UTF8
[System.Windows.MessageBox]::Show("Applications saved successfully to `"$Path`".", "Save Applications", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Information)
}
@@ -343,7 +343,7 @@ function Start-CopyBYOApplicationTask {
# Build the new entry
$newEntry = [pscustomobject]@{
- Priority = $priority
+ Priority = [int]$priority
Name = $appName
CommandLine = $commandLine
Arguments = $arguments