Class WindowsAppUpdaterProvider
- Namespace
- VpnHood.AppUi.Hosting.Desktop.WindowsTun
- Assembly
- VpnHood.AppUi.Hosting.Desktop.WindowsTun.dll
Provides the app's update on Windows, for an install from the website: it hands the package to the install's own
updater, vhupdate.ps1 in its root, which is the automatic update too.
public sealed class WindowsAppUpdaterProvider : DesktopAppUpdaterProvider, IAppUpdaterProvider
- Inheritance
-
WindowsAppUpdaterProvider
- Implements
- Inherited Members
Remarks
The task's runs of the updater check the feed; an install here hands it the downloaded package, whose own version it
checks, then runs the setup silently, which stops this service, closes the windows and trays that run from the
install, puts the new version in and asks Windows to start it, and the new service tries to open those windows and
trays again.
Here the updater runs as a child of this service; its output goes to update.log beside it.
Methods
IsAutomaticUpdateOn(CancellationToken)
Gets whether the updater's task is on, as the setup left it or the person set it.
public override Task<bool> IsAutomaticUpdateOn(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
schtasks could not be run.
RunInstaller(string)
Runs the install's updater on a package, and waits for it.
protected override Task<string?> RunInstaller(string packagePath)
Parameters
packagePathstringThe package.
Returns
- Task<string>
A task whose result is why the update installed nothing: the update log's last line that is not blank, or the updater's exit code. The setup stops this service before it puts anything in, so an updater that ends first installed nothing.
Exceptions
- InvalidOperationException
The updater could not be started.
RunUpdater(CancellationToken)
Runs the updater's task now; its triggers keep their times, and a run under way ignores it.
protected override Task RunUpdater(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that completes once the run is asked for.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
schtasks could not be run, or could not run the task.
SetAutomaticUpdate(bool, CancellationToken)
Turns the updater's task on or off, as the setup does.
public override Task SetAutomaticUpdate(bool isOn, CancellationToken cancellationToken)
Parameters
isOnbooltrue to turn it on.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
Turned on, it asks for one run at once, a check now, which a run under way ignores; where that request fails, it is logged, and the task stays on.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled.- InvalidOperationException
schtasks could not be run, or could not enable or disable the task.
TryCreate(AppOptionsContext)
Creates the updater of an install the setup made, whose version's folder holds the setup's publish.json.
public static WindowsAppUpdaterProvider? TryCreate(AppOptionsContext context)
Parameters
contextAppOptionsContextThe app's options context, with its app ID and version.
Returns
- WindowsAppUpdaterProvider
The updater, or null where the install has no updater script or the version's folder no
publish.json, as in a debugger's build.
Exceptions
- InvalidDataException
The
UpdateInfoUrlproperty inpublish.jsonis null.- InvalidOperationException
The entry assembly has no name, so the install has none.