Onova is a lightweight auto-update framework for desktop applications. It's primarily designed for performing in-place updates for portable applications distributed via archive files (as opposed to installers or packages). The library requires minimal configuration, doesn't impose any changes to the CI/CD process, and doesn't affect the life cycle of your application.
β¨ See also Onova.Publisher β community project that provides an integrated installation experience based on Onova.
By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:
To learn more about the war and how you can help, click here. Glory to Ukraine! πΊπ¦
dotnet add package Onova
LocalPackageResolver
- file systemGithubPackageResolver
- GitHub releasesWebPackageResolver
- web version manifestNugetPackageResolver
- NuGet feedAggregatePackageResolver
- aggregates multiple resolversZipPackageExtractor
- zip archivesNugetPackageExtractor
- NuGet packagesPackages and their versions are resolved using an implementation of IPackageResolver
. Currently there are 5 built-in implementations:
LocalPackageResolver
This implementation looks for files in the specified directory using a predefined pattern. Package versions are extracted from file names, e.g. file named MyProject-v2.1.5.zip
corresponds to package version 2.1.5
.
GithubPackageResolver
This implementation looks for assets in releases of specified GitHub repository using a predefined pattern. Package versions are extracted from release names, e.g. release named v1.0
corresponds to package version 1.0
.
Since .NET assemblies do not support semantic versions, pre-releases are ignored.
WebPackageResolver
This implementation requests a version manifest using the specified URL. The server is expected to respond with a plain-text list of package versions and their URLs, separated by space, one line per package. E.g.:
1.0 https://my.server.com/1.0.zip
2.0 https://my.server.com/2.0.zip
NugetPackageResolver
This implementation resolves packages from the specified NuGet feed.
Since .NET assemblies do not support semantic versions, pre-releases are ignored.
AggregatePackageResolver
This implementation provides aggregation over multiple other IPackageResolver
instances. It allows resolving and downloading packages from more than one source.
Downloaded packages are extracted using an implementation of IPackageExtractor
. Currently there are 2 built-in implementations:
ZipPackageExtractor
This implementation extracts files from zip-archived packages.
NugetPackageExtractor
This implementation extracts files from NuGet packages, from the specified root directory.
The following code checks for updates and installs them if they are available, in a single operation.
// Configure to look for packages in specified directory and treat them as zips
using (var manager = new UpdateManager(
new LocalPackageResolver("c:\\test\\packages", "*.zip"),
new ZipPackageExtractor()))
{
// Check for new version and, if available, perform full update and restart
await manager.CheckPerformUpdateAsync();
}
To provide users with the most optimal experience, you will probably want to handle intermediate steps manually.
// Check for updates
var result = await manager.CheckForUpdatesAsync();
if (result.CanUpdate)
{
// Prepare an update by downloading and extracting the package
// (supports progress reporting and cancellation)
await manager.PrepareUpdateAsync(result.LastVersion);
// Launch an executable that will apply the update
// (can be instructed to restart the application afterwards)
manager.LaunchUpdater(result.LastVersion);
// Terminate the running application so that the updater can overwrite files
Environment.Exit(0);
}
To prevent conflicts when running multiple instances of the same application, only one instance of UpdateManager
(across all processes) is able to prepare updates and launch the updater.
In order to correctly handle cases where multiple instances of the application may try to update at the same time, you need to catch these exceptions:
LockFileNotAcquiredException
- thrown by PrepareUpdateAsync
and LaunchUpdater
when this instance of UpdateManager
cannot acquire a lock file. This means that another instance currently owns the lock file and is probably performing an update.UpdaterAlreadyLaunchedException
- thrown by PrepareUpdateAsync
and LaunchUpdater
when an updater executable has already been launched, either by this instance of UpdateManager
or another instance that has released the lock file.The updater will wait until all instances of the application have exited before applying an update, regardless of which instance launched it.
The name "Onova" is derived from the Ukrainian word for "update" (noun).