AlwaysUpToDate 1.0.0.4

dotnet add package AlwaysUpToDate --version 1.0.0.4
NuGet\Install-Package AlwaysUpToDate -Version 1.0.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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
#r "nuget: AlwaysUpToDate, 1.0.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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

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}%");
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 490 6/26/2021
1.0.0.3 380 5/29/2021
1.0.0.2 330 4/16/2021
1.0.0.1 326 4/16/2021