AlwaysUpToDate 1.0.0.1
See the version list below for details.
dotnet add package AlwaysUpToDate --version 1.0.0.1
NuGet\Install-Package AlwaysUpToDate -Version 1.0.0.1
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.1" />
paket add AlwaysUpToDate --version 1.0.0.1
#r "nuget: AlwaysUpToDate, 1.0.0.1"
// Install AlwaysUpToDate as a Cake Addin #addin nuget:?package=AlwaysUpToDate&version=1.0.0.1 // Install AlwaysUpToDate as a Cake Tool #tool nuget:?package=AlwaysUpToDate&version=1.0.0.1
AlwaysUpToDate
A simple .NET auto updater
Download
Package Manager
Install-Package Stone_Red-C-Sharp-Utilities
.NET CLI
dotnet add package Stone_Red-C-Sharp-Utilities
NuGet
https://www.nuget.org/packages/Stone_Red-C-Sharp-Utilities
How it works
AlwaysUpToDate downloads an json information 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
{
"Version":"version",
"FileUrl":"url",
"Mandatory":false
}
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 additionalInformationUrl)
{
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 | Versions 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. |
-
.NETStandard 2.1
- System.Text.Json (>= 5.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.