Final
parent
b40a578baf
commit
1705b80518
|
@ -183,6 +183,7 @@ Just put the scripts in question with the **AppID** followed by the `-preinstall
|
|||
>- Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
|
||||
>- Runs after upgrade/install has been confirmed: `AppID-installed.ps1`
|
||||
>- Runs after a failed upgrade/install: `AppID-notinstalled.ps1`
|
||||
>- Runs after a failed upgrade/install: `_WAU-notinstalled.ps1` (any individual `AppID-notinstalled.ps1` overrides this global one)
|
||||
|
||||
The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).<br>
|
||||
`AppID-install.ps1` is recommended because it's used in **both** scenarios.
|
||||
|
|
|
@ -8,9 +8,14 @@ function Test-Mods ($app) {
|
|||
$ModsUpgrade = $null
|
||||
$ModsInstall = $null
|
||||
$ModsInstalled = $null
|
||||
$ModsNotInstalled = $ null
|
||||
$ModsNotInstalled = $null
|
||||
|
||||
$Mods = "$WorkingDir\mods"
|
||||
|
||||
if (Test-Path "$Mods\_WAU-notinstalled.ps1") {
|
||||
$ModsNotInstalled = "$Mods\_WAU-notinstalled.ps1"
|
||||
}
|
||||
|
||||
if (Test-Path "$Mods\$app-*") {
|
||||
if (Test-Path "$Mods\$app-preinstall.ps1") {
|
||||
$ModsPreInstall = "$Mods\$app-preinstall.ps1"
|
||||
|
|
|
@ -81,16 +81,25 @@ Function Update-App ($app) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($FailedToUpgrade -eq $false) {
|
||||
switch ($FailedToUpgrade)
|
||||
{
|
||||
# Upgrade/install was successful
|
||||
$false
|
||||
{
|
||||
if ($ModsInstalled) {
|
||||
Write-ToLog "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow"
|
||||
& "$ModsInstalled"
|
||||
}
|
||||
}
|
||||
elseif ($FailedToUpgrade -eq $true -and $ModsNotInstalled) {
|
||||
# Upgrade/install was unsuccessful
|
||||
$true
|
||||
{
|
||||
if ($ModsNotInstalled) {
|
||||
Write-ToLog "Modifications for $($app.Id) after a failed upgrade/install are being applied..." "Yellow"
|
||||
& "$ModsNotInstalled"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-ToLog "########## WINGET UPGRADE PROCESS FINISHED FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Custom script should be placed here.
|
||||
A script **Template** `_WAU-mods-template.ps1` is included to get you started.
|
||||
Rename it to `_WAU-mods.ps1` if you want to activate/run it via `Winget-Upgrade.ps1`.
|
||||
### Pre/During/Post install/uninstall:
|
||||
### AppID Pre/During/Post install/uninstall:
|
||||
Custom scripts should be placed here.
|
||||
A script **Template** and **Mods Functions** are included as an **example** to get you started...
|
||||
|
||||
|
@ -10,15 +10,19 @@ Scripts that are considered:
|
|||
**AppID**`-preinstall.ps1`, `-upgrade.ps1`, `-install.ps1`, `-installed.ps1` or `-notinstalled.ps1`.
|
||||
(`-preuninstall.ps1`, `-uninstall.ps1` or `-uninstalled.ps1` - if used together with [Winget-Install](https://github.com/Romanitho/Winget-Install)).
|
||||
|
||||
> Runs before upgrade/install: `AppID-preinstall.ps1`
|
||||
> Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
|
||||
> Runs after upgrade/install has been confirmed: `AppID-installed.ps1`
|
||||
> Runs after a failed upgrade/install: `AppID-notinstalled.ps1`
|
||||
>- Runs before upgrade/install: `AppID-preinstall.ps1`
|
||||
>- Runs during upgrade/install (before install check): `AppID-upgrade.ps1`/`AppID-install.ps1`
|
||||
>- Runs after upgrade/install has been confirmed: `AppID-installed.ps1`
|
||||
>- Runs after a failed upgrade/install: `AppID-notinstalled.ps1`
|
||||
>- Runs after a failed upgrade/install: `_WAU-notinstalled.ps1` (any individual `AppID-notinstalled.ps1` overrides this global one)
|
||||
|
||||
The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist (**WAU** first tries `& $Winget upgrade --id` and if the app isn't detected after that `& $Winget install --id` is tried).
|
||||
|
||||
`AppID-install.ps1` is recommended because it's used in **both** scenarios.
|
||||
|
||||
A script **Template** for an all-purpose mod (`_WAU-notinstalled-template.ps1`) is included in which actions can be taken if an upgrade/install fails for any **AppID** (any individual `AppID-notinstalled.ps1` overrides this global one)
|
||||
Name it `_WAU-notinstalled.ps1` for activation
|
||||
|
||||
### Winget native parameters:
|
||||
Another finess is the **AppID** followed by the `-override` suffix as a **text file** (**.txt**).
|
||||
> Example:
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<# An all-purpose mod for doing things
|
||||
if an AppID upgrade/install in WAU fails
|
||||
Name it:
|
||||
"$Mods\_WAU-notinstalled.ps1"
|
||||
|
||||
This all-purpose mod will be overridden by any specific:
|
||||
"$Mods\AppID-notinstalled.ps1"
|
||||
#>
|
||||
|
||||
<# FUNCTIONS #>
|
||||
. $PSScriptRoot\_Mods-Functions.ps1
|
||||
|
||||
<# ARRAYS/VARIABLES #>
|
||||
|
||||
|
||||
<# MAIN #>
|
||||
if ($($app.Id) -eq "Microsoft.SQLServerManagementStudio") {
|
||||
$ConfirmInstall = Confirm-Installation $($app.Id) $($app.AvailableVersion)
|
||||
if ($ConfirmInstall -ne $true) {
|
||||
try {
|
||||
Write-ToLog "...succesfully done something" "Green"
|
||||
}
|
||||
catch {
|
||||
Write-ToLog "...failed to do something" "Red"
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-ToLog "...nothing defined for $($app.Id)" "Yellow"
|
||||
}
|
Loading…
Reference in New Issue