mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -356,7 +356,7 @@
|
||||
|
||||
<!-- Command Line -->
|
||||
<TextBlock Text="Command Line:" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="txtAppCommandLine" Margin="0,0,0,10" ToolTip="Enter the full path to the command line to install the application. This should start with D:\ for exe, cmd, etc types of deployments (e.g. D:\Win32\Mozilla FireFox\setup.exe). For MSI installs, use msiexec and then fill in the rest of the arguments in the arguments field."/>
|
||||
<TextBox x:Name="txtAppCommandLine" Margin="0,0,0,10" ToolTip="Enter the full path to the command line to install the application. This should start with D:\Win32 for exe, cmd, etc types of deployments (e.g. D:\Win32\Mozilla FireFox\setup.exe). For MSI installs, use msiexec and then fill in the rest of the arguments in the arguments field."/>
|
||||
|
||||
<!-- Arguments -->
|
||||
<TextBlock Text="Arguments:" Margin="0,0,0,5"/>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user