From 144a4bbd38a5be3a3f3758dd4e1696653c71490d Mon Sep 17 00:00:00 2001 From: GAJ-san Date: Wed, 27 Jul 2022 09:44:11 +0200 Subject: [PATCH 1/6] Bug in mods testing (foreach) --- Winget-AutoUpdate/functions/Update-App.ps1 | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 9c1f2bd..dc8b3a4 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -18,36 +18,35 @@ Function Update-App ($app) { #Run Winget Upgrade command & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - + + #Check if mods exist + $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) + if ($ModsUpgrade) { + Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" + & "$ModsUpgrade" + } + #Check if application updated properly $CheckOutdated = Get-WingetOutdatedApps $FailedToUpgrade = $false - #Check if mods exist - $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) foreach ($CheckApp in $CheckOutdated) { if ($($CheckApp.Id) -eq $($app.Id)) { #If app failed to upgrade, run Install command & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - + + $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) + if ($ModsInstall) { + Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" + & "$ModsInstall" + } + #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps foreach ($CheckApp2 in $CheckOutdated2) { if ($($CheckApp2.Id) -eq $($app.Id)) { $FailedToUpgrade = $true } - else { - if ($ModsInstall) { - Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" - & "$ModsInstall" - } - } - } - } - else { - if ($ModsUpgrade) { - Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" - & "$ModsUpgrade" } } } From ae7a1b63cf414e692d2008ed9b2fff5c58d4a41f Mon Sep 17 00:00:00 2001 From: GAJ-san Date: Wed, 27 Jul 2022 12:00:41 +0200 Subject: [PATCH 2/6] More description --- Winget-AutoUpdate/functions/Update-App.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index dc8b3a4..a586ad7 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -19,7 +19,7 @@ Function Update-App ($app) { #Run Winget Upgrade command & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Check if mods exist + #Check if mods exist for upgrade $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) if ($ModsUpgrade) { Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" @@ -35,6 +35,7 @@ Function Update-App ($app) { #If app failed to upgrade, run Install command & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append + #Check if mods exist for install $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) if ($ModsInstall) { Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" From 7e38b02d9863057db857d5b0344eb52e0b18208f Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Wed, 27 Jul 2022 17:40:40 +0200 Subject: [PATCH 3/6] Better implement of mods upgrade --- Winget-AutoUpdate/functions/Update-App.ps1 | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index a586ad7..4d93c8b 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -19,13 +19,6 @@ Function Update-App ($app) { #Run Winget Upgrade command & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Check if mods exist for upgrade - $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if ($ModsUpgrade) { - Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" - & "$ModsUpgrade" - } - #Check if application updated properly $CheckOutdated = Get-WingetOutdatedApps $FailedToUpgrade = $false @@ -35,13 +28,6 @@ Function Update-App ($app) { #If app failed to upgrade, run Install command & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Check if mods exist for install - $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if ($ModsInstall) { - Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" - & "$ModsInstall" - } - #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps foreach ($CheckApp2 in $CheckOutdated2) { @@ -52,6 +38,16 @@ Function Update-App ($app) { } } + if ($FailedToUpgrade -eq $false) { + + #Check if mods exist for install/upgrade + $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) + if ($ModsUpgrade) { + Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" + & "$ModsUpgrade" + } + } + Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" #Notify installation From ab6d29daddcff564434dd96b07c0fefa337a8efe Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 28 Jul 2022 19:09:50 +0200 Subject: [PATCH 4/6] ModsMode for Install/Upgrade --- Winget-AutoUpdate/functions/Update-App.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 4d93c8b..a72951f 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -19,6 +19,9 @@ Function Update-App ($app) { #Run Winget Upgrade command & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append + #Set mods to apply as an upgrade + $ModsMode = "Upgrade" + #Check if application updated properly $CheckOutdated = Get-WingetOutdatedApps $FailedToUpgrade = $false @@ -28,6 +31,9 @@ Function Update-App ($app) { #If app failed to upgrade, run Install command & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append + #Set mods to apply as an install + $ModsMode = "Install" + #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps foreach ($CheckApp2 in $CheckOutdated2) { @@ -42,10 +48,14 @@ Function Update-App ($app) { #Check if mods exist for install/upgrade $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if ($ModsUpgrade) { + if ($ModsMode = "Upgrade") { Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" & "$ModsUpgrade" } + elseif ($ModsMode = "Install") { + Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" + & "$ModsInstall" + } } Write-Log "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray" From 5123ea8ca2e8ddf98258779d85e325429c59d26d Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 28 Jul 2022 19:19:15 +0200 Subject: [PATCH 5/6] Forgot about $ModsUpgrade --- Winget-AutoUpdate/functions/Update-App.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index a72951f..ea30638 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -48,11 +48,11 @@ Function Update-App ($app) { #Check if mods exist for install/upgrade $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if ($ModsMode = "Upgrade") { + if (($ModsUpgrade) -and ($ModsMode = "Upgrade")) { Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" & "$ModsUpgrade" } - elseif ($ModsMode = "Install") { + elseif (($ModsInstall) -and ($ModsMode = "Install")) { Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" & "$ModsInstall" } From 9125956900afbdffc97e1c0026596f4f6b7f2565 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 28 Jul 2022 19:45:11 +0200 Subject: [PATCH 6/6] Done (I think)... --- Winget-AutoUpdate/functions/Update-App.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index ea30638..55cdefb 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -48,11 +48,12 @@ Function Update-App ($app) { #Check if mods exist for install/upgrade $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - if (($ModsUpgrade) -and ($ModsMode = "Upgrade")) { + + if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) { Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" & "$ModsUpgrade" } - elseif (($ModsInstall) -and ($ModsMode = "Install")) { + elseif (($ModsInstall) -and ($ModsMode -eq "Install")) { Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" & "$ModsInstall" }