commit
d0c47c31f8
|
@ -0,0 +1,22 @@
|
|||
#Function to check if modification exists in 'mods' directory
|
||||
|
||||
function Test-Mods ($app){
|
||||
|
||||
#Takes care of a null situation
|
||||
$ModsInstall = $null
|
||||
$ModsUpgrade = $null
|
||||
|
||||
$Mods = "$WorkingDir\mods"
|
||||
if (Test-Path "$Mods\$app-*"){
|
||||
if (Test-Path "$Mods\$app-install.ps1"){
|
||||
$ModsInstall = "$Mods\$app-install.ps1"
|
||||
$ModsUpgrade = "$Mods\$app-install.ps1"
|
||||
}
|
||||
if (Test-Path "$Mods\$app-upgrade.ps1"){
|
||||
$ModsUpgrade = "$Mods\$app-upgrade.ps1"
|
||||
}
|
||||
}
|
||||
|
||||
return $ModsInstall,$ModsUpgrade
|
||||
|
||||
}
|
|
@ -16,6 +16,14 @@ 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) during upgrade are being applied..." "Yellow"
|
||||
& "$ModsUpgrade"
|
||||
}
|
||||
|
||||
#Check if application updated properly
|
||||
$CheckOutdated = Get-WingetOutdatedApps
|
||||
$FailedToUpgrade = $false
|
||||
|
@ -24,6 +32,11 @@ 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
|
||||
|
||||
if ($ModsInstall){
|
||||
Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow"
|
||||
& "$ModsInstall"
|
||||
}
|
||||
|
||||
#Check if application installed properly
|
||||
$CheckOutdated2 = Get-WingetOutdatedApps
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# Winget-Install
|
||||
|
||||
## Mods
|
||||
|
||||
The Mod feature allows you to run an additional script when installing or upgrading an app.
|
||||
Just put the script with the App ID followed by the "-install" or "-upgrade" suffix to be considered.
|
||||
`AppID-install.ps1` and/or `AppID-upgrade.ps1` (if it differs, otherwise the "-install" mod will be used for upgrade)
|
||||
and put this in the Mods directory
|
||||
> Example:
|
||||
> If you want to run a script just after installing ".NET Desktop Runtime 6", call your script like this:
|
||||
> `Microsoft.dotnetRuntime.6-x64-install.ps1`
|
||||
|
||||
In the case of ".NET Desktop Runtime 6" it spawns a new process and this we will have to wait for completion of before moving on to checking if the installation/upgrade suceeded or not. - (this seems to be handled in Winget Version: v1.3.0-preview)
|
Loading…
Reference in New Issue