AlwaysUpToDate 1.0.0.4

Install-Package AlwaysUpToDate -Version 1.0.0.4
dotnet add package AlwaysUpToDate --version 1.0.0.4
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AlwaysUpToDate --version 1.0.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AlwaysUpToDate, 1.0.0.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install AlwaysUpToDate as a Cake Addin
#addin nuget:?package=AlwaysUpToDate&version=1.0.0.4

// Install AlwaysUpToDate as a Cake Tool
#tool nuget:?package=AlwaysUpToDate&version=1.0.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

AlwaysUpToDate

A simple .NET auto updater

Download

Package Manager

Install-Package AlwaysUpToDate

.NET CLI

dotnet add package AlwaysUpToDate

NuGet

https://www.nuget.org/packages/AlwaysUpToDate

How it works

AlwaysUpToDate downloads a json file containing update information from your server. The file gets used to determent if an update is available. If the version in the file is greater than the assembly version of your application then either the update event gets triggered or you can decide if you want to download the update or if the update is marked as mandatory it gets downloaded and installed instantly. After the install the new version will be started automatically.

More detailed how it works

After you started the updater, it will check at the specified time interval if a new version is available by downloading the json file.
If the latest version of the software is greater the current assembly version (Not assembly file version!). If the update is not mandatory the UpdateAvailible will be triggered and you can handle the time of the update yourself. If the update is mandatory, the new version will be downloaded instantly without asking.
While extracting the zip file all the files that have the same name/path as in the zip file will get marked as old(add _OLD_ to the name). After the extraction, the installer tries to delete all files marked as old. The files it is unable to delete will just sit there and the installer tries to delete them at th next update. After that it will try to start the new version (for that to work the executable name has to be the same as the old one).

Usage

Creating json file

  • Version (Required): The version should have this format X.X.X.X
  • FileUrl (Required): Url to the newest installer version zip file
  • Mandatory (Optional): Should be either true or false. The default is false
  • AdditionalInformation (Optional): Can be anything. This will get passed as a parameter of the UpdateAvailible event.
{
   "Version":"version",
   "FileUrl":"url",
   "Mandatory":false,
   "AdditionalInformation":"information",
}

Creating new Updater and starting it

Updater downloader = new Updater(
new TimeSpan(0, 0, 1), //Update interval
"https://raw.githubusercontent.com/Stone-Red-Code/Test/main/test.json", //Json file url
"./" //Install path
);
updater.Start();

Adding event handlers

...
    updater.ProgressChanged += Updater_ProgressChanged;
    updater.UpdateAvailible += Updater_UpdateAvailible;
}

private static void Downloader_UpdateAvailible(string version, string additionalInformationUrl)
{
}

private static void Downloader_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage)
{
}

Handeling the update

private static void Updater_UpdateAvailible(string version, string additionalInformation)
{
    Console.WriteLine("New Update avalible: " + version);
    Console.WriteLine("Do you want to install the new update? (y/n)");

    char input = Console.ReadKey().KeyChar;

    if (char.ToLower(input) == 'y')
        updater.Update();
}

Download process reporting

private static void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage)
{
    Console.WriteLine($"{totalBytesDownloaded}/{totalFileSize}  {progressPercentage}%");
}

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.4 185 6/26/2021
1.0.0.3 136 5/29/2021
1.0.0.2 128 4/16/2021
1.0.0.1 119 4/16/2021