From c2a924994fb8a08fc056913d233ff05335ef6434 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 16 Apr 2021 10:23:00 +0200 Subject: [PATCH 1/4] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..47c93ec --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# AlwaysUpToDate +> A simple .NET auto updater + +#README comming soon From 7d5ec2e6c2a6b90a5a3209252a1de8f653cdda65 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 16 Apr 2021 10:23:08 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47c93ec..36db03f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # AlwaysUpToDate > A simple .NET auto updater -#README comming soon +# README comming soon From 26220afd8c8556e1f09ae50d24c1c22645b8837c Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:12:09 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36db03f..8e3067d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,81 @@ # AlwaysUpToDate > A simple .NET auto updater -# README comming soon +## 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 +```json +{ + "Version":"version", + "FileUrl":"url", + "Mandatory":false +} +``` + +### Creating new `Updater` and starting it +```cs +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 +```cs +... + 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}%"); +} +``` From 7639a034f19a916a7d229e1c53ef6a9e2744fe90 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 16 Apr 2021 11:43:47 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8e3067d..7b91db9 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ## Download ### Package Manager -`Install-Package Stone_Red-C-Sharp-Utilities` +`Install-Package AlwaysUpToDate` ### .NET CLI -`dotnet add package Stone_Red-C-Sharp-Utilities` +`dotnet add package AlwaysUpToDate` ### NuGet -https://www.nuget.org/packages/Stone_Red-C-Sharp-Utilities +https://www.nuget.org/packages/AlwaysUpToDate ## How it works AlwaysUpToDate downloads an json information file containing update information from your server.