This is a .net standard class library that allows application to update themselves. The main goal of this project is to create a library that supports creating self-updating applications. This library will make this process straight-forward.
- The latest version of your application is deployed as a single ZIP file as a GitHub release.
- You can use the
Update
class if you needINotifyPropertyChanged
:
using AutoUpdateViaGitHubRelease;
...
var update = new Update();
update.PropertyChanged += Update_PropertyChanged;
var assembly = Assembly.GetExecutingAssembly();
var version = assembly.GetName().Version;
update.CheckDownloadNewVersionAsync(GitHubUser, GitHubRepo, version, tempDir);
...
private void Update_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if(update.Available)
{
var destinationDir = Path.GetDirectory(assembly.Location);
update.StartInstall(destinationDir);
Application.Close();
}
}
- If you want more control, you can use the methods from the
UpdateTools
class:
using AutoUpdateViaGitHubRelease;
...
var assembly = Assembly.GetExecutingAssembly();
var tempDir = Path.Combine(Path.GetTempPath(), nameof(ApplicationName));
Directory.CreateDirectory(tempDir);
var updateArchive = Path.Combine(tempDir, "update.zip");
var version = assembly.GetName().Version;
var updateTask = UpdateTools.CheckDownloadNewVersionAsync(GitHubUser, GitHubRepo, assembly.GetName().Version, updateArchive);
... // application code
var updateAvailable = updateTask.Result;
if (updateAvailable)
{
Console.Write("Update? (Y/N)");
if (ConsoleKey.Y == Console.ReadKey().Key)
{
var installer = Path.Combine(tempDir, UpdateTools.DownloadExtractInstallerToAsync(tempDir).Result);
var destinationDir = Path.GetDirectoryName(assembly.Location);
UpdateTools.StartInstall(installer, updateArchive, destinationDir); // don't wait for install process to finish in windows! The applications needs to be closed before it can be updated.
// Your application should close right after starting install
Environment.Exit(0);
}
}
See the change log for changes and road map.
- Check if a newer version is available
- Run update (you will need to close your application to allow overwriting your application files)
- Command line
- WPF
Please us the GitHub Issue function to report errors or ask questions.
Check out the contribution guidelines if you want to contribute to this project.