Retry installation if "upgrade" failed

#11
pull/13/head
Romain 2022-02-22 18:08:32 +01:00
parent 181d7898bc
commit d5dd6ef76f
1 changed files with 10 additions and 4 deletions

View File

@ -9,7 +9,7 @@ function Init {
$Log | Write-host $Log | Write-host
try{ try{
#Logs initialisation #Logs initialisation
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$LogPath = "$WorkingDir\logs" $LogPath = "$WorkingDir\logs"
if (!(Test-Path $LogPath)){ if (!(Test-Path $LogPath)){
New-Item -ItemType Directory -Force -Path $LogPath New-Item -ItemType Directory -Force -Path $LogPath
@ -269,9 +269,15 @@ if (Test-Network){
Start-NotifTask $Title $Message $MessageType $Balise Start-NotifTask $Title $Message $MessageType $Balise
#Winget upgrade #Winget upgrade
Write-Log "------ Winget - $($app.Name) Upgrade Starts ------" "Gray" Write-Log "########## WINGET PROCESS STARTS FOR '$($app.Name)' ##########" "Gray"
& $upgradecmd upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $UpgradeCmd upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
Write-Log "----- Winget - $($app.Name) Upgrade Finished -----" "Gray" $checkoutdated = Get-WingetOutdated
foreach ($checkapp in $checkoutdated){
if ($($checkapp.Id) -eq $($app.Id)) {
$FailedToUpgrade = $true
}
}
Write-Log "########## WINGET PROCESS FINISHED FOR '$($app.Name)' ##########" "Gray"
#Check installed version #Check installed version
$checkoutdated = Get-WingetOutdated $checkoutdated = Get-WingetOutdated